Skip to content

Commit 7259a0c

Browse files
committed
Add opensearch support to server
1 parent 25e8a41 commit 7259a0c

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ s is released under the MIT license.
388388
[ReportCard-Image]: https://goreportcard.com/badge/github.com/zquestz/s
389389
[Build-Status-URL]: https://app.travis-ci.com/github/zquestz/s
390390
[Build-Status-Image]: https://app.travis-ci.com/zquestz/s.svg?branch=master
391-
[Release-URL]: https://github.com/zquestz/s/releases/tag/v0.7.2
392-
[Release-Image]: https://img.shields.io/badge/release-v0.7.2-1eb0fc.svg
391+
[Release-URL]: https://github.com/zquestz/s/releases/tag/v0.7.3
392+
[Release-Image]: https://img.shields.io/badge/release-v0.7.3-1eb0fc.svg
393393
[Snap-Build-URL]: https://github.com/zquestz/s/actions/workflows/test-snap-builds.yml
394394
[Snap-Build-Image]: https://github.com/zquestz/s/actions/workflows/test-snap-builds.yml/badge.svg
395395
[Snap-Image]: https://snapcraft.io/s-search/badge.svg

cmd/search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
const (
1717
appName = "s"
18-
version = "0.7.2"
18+
version = "0.7.3"
1919
defaultPort = 8080
2020
defaultProvider = "presearch"
2121
)

server/favicon.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func setupFaviconHandlers() {
3737
http.Handle("/browserconfig.xml", gziphandler.GzipHandler(http.HandlerFunc(browserconfigXML)))
3838
http.Handle("/manifest.json", gziphandler.GzipHandler(http.HandlerFunc(manifestJSON)))
3939
http.Handle("/safari-pinned-tab.svg", gziphandler.GzipHandler(http.HandlerFunc(safariPinnedTabSvg)))
40+
http.Handle("/opensearch.xml", gziphandler.GzipHandler(http.HandlerFunc(opensearchXML)))
4041
}
4142

4243
func setExpiresHeader(w http.ResponseWriter) {
@@ -1716,6 +1717,21 @@ func browserconfigXML(w http.ResponseWriter, r *http.Request) {
17161717
`))
17171718
}
17181719

1720+
func opensearchXML(w http.ResponseWriter, r *http.Request) {
1721+
w.Header().Set("Content-Type", "application/opensearchdescription+xml")
1722+
setExpiresHeader(w)
1723+
1724+
w.Write([]byte(`<?xml version="1.0" encoding="utf-8"?>
1725+
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
1726+
<ShortName>s</ShortName>
1727+
<Description>Multi-provider web search portal supporting 50+ search engines including Google, GitHub, and Stack Overflow</Description>
1728+
<InputEncoding>UTF-8</InputEncoding>
1729+
<Image width="32" height="32" type="image/png">/favicon-32x32.png</Image>
1730+
<Url type="text/html" method="get" template="/search?q={searchTerms}"/>
1731+
</OpenSearchDescription>
1732+
`))
1733+
}
1734+
17191735
func manifestJSON(w http.ResponseWriter, r *http.Request) {
17201736
w.Header().Set("Content-Type", "application/json")
17211737
setExpiresHeader(w)

server/template.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var (
2828
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
2929
<link rel="manifest" href="/manifest.json">
3030
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#272f32">
31+
<link rel="search" type="application/opensearchdescription+xml" title="s" href="/opensearch.xml">
3132
<meta name="apple-mobile-web-app-title" content="s">
3233
<meta name="application-name" content="s">
3334
<meta name="msapplication-TileColor" content="#272f32">

0 commit comments

Comments
 (0)