From afdb23ff572dcb40073419827746a9015163bb1e Mon Sep 17 00:00:00 2001 From: Hakaba Hitoyo Date: Thu, 29 Nov 2018 11:05:17 +0900 Subject: [PATCH] Feature / Configurable web search engine (#3406) * configurable web search engine * add webSearchEngine config in mobile ui * add webSearchEngine config in desktop ui * add webSearchEngine config * add messages for web search engine config * correct locale --- locales/ja-JP.yml | 4 ++++ src/client/app/common/views/components/google.vue | 5 ++++- src/client/app/desktop/views/components/settings.vue | 10 ++++++++++ src/client/app/mobile/views/pages/settings.vue | 10 ++++++++++ src/client/app/store.ts | 1 + 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 239533998..92c4f4c91 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -824,6 +824,8 @@ desktop/views/components/settings.vue: note-visibility: "投稿の公開範囲" default-note-visibility: "デフォルトの公開範囲" remember-note-visibility: "投稿の公開範囲を記憶する" + web-search-engine: "ウェブ検索エンジン" + web-search-engine-desc: "例: https://www.google.com/?#q={{query}}" auto-popout: "ウィンドウの自動ポップアウト" auto-popout-desc: "ウィンドウが開かれるとき、ポップアウト(ブラウザ外に切り離す)可能なら自動でポップアウトします。この設定はブラウザに記憶されます。" advanced: "詳細設定" @@ -1564,6 +1566,8 @@ mobile/views/pages/settings.vue: note-visibility: "投稿の公開範囲" default-note-visibility: "デフォルトの公開範囲" remember-note-visibility: "投稿の公開範囲を記憶する" + web-search-engine: "ウェブ検索エンジン" + web-search-engine-desc: "例: https://www.google.com/?#q={{query}}" disable-via-mobile: "「モバイルからの投稿」フラグを付けない" load-raw-images: "添付された画像を高画質で表示する" load-remote-media: "リモートサーバーのメディアを表示する" diff --git a/src/client/app/common/views/components/google.vue b/src/client/app/common/views/components/google.vue index 1d852cf25..dab2e6824 100644 --- a/src/client/app/common/views/components/google.vue +++ b/src/client/app/common/views/components/google.vue @@ -22,7 +22,10 @@ export default Vue.extend({ }, methods: { search() { - window.open(`https://www.google.com/?#q=${this.query}`, '_blank'); + const engine = this.$store.state.settings.webSearchEngine || + 'https://www.google.com/?#q={{query}}'; + const url = engine.replace('{{query}}', this.query) + window.open(url, '_blank'); } } }); diff --git a/src/client/app/desktop/views/components/settings.vue b/src/client/app/desktop/views/components/settings.vue index 62106768b..a474a5015 100644 --- a/src/client/app/desktop/views/components/settings.vue +++ b/src/client/app/desktop/views/components/settings.vue @@ -91,6 +91,11 @@ + +
+
{{ $t('web-search-engine') }}
+ {{ $t('web-search-engine') }}{{ $t('web-search-engine-desc') }} +
@@ -455,6 +460,11 @@ export default Vue.extend({ set(value) { this.$store.dispatch('settings/set', { key: 'defaultNoteVisibility', value }); } }, + webSearchEngine: { + get() { return this.$store.state.settings.webSearchEngine; }, + set(value) { this.$store.dispatch('settings/set', { key: 'webSearchEngine', value }); } + }, + showReplyTarget: { get() { return this.$store.state.settings.showReplyTarget; }, set(value) { this.$store.dispatch('settings/set', { key: 'showReplyTarget', value }); } diff --git a/src/client/app/mobile/views/pages/settings.vue b/src/client/app/mobile/views/pages/settings.vue index 0f5493392..8b6d0e79d 100644 --- a/src/client/app/mobile/views/pages/settings.vue +++ b/src/client/app/mobile/views/pages/settings.vue @@ -86,6 +86,11 @@ + +
+
{{ $t('web-search-engine') }}
+ {{ $t('web-search-engine') }}{{ $t('web-search-engine-desc') }} +
@@ -365,6 +370,11 @@ export default Vue.extend({ get() { return this.$store.state.settings.defaultNoteVisibility; }, set(value) { this.$store.dispatch('settings/set', { key: 'defaultNoteVisibility', value }); } }, + + webSearchEngine: { + get() { return this.$store.state.settings.webSearchEngine; }, + set(value) { this.$store.dispatch('settings/set', { key: 'webSearchEngine', value }); } + }, }, mounted() { diff --git a/src/client/app/store.ts b/src/client/app/store.ts index a498b0138..159ed994c 100644 --- a/src/client/app/store.ts +++ b/src/client/app/store.ts @@ -35,6 +35,7 @@ const defaultSettings = { iLikeSushi: false, rememberNoteVisibility: false, defaultNoteVisibility: 'public', + webSearchEngine: 'https://www.google.com/?#q={{query}}', mutedWords: [], games: { reversi: {