6647a09a73
OBS-URL: https://build.opensuse.org/request/show/59945 OBS-URL: https://build.opensuse.org/package/show/devel:languages:go/go?expand=0&rev=35
51 lines
1.7 KiB
Diff
51 lines
1.7 KiB
Diff
diff -r 867d37fb41a4 src/cmd/godoc/godoc.go
|
|
--- a/src/cmd/godoc/godoc.go Wed Feb 02 12:09:31 2011 +1100
|
|
+++ b/src/cmd/godoc/godoc.go Thu Feb 03 17:00:14 2011 +0100
|
|
@@ -78,11 +78,13 @@
|
|
)
|
|
|
|
|
|
+const docroot = "/usr/share/doc/packages/go-doc/"
|
|
+
|
|
func initHandlers() {
|
|
fsMap.Init(*pkgPath)
|
|
- fileServer = http.FileServer(*goroot, "")
|
|
- cmdHandler = httpHandler{"/cmd/", pathutil.Join(*goroot, "src/cmd"), false}
|
|
- pkgHandler = httpHandler{"/pkg/", pathutil.Join(*goroot, "src/pkg"), true}
|
|
+ fileServer = http.FileServer(docroot, "")
|
|
+ cmdHandler = httpHandler{"/cmd/", pathutil.Join(docroot, "src/cmd"), false}
|
|
+ pkgHandler = httpHandler{"/pkg/", pathutil.Join(docroot, "src/pkg"), true}
|
|
}
|
|
|
|
|
|
@@ -622,7 +624,7 @@
|
|
|
|
|
|
func readTemplate(name string) *template.Template {
|
|
- path := pathutil.Join(*goroot, "lib/godoc/"+name)
|
|
+ path := pathutil.Join(*goroot, "lib/"+name)
|
|
data, err := ioutil.ReadFile(path)
|
|
if err != nil {
|
|
log.Fatalf("ReadFile %s: %v", path, err)
|
|
@@ -804,13 +806,18 @@
|
|
|
|
|
|
func serveFile(w http.ResponseWriter, r *http.Request) {
|
|
+ // openSUSE: serv docs from root of go-doc package install location
|
|
+ if strings.HasPrefix(r.URL.Path, "/doc/") {
|
|
+ http.Redirect(w, r, "/"+ r.URL.Path[len("/doc"):], http.StatusMovedPermanently)
|
|
+ return
|
|
+ }
|
|
relpath := r.URL.Path[1:] // serveFile URL paths start with '/'
|
|
- abspath := absolutePath(relpath, *goroot)
|
|
+ abspath := absolutePath(relpath, docroot)
|
|
|
|
// pick off special cases and hand the rest to the standard file server
|
|
switch r.URL.Path {
|
|
case "/":
|
|
- serveHTMLDoc(w, r, pathutil.Join(*goroot, "doc/root.html"), "doc/root.html")
|
|
+ serveHTMLDoc(w, r, pathutil.Join(docroot, "root.html"), "root.html")
|
|
return
|
|
|
|
case "/doc/root.html":
|