diff options
| author | Soni L <EnderMoneyMod@gmail.com> | 2022-12-28 19:53:59 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-29 07:53:59 +0900 |
| commit | 123e490311b76e41ccd6781adf1cde135f84de9a (patch) | |
| tree | 10143c21dd3417661c132e1f3832938daa3456e8 /packages/backend/src/server/web/ClientServerService.ts | |
| parent | 13.0.0-beta.5 (diff) | |
| download | sharkey-123e490311b76e41ccd6781adf1cde135f84de9a.tar.gz sharkey-123e490311b76e41ccd6781adf1cde135f84de9a.tar.bz2 sharkey-123e490311b76e41ccd6781adf1cde135f84de9a.zip | |
Support OpenSearch (closes #7058) (#9427)
Co-authored-by: Chaos <chaoticryptidz@owo.monster>
Diffstat (limited to 'packages/backend/src/server/web/ClientServerService.ts')
| -rw-r--r-- | packages/backend/src/server/web/ClientServerService.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts index 727bbc9d7b..2b3f0ce0f5 100644 --- a/packages/backend/src/server/web/ClientServerService.ts +++ b/packages/backend/src/server/web/ClientServerService.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 += `<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">`; + content += `<ShortName>${name} Search</ShortName>`; + content += `<Description>${name} Search</Description>`; + content += `<InputEncoding>UTF-8</InputEncoding>`; + content += `<Image width="16" height="16" type="image/x-icon">${this.config.url}/favicon.ico</Image>`; + content += `<Url type="text/html" template="${this.config.url}/search?q={searchTerms}"/>`; + content += `</OpenSearchDescription>`; + + 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, |