mirror of
https://github.com/golang/go
synced 2024-09-05 16:04:50 +00:00
godoc: added an opensearch description document.
R=golang-dev, r, tux21b, rsc CC=golang-dev https://golang.org/cl/5479062
This commit is contained in:
parent
fbff033ecf
commit
ecf4a9216e
|
@ -12,6 +12,9 @@
|
||||||
<link rel="stylesheet" href="/doc/ie.css" type="text/css">
|
<link rel="stylesheet" href="/doc/ie.css" type="text/css">
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<script type="text/javascript" src="/doc/godocs.js"></script>
|
<script type="text/javascript" src="/doc/godocs.js"></script>
|
||||||
|
{{if .SearchBox}}
|
||||||
|
<link rel="search" type="application/opensearchdescription+xml" title="godoc" href="/opensearch.xml" />
|
||||||
|
{{end}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="container">
|
<div id="container">
|
||||||
|
|
11
lib/godoc/opensearch.xml
Normal file
11
lib/godoc/opensearch.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
|
||||||
|
<ShortName>godoc</ShortName>
|
||||||
|
<Description>The Go Programming Language</Description>
|
||||||
|
<Tags>go golang</Tags>
|
||||||
|
<Contact />
|
||||||
|
<Url type="text/html" template="{{.BaseURL}}/search?q={searchTerms}" />
|
||||||
|
<Image height="15" width="16" type="image/x-icon">/favicon.ico</Image>
|
||||||
|
<OutputEncoding>UTF-8</OutputEncoding>
|
||||||
|
<InputEncoding>UTF-8</InputEncoding>
|
||||||
|
</OpenSearchDescription>
|
|
@ -105,6 +105,7 @@ func registerPublicHandlers(mux *http.ServeMux) {
|
||||||
mux.HandleFunc("/doc/codewalk/", codewalk)
|
mux.HandleFunc("/doc/codewalk/", codewalk)
|
||||||
mux.HandleFunc("/search", search)
|
mux.HandleFunc("/search", search)
|
||||||
mux.Handle("/robots.txt", fileServer)
|
mux.Handle("/robots.txt", fileServer)
|
||||||
|
mux.HandleFunc("/opensearch.xml", serveSearchDesc)
|
||||||
mux.HandleFunc("/", serveFile)
|
mux.HandleFunc("/", serveFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,7 +601,8 @@ var (
|
||||||
packageHTML,
|
packageHTML,
|
||||||
packageText,
|
packageText,
|
||||||
searchHTML,
|
searchHTML,
|
||||||
searchText *template.Template
|
searchText,
|
||||||
|
searchDescXML *template.Template
|
||||||
)
|
)
|
||||||
|
|
||||||
func readTemplates() {
|
func readTemplates() {
|
||||||
|
@ -615,6 +617,7 @@ func readTemplates() {
|
||||||
packageText = readTemplate("package.txt")
|
packageText = readTemplate("package.txt")
|
||||||
searchHTML = readTemplate("search.html")
|
searchHTML = readTemplate("search.html")
|
||||||
searchText = readTemplate("search.txt")
|
searchText = readTemplate("search.txt")
|
||||||
|
searchDescXML = readTemplate("opensearch.xml")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -809,6 +812,16 @@ func serveFile(w http.ResponseWriter, r *http.Request) {
|
||||||
fileServer.ServeHTTP(w, r)
|
fileServer.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func serveSearchDesc(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Content-Type", "application/opensearchdescription+xml")
|
||||||
|
data := map[string]interface{}{
|
||||||
|
"BaseURL": fmt.Sprintf("http://%s", r.Host),
|
||||||
|
}
|
||||||
|
if err := searchDescXML.Execute(w, &data); err != nil {
|
||||||
|
log.Printf("searchDescXML.Execute: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Packages
|
// Packages
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue