From e2e0e9d956106e54f5947350aae33065d8fd4660 Mon Sep 17 00:00:00 2001 From: Leah Date: Sun, 19 Jan 2025 23:21:47 +0100 Subject: [PATCH] add custom search engines to google mfm --- locales/en-US.yml | 4 +++ locales/index.d.ts | 18 ++++++++++++- locales/index.js | 2 +- locales/ja-JP.yml | 4 +++ packages/frontend/src/components/MkGoogle.vue | 7 ++--- .../frontend/src/pages/settings/general.vue | 26 +++++++++++++++++++ .../frontend/src/scripts/search-engine-map.ts | 17 ++++++++++++ packages/frontend/src/store.ts | 5 ++++ 8 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 packages/frontend/src/scripts/search-engine-map.ts diff --git a/locales/en-US.yml b/locales/en-US.yml index 3cf165e3e..269886b1d 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -762,6 +762,10 @@ noCrawleDescription: "Ask search engines to not index your profile page, notes, lockedAccountInfo: "Unless you set your note visiblity to \"Followers only\", your notes will be visible to anyone, even if you require followers to be manually approved." alwaysMarkSensitive: "Mark as sensitive by default" loadRawImages: "Load original images instead of showing thumbnails" +searchEngine: "Search Engine For Search MFM" +searchEngineOther: "Other" +searchEngineCustomURIDescription: "The custom URI must be input in the format like \"https://www.google.com/search?q=\\{query}\" or \"https://www.google.com/search?q=%s\"." +searchEngineCusomURI: "Custom URI" disableShowingAnimatedImages: "Don't play animated images" highlightSensitiveMedia: "Highlight sensitive media" verificationEmailSent: "A verification email has been sent. Please follow the included link to complete verification." diff --git a/locales/index.d.ts b/locales/index.d.ts index da14073e8..e7864562e 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -3064,6 +3064,22 @@ export interface Locale extends ILocale { * 添付画像のサムネイルをオリジナル画質にする */ "loadRawImages": string; + /** + * 検索MFMの検索エンジン + */ + "searchEngine": string; + /** + * 他 + */ + "searchEngineOther": string; + /** + * カスタム URI は、"https://www.google.com/search?q=\{query}" や "https://www.google.com/search?q=%s" のような形式で入力する必要があります。 + */ + "searchEngineCustomURIDescription": ParameterizedString<"query">; + /** + * カスタム URI + */ + "searchEngineCusomURI": string; /** * アニメーション画像を再生しない */ @@ -6843,7 +6859,7 @@ export interface Locale extends ILocale { }; "_tutorialCompleted": { /** - * Misskey初心者講座 修了証 + * Forkey初心者講座 修了証 */ "title": string; /** diff --git a/locales/index.js b/locales/index.js index 0770fd82a..6ec1f61b8 100644 --- a/locales/index.js +++ b/locales/index.js @@ -49,7 +49,7 @@ const primaries = { }; // 何故か文字列にバックスペース文字が混入することがあり、YAMLが壊れるので取り除く -const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), ''); +const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), '').replaceAll(new RegExp(/\\+\{/,'g'), '{'); export function build() { const metaUrl = import.meta.url; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 0e4770453..f34fb5497 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -762,6 +762,10 @@ noCrawleDescription: "外部の検索エンジンにあなたのユーザーペ lockedAccountInfo: "フォローを承認制にしても、ノートの公開範囲を「フォロワー」にしない限り、誰でもあなたのノートを見ることができます。" alwaysMarkSensitive: "デフォルトでメディアをセンシティブ設定にする" loadRawImages: "添付画像のサムネイルをオリジナル画質にする" +searchEngine: "検索MFMの検索エンジン" +searchEngineOther: "他" +searchEngineCustomURIDescription: "カスタム URI は、\"https://www.google.com/search?q=\\{query}\" や \"https://www.google.com/search?q=%s\" のような形式で入力する必要があります。" +searchEngineCusomURI: "カスタム URI" disableShowingAnimatedImages: "アニメーション画像を再生しない" highlightSensitiveMedia: "メディアがセンシティブであることを分かりやすく表示" verificationEmailSent: "確認のメールを送信しました。メールに記載されたリンクにアクセスして、設定を完了してください。" diff --git a/packages/frontend/src/components/MkGoogle.vue b/packages/frontend/src/components/MkGoogle.vue index 2244d36bb..8338cdf36 100644 --- a/packages/frontend/src/components/MkGoogle.vue +++ b/packages/frontend/src/components/MkGoogle.vue @@ -13,6 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 172e07001..7edf71c00 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -62,6 +62,27 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.showReactionsCount }} {{ i18n.ts.showGapBetweenNotesInTimeline }} {{ i18n.ts.loadRawImages }} + + + + + + + + + +
+ + + + +
@@ -241,6 +262,7 @@ import * as Misskey from 'misskey-js'; import MkSwitch from '@/components/MkSwitch.vue'; import MkSelect from '@/components/MkSelect.vue'; import MkRadios from '@/components/MkRadios.vue'; +import MkInput from '@/components/MkInput.vue'; import MkRange from '@/components/MkRange.vue'; import MkFolder from '@/components/MkFolder.vue'; import MkButton from '@/components/MkButton.vue'; @@ -249,6 +271,7 @@ import FormLink from '@/components/form/link.vue'; import MkLink from '@/components/MkLink.vue'; import MkInfo from '@/components/MkInfo.vue'; import { langs } from '@/config.js'; +import { searchEngineMap } from '@/scripts/search-engine-map.js'; import { defaultStore } from '@/store.js'; import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js'; @@ -313,6 +336,7 @@ const showAvatarDecorations = computed(defaultStore.makeGetterSetter('showAvatar const mediaListWithOneImageAppearance = computed(defaultStore.makeGetterSetter('mediaListWithOneImageAppearance')); const notificationPosition = computed(defaultStore.makeGetterSetter('notificationPosition')); const notificationStackAxis = computed(defaultStore.makeGetterSetter('notificationStackAxis')); +const searchEngine = computed(defaultStore.makeGetterSetter('searchEngine')); const keepScreenOn = computed(defaultStore.makeGetterSetter('keepScreenOn')); const disableStreamingTimeline = computed(defaultStore.makeGetterSetter('disableStreamingTimeline')); const useGroupedNotifications = computed(defaultStore.makeGetterSetter('useGroupedNotifications')); @@ -485,4 +509,6 @@ definePageMetadata(() => ({ title: i18n.ts.general, icon: 'ti ti-adjustments', })); + +const useCustomSearchEngine = computed(() => !Object.keys(searchEngineMap).includes(searchEngine.value)); diff --git a/packages/frontend/src/scripts/search-engine-map.ts b/packages/frontend/src/scripts/search-engine-map.ts new file mode 100644 index 000000000..8b74c7e8b --- /dev/null +++ b/packages/frontend/src/scripts/search-engine-map.ts @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: leah and other Sharkey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +//store the URL and if its none of these it's a custom one +export const searchEngineMap = { + //The first one is the default search engine + 'https://www.google.com/search?q={query}': 'Google', + 'https://duckduckgo.com/?q={query}': 'Duckduckgo', + 'https://www.bing.com/search?q={query}': 'Bing', + 'https://search.yahoo.com/search?p={query}': 'Yahoo', + 'https://www.ecosia.org/search?q={query}': 'Ecosia', + 'https://www.qwant.com/?q={query}': 'Qwant', + 'https://search.aol.com/aol/search?q={query}': 'AOL', + 'https://yandex.com/search?text={query}': 'Yandex', +}; diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index b44e1d9c4..36200c71e 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -6,6 +6,7 @@ import { markRaw, ref } from 'vue'; import * as Misskey from 'misskey-js'; import { miLocalStorage } from './local-storage.js'; +import { searchEngineMap } from './scripts/search-engine-map.js'; import type { SoundType } from '@/scripts/sound.js'; import { Storage } from '@/pizzax.js'; import { hemisphere } from '@/scripts/intl-const.js'; @@ -247,6 +248,10 @@ export const defaultStore = markRaw(new Storage('base', { where: 'device', default: false, }, + searchEngine: { + where: 'account', + default: Object.keys(searchEngineMap)[0], + }, warnMissingAltText: { where: 'device', default: true,