aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/frontend/server.go3
-rw-r--r--static/frontend/frontend.tmpl3
-rw-r--r--static/shared/opensearch.xml9
3 files changed, 15 insertions, 0 deletions
diff --git a/internal/frontend/server.go b/internal/frontend/server.go
index 07c235c8..b68d815f 100644
--- a/internal/frontend/server.go
+++ b/internal/frontend/server.go
@@ -215,6 +215,9 @@ func (s *Server) Install(handle func(string, http.Handler), cacher Cacher, authV
handle("/golang.org/x", s.staticPageHandler("subrepo", "Sub-repositories"))
handle("/files/", http.StripPrefix("/files", s.fileMux))
handle("/vuln/", vulnHandler)
+ handle("/opensearch.xml", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ serveFileFS(w, r, s.staticFS, "shared/opensearch.xml")
+ }))
handle("/", detailHandler)
if s.serveStats {
handle("/detail-stats/",
diff --git a/static/frontend/frontend.tmpl b/static/frontend/frontend.tmpl
index 4fab9347..e2a7600f 100644
--- a/static/frontend/frontend.tmpl
+++ b/static/frontend/frontend.tmpl
@@ -30,6 +30,9 @@
<link rel="shortcut icon" href="/static/shared/icon/favicon.ico">
{{block "canonical" .}}{{end}}
<link href="/static/frontend/frontend.min.css?version={{.AppVersionLabel}}" rel="stylesheet">
+ {{if not .LocalMode}}
+ <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Go Packages">
+ {{end}}
{{block "title" .}}
<title>{{if .HTMLTitle}}{{.HTMLTitle}} - {{end}}Go Packages</title>
{{end}}
diff --git a/static/shared/opensearch.xml b/static/shared/opensearch.xml
new file mode 100644
index 00000000..acb63248
--- /dev/null
+++ b/static/shared/opensearch.xml
@@ -0,0 +1,9 @@
+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
+ xmlns:moz="http://www.mozilla.org/2006/browser/search/">
+ <ShortName>Go Packages</ShortName>
+ <Description>Search Go Packages</Description>
+ <InputEncoding>UTF-8</InputEncoding>
+ <Image width="16" height="16" type="image/x-icon">https://pkg.go.dev/favicon.ico</Image>
+ <Url type="text/html" method="get" template="https://pkg.go.dev/search?q={searchTerms}&amp;ref=opensearch"/>
+ <moz:SearchForm>https://pkg.go.dev/</moz:SearchForm>
+</OpenSearchDescription>