diff --git a/overlay/misskey/browser-search-support.patch b/overlay/misskey/browser-search-support.patch new file mode 100644 index 0000000..2d8b457 --- /dev/null +++ b/overlay/misskey/browser-search-support.patch @@ -0,0 +1,88 @@ +diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts +index 727bbc9..2b3f0ce 100644 +--- a/packages/backend/src/server/web/index.ts ++++ b/packages/backend/src/server/web/index.ts +@@ -304,6 +304,24 @@ export class ClientServerService { + return await reply.sendFile('/robots.txt', staticAssets); + }); + ++ // OpenSearch XML ++ fastify.get('/opensearch.xml', async (request, reply) => { ++ const meta = await this.metaService.fetch(); ++ ++ const name = meta.name || "Misskey"; ++ let content = ""; ++ content += ``; ++ content += `${name} Search`; ++ content += `${name} Search`; ++ content += `UTF-8`; ++ content += `${this.config.url}/favicon.ico`; ++ content += ``; ++ content += ``; ++ ++ reply.header('Content-Type', 'application/opensearchdescription+xml'); ++ return await reply.send(content); ++ }); ++ + //#endregion + + const renderBase = async (reply: FastifyReply) => { +@@ -313,6 +331,7 @@ export class ClientServerService { + img: meta.bannerUrl, + title: meta.name ?? 'Misskey', + instanceName: meta.name ?? 'Misskey', ++ url: this.config.url, + desc: meta.description, + icon: meta.iconUrl, + themeColor: meta.themeColor, +diff --git a/packages/backend/src/server/web/views/base.pug b/packages/backend/src/server/web/views/base.pug +index 0c3c5c9..b472cff 100644 +--- a/packages/backend/src/server/web/views/base.pug ++++ b/packages/backend/src/server/web/views/base.pug +@@ -31,6 +31,7 @@ html + link(rel='icon' href= icon || '/favicon.ico') + link(rel='apple-touch-icon' href= icon || '/apple-touch-icon.png') + link(rel='manifest' href='/manifest.json') ++ link(rel='search' type='application/opensearchdescription+xml' title=((title || "Misskey") + " Search") href=`${url}/opensearch.xml`) + link(rel='prefetch' href='https://xn--931a.moe/assets/info.jpg') + link(rel='prefetch' href='https://xn--931a.moe/assets/not-found.jpg') + link(rel='prefetch' href='https://xn--931a.moe/assets/error.jpg') +diff --git a/packages/client/src/pages/search.vue b/packages/client/src/pages/search.vue +index c080b76..f9aac2d 100644 +--- a/packages/client/src/pages/search.vue ++++ b/packages/client/src/pages/search.vue +@@ -12,12 +12,34 @@ import { computed } from 'vue'; + import XNotes from '@/components/MkNotes.vue'; + import { i18n } from '@/i18n'; + import { definePageMetadata } from '@/scripts/page-metadata'; ++import * as os from '@/os'; ++import { mainRouter } from '@/router'; + + const props = defineProps<{ + query: string; + channel?: string; + }>(); + ++const query = props.query; ++ ++if (localStorage.getItem('account') != null) { ++ if (query.startsWith('https://') || (query.startsWith('@') && !query.includes(' '))) { ++ const promise = os.api('ap/show', { ++ uri: props.query, ++ }); ++ ++ os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject); ++ ++ const res = await promise; ++ ++ if (res.type === 'User') { ++ mainRouter.replace(`/@${res.object.username}@${res.object.host}`); ++ } else if (res.type === 'Note') { ++ mainRouter.replace(`/notes/${res.object.id}`); ++ } ++ } ++} ++ + const pagination = { + endpoint: 'notes/search' as const, + limit: 10, diff --git a/overlay/misskey/default.nix b/overlay/misskey/default.nix index bb6c973..87a5911 100644 --- a/overlay/misskey/default.nix +++ b/overlay/misskey/default.nix @@ -21,7 +21,7 @@ in # some of my own personal patches patches = [ # Nya! - ./search-allow-query-posts-and-users.patch + ./browser-search-support.patch ./copy-link-non-monospace.patch ./reorder-note-menu.patch ]; diff --git a/overlay/misskey/search-allow-query-posts-and-users.patch b/overlay/misskey/search-allow-query-posts-and-users.patch deleted file mode 100644 index 2448622..0000000 --- a/overlay/misskey/search-allow-query-posts-and-users.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/packages/client/src/pages/search.vue b/packages/client/src/pages/search.vue -index c080b76..cdfb47c 100644 ---- a/packages/client/src/pages/search.vue -+++ b/packages/client/src/pages/search.vue -@@ -12,12 +12,35 @@ import { computed } from 'vue'; - import XNotes from '@/components/MkNotes.vue'; - import { i18n } from '@/i18n'; - import { definePageMetadata } from '@/scripts/page-metadata'; -+import * as os from '@/os'; -+import { mainRouter } from '@/router'; - - const props = defineProps<{ - query: string; - channel?: string; - }>(); - -+const query = props.query; -+ -+# TODO: get this to work without being logged in -+if (localStorage.getItem('account') != null) { -+ if (query.startsWith('https://') || (query.startsWith('@') && !query.includes(' '))) { -+ const promise = os.api('ap/show', { -+ uri: props.query, -+ }); -+ -+ os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject); -+ -+ const res = await promise; -+ -+ if (res.type === 'User') { -+ mainRouter.replace(`/@${res.object.username}@${res.object.host}`); -+ } else if (res.type === 'Note') { -+ mainRouter.replace(`/notes/${res.object.id}`); -+ } -+ } -+} -+ - const pagination = { - endpoint: 'notes/search' as const, - limit: 10,