about summary refs log tree commit diff stats
path: root/frontend
diff options
context:
space:
mode:
authorAlan Pearce2024-05-15 20:17:06 +0200
committerAlan Pearce2024-05-15 20:19:39 +0200
commit5521173ea0e05bda93096b51f67c5e813cb1d87e (patch)
tree79f066b3396b19f1b76a1e544a359b9b4088df82 /frontend
parent9437f522c2ed21950acde884cafc369ca45f4b7b (diff)
downloadsearchix-5521173ea0e05bda93096b51f67c5e813cb1d87e.tar.lz
searchix-5521173ea0e05bda93096b51f67c5e813cb1d87e.tar.zst
searchix-5521173ea0e05bda93096b51f67c5e813cb1d87e.zip
feat: add browser search engines via opensearch description
https://developer.mozilla.org/en-US/docs/Web/OpenSearch
Diffstat (limited to 'frontend')
-rw-r--r--frontend/templates/blocks/search.gotmpl2
-rw-r--r--frontend/templates/index.gotmpl10
-rw-r--r--frontend/templates/opensearch.xml.gotmpl16
3 files changed, 26 insertions, 2 deletions
diff --git a/frontend/templates/blocks/search.gotmpl b/frontend/templates/blocks/search.gotmpl
index 3ad05bf..6f47df3 100644
--- a/frontend/templates/blocks/search.gotmpl
+++ b/frontend/templates/blocks/search.gotmpl
@@ -11,6 +11,6 @@
   {{- end }}
 {{- end }}
 
-{{- define "js" }}
+{{- define "head" }}
   <script src="/static/search.js" defer></script>
 {{- end }}
diff --git a/frontend/templates/index.gotmpl b/frontend/templates/index.gotmpl
index 6db4cc2..90f875b 100644
--- a/frontend/templates/index.gotmpl
+++ b/frontend/templates/index.gotmpl
@@ -6,9 +6,17 @@
     <title>Searchix</title>
     <link href="/static/base.css" rel="stylesheet" />
     <link href="/static/style.css" rel="stylesheet" />
-    {{ block "js" . }}
+    {{ block "head" . }}
     {{ end }}
     {{ .ExtraHeadHTML }}
+    {{- range $key, $value := .Sources }}
+      <link
+        rel="search"
+        type="application/opensearchdescription+xml"
+        title="Searchix {{ $value.Name }}"
+        href="/options/{{ $key }}/opensearch.xml"
+      />
+    {{- end }}
   </head>
   <body>
     <header>
diff --git a/frontend/templates/opensearch.xml.gotmpl b/frontend/templates/opensearch.xml.gotmpl
new file mode 100644
index 0000000..8d978ea
--- /dev/null
+++ b/frontend/templates/opensearch.xml.gotmpl
@@ -0,0 +1,16 @@
+<OpenSearchDescription
+  xmlns="http://a9.com/-/spec/opensearch/1.1/"
+  xmlns:moz="http://www.mozilla.org/2006/browser/search/"
+>
+  <ShortName>Searchix {{ .Source.Name }}</ShortName>
+  <LongName>Search {{ .Source.Name }} options with Searchix</LongName>
+  <Description>Search options {{ .Source.Name }}</Description>
+  <Url
+    type="text/html"
+    method="get"
+    template="{{ .BaseURL }}/options/{{ .Source.Key }}/search?query={searchTerms}&amp;from=opensearch"
+  />
+  <moz:SearchForm
+    >{{ .BaseURL }}/options/{{ .Source.Key }}/search</moz:SearchForm
+  >
+</OpenSearchDescription>