From c87ed513112bd25496f96c1df366a1141a6da868 Mon Sep 17 00:00:00 2001
From: KevinWh0 <45321184+ChaoticLeah@users.noreply.github.com>
Date: Wed, 12 Jun 2024 13:35:37 +0200
Subject: [PATCH 1/4] made it so you can pick a search engine
---
locales/en-US.yml | 4 +++
locales/index.d.ts | 16 +++++++++++
locales/ja-JP.yml | 4 +++
packages/frontend/src/components/MkGoogle.vue | 8 ++++--
.../frontend/src/pages/settings/general.vue | 28 ++++++++++++++++++-
.../frontend/src/scripts/search-engine-map.ts | 12 ++++++++
packages/frontend/src/store.ts | 5 ++++
7 files changed, 73 insertions(+), 4 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 c442d41c1e..23884aa043 100644
--- a/locales/en-US.yml
+++ b/locales/en-US.yml
@@ -752,6 +752,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 6efd5b33b9..fe36e2dfd0 100644
--- a/locales/index.d.ts
+++ b/locales/index.d.ts
@@ -3020,6 +3020,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;
/**
* アニメーション画像を再生しない
*/
diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml
index 68e4091a88..293f8ec380 100644
--- a/locales/ja-JP.yml
+++ b/locales/ja-JP.yml
@@ -751,6 +751,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 c92a49d32a..d1809d1073 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 1e4e815d5d..c589a29001 100644
--- a/packages/frontend/src/pages/settings/general.vue
+++ b/packages/frontend/src/pages/settings/general.vue
@@ -63,6 +63,27 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.ts.showGapBetweenNotesInTimeline }}
{{ i18n.ts.loadRawImages }}
Show instance ticker on replies
+
+ {{ i18n.ts.searchEngine }}
+
+
+
+
+
+
+
+
+ {{ i18n.ts.searchEngineCusomURI }}
+ {{ i18n.ts.searchEngineCustomURIDescription }}
+
+
+
{{ i18n.ts.reactionsDisplaySize }}
@@ -271,11 +292,12 @@ SPDX-License-Identifier: AGPL-3.0-only
diff --git a/packages/frontend/src/scripts/search-engine-map.ts b/packages/frontend/src/scripts/search-engine-map.ts
index 925d16aafe..3e0594f0c5 100644
--- a/packages/frontend/src/scripts/search-engine-map.ts
+++ b/packages/frontend/src/scripts/search-engine-map.ts
@@ -1,12 +1,12 @@
//store the URL and if its none of these its 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://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 ffd63f71fc..f753b2c3e8 100644
--- a/packages/frontend/src/store.ts
+++ b/packages/frontend/src/store.ts
@@ -306,7 +306,7 @@ export const defaultStore = markRaw(new Storage('base', {
default: false,
},
searchEngine: {
- where: 'device',
+ where: 'account',
default: Object.keys(searchEngineMap)[0],
},
noteDesign: {
From d53df1c5d292f44cfe4d90830f12998ab726a582 Mon Sep 17 00:00:00 2001
From: KevinWh0 <45321184+ChaoticLeah@users.noreply.github.com>
Date: Wed, 12 Jun 2024 15:00:12 +0200
Subject: [PATCH 3/4] undid weird / in search engine map
---
packages/frontend/src/scripts/search-engine-map.ts | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/packages/frontend/src/scripts/search-engine-map.ts b/packages/frontend/src/scripts/search-engine-map.ts
index 3e0594f0c5..3fb06d135d 100644
--- a/packages/frontend/src/scripts/search-engine-map.ts
+++ b/packages/frontend/src/scripts/search-engine-map.ts
@@ -1,12 +1,12 @@
//store the URL and if its none of these its a custom one
export const searchEngineMap = {
//The first one is the default search engine
- 'https://www.google.com/search/?q={query}': 'Google',
+ '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.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',
+ 'https://search.aol.com/aol/search?q={query}': 'AOL',
+ 'https://yandex.com/search?text={query}': 'Yandex',
};
From f7898fa89daa0eed601dd1acac7569ca5ba93fb1 Mon Sep 17 00:00:00 2001
From: dakkar
Date: Wed, 12 Jun 2024 15:06:01 +0100
Subject: [PATCH 4/4] teach the locale system that sometimes braces are just
braces
---
locales/en-US.yml | 2 +-
locales/generateDTS.js | 5 ++++-
locales/index.d.ts | 4 ++--
locales/index.js | 6 +++++-
locales/ja-JP.yml | 2 +-
5 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/locales/en-US.yml b/locales/en-US.yml
index 23884aa043..b469b312a5 100644
--- a/locales/en-US.yml
+++ b/locales/en-US.yml
@@ -754,7 +754,7 @@ 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\"."
+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"
diff --git a/locales/generateDTS.js b/locales/generateDTS.js
index 49807144ec..a175247445 100644
--- a/locales/generateDTS.js
+++ b/locales/generateDTS.js
@@ -6,7 +6,10 @@ import ts from 'typescript';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
-const parameterRegExp = /\{(\w+)\}/g;
+// braces preceded by backslashes are literal, they don't represent
+// parameters; they get cleaned up by `locales/index.js` before
+// getting shipped to the browser
+const parameterRegExp = /(?;
+ "searchEngineCustomURIDescription": string;
/**
* カスタム URI
*/
diff --git a/locales/index.js b/locales/index.js
index 650e552337..c7a693fb77 100644
--- a/locales/index.js
+++ b/locales/index.js
@@ -49,7 +49,11 @@ const primaries = {
};
// 何故か文字列にバックスペース文字が混入することがあり、YAMLが壊れるので取り除く
-const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), '');
+//
+// also, we remove the backslashes in front of open braces (the
+// backslashes are only needed to tell `generateDTS.js` that the
+// braces do not represent parameters)
+const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), '').replaceAll(new RegExp(/\\+\{/,'g'), '{');
export function build() {
const locales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(new URL(`${c}.yml`, import.meta.url), 'utf-8'))) || {}, a), {});
diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml
index 293f8ec380..8c0ef3d55f 100644
--- a/locales/ja-JP.yml
+++ b/locales/ja-JP.yml
@@ -753,7 +753,7 @@ alwaysMarkSensitive: "デフォルトでメディアをセンシティブ設定
loadRawImages: "添付画像のサムネイルをオリジナル画質にする"
searchEngine: "検索MFMの検索エンジン"
searchEngineOther: "他"
-searchEngineCustomURIDescription: "カスタム URI は、\"https://www.google.com/search?q={query}\" や \"https://www.google.com/search?q=%s\" のような形式で入力する必要があります。"
+searchEngineCustomURIDescription: "カスタム URI は、\"https://www.google.com/search?q=\\{query}\" や \"https://www.google.com/search?q=%s\" のような形式で入力する必要があります。"
searchEngineCusomURI: "カスタム URI"
disableShowingAnimatedImages: "アニメーション画像を再生しない"
highlightSensitiveMedia: "メディアがセンシティブであることを分かりやすく表示"