π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
:sparkles: Adds web search functionality
Alicia Sykes411357c5b6ea
diff --git a/src/components/Settings/SearchBar.vue b/src/components/Settings/SearchBar.vueindex a78976c6..8fbf4877 100644--- a/src/components/Settings/SearchBar.vue+++ b/src/components/Settings/SearchBar.vue@@ -1,5 +1,5 @@<template>- <form>+ <form @submit.prevent="searchSubmitted"><label for="filter-tiles">{{ $t('search.search-label') }}</label><inputid="filter-tiles"@@ -16,12 +16,15 @@</template><script>-+import router from '@/router';import ArrowKeyNavigation from '@/utils/ArrowKeyNavigation';+import ErrorHandler from '@/utils/ErrorHandler';import { getCustomKeyShortcuts } from '@/utils/ConfigHelpers';+import { searchEngineUrls, defaultSearchEngine, defaultSearchOpeningMethod } from '@/utils/defaults';export default {name: 'FilterTile',+ inject: ['config'],props: {active: Boolean,},@@ -74,6 +77,40 @@ export default {}});},+ launchWebSearch(url, method) {+ switch (method) {+ case 'newtab':+ window.open(url, '_blank');+ break;+ case 'sametab':+ window.open(url, '_self');+ break;+ case 'workspace':+ router.push({ name: 'workspace', query: { url } });+ break;+ default:+ ErrorHandler(`Unknown opening method: ${method}`);+ window.open(url, '_blank');+ }+ },+ searchSubmitted() {+ // Get search preferences from appConfig+ const { appConfig } = this.config;+ const searchPrefs = appConfig.webSearch || {};+ if (!searchPrefs.disableWebSearch) { // Only proceed if user hasn't disabled web search+ const openingMethod = searchPrefs.openingMethod || defaultSearchOpeningMethod;+ // Get search engine, and make URL+ const searchEngine = searchPrefs.searchEngine || defaultSearchEngine;+ let searchUrl = searchEngineUrls[searchEngine];+ if (!searchUrl) ErrorHandler(`Search engine not found - ${searchEngine}`);+ if (searchEngine === 'custom' && searchPrefs.customSearchEngine) {+ searchUrl = searchPrefs.customSearchEngine;+ }+ // Append users encoded query onto search URL, and launch+ searchUrl += encodeURIComponent(this.input);+ this.launchWebSearch(searchUrl, openingMethod);+ }+ },},};</script>diff --git a/src/utils/defaults.js b/src/utils/defaults.jsindex 10d18ad1..6ceb0a41 100644--- a/src/utils/defaults.js+++ b/src/utils/defaults.js@@ -152,6 +152,35 @@ module.exports = {localPath: '/item-icons',faviconName: 'favicon.ico',},+ /* URLs for web search engines */+ searchEngineUrls: {+ // Common+ duckduckgo: 'https://duckduckgo.com/?q=',+ google: 'https://google.com/search?q=',+ whoogle: 'https://whoogle.sdf.org/search?q=',+ qwant: 'https://www.qwant.com/?q=',+ startpage: 'https://www.startpage.com/do/search?query=',+ // Niche+ 'searx-bar': 'https://searx.bar/search?q=',+ 'searx-info': 'https://searx.info/search?q=',+ 'searx-tiekoetter': 'https://searx.tiekoetter.com/search?q=',+ 'searx-bissisoft': 'https://searx.bissisoft.com/search?q=',+ ecosia: 'https://www.ecosia.org/search?q=',+ metager: 'https://metager.org/meta/meta.ger3?eingabe=',+ swisscows: 'https://swisscows.com/web?query=',+ mojeek: 'https://www.mojeek.com/search?q=',+ peekier: 'https://peekier.com/#!',+ // Specific+ wikipedia: 'https://en.wikipedia.org/w/?search=',+ stackoverflow: 'https://stackoverflow.com/search?q=',+ wolframalpha: 'https://www.wolframalpha.com/input/?i=',+ reddit: 'https://www.reddit.com/search/?q=',+ youtube: 'https://youtube.com/results?q=',+ github: 'https://github.com/search?q=',+ bbc: 'https://www.bbc.co.uk/search?q=',+ },+ defaultSearchEngine: 'duckduckgo',+ defaultSearchOpeningMethod: 'newtab',/* Available built-in colors for the theme builder */swatches: [['#eb5cad', '#985ceb', '#5346f3', '#5c90eb'],