go/godoc-path-locations.patch

85 lines
2.4 KiB
Diff

*** a/src/cmd/godoc/godoc.go 2011-03-08 18:46:40.906386884 +0100
--- b/src/cmd/godoc/godoc.go 2011-03-08 19:10:03.880387209 +0100
***************
*** 78,89 ****
pkgHandler httpHandler
)
func initHandlers() {
fsMap.Init(*pkgPath)
! fileServer = http.FileServer(*goroot, "")
! cmdHandler = httpHandler{"/cmd/", filepath.Join(*goroot, "src", "cmd"), false}
! pkgHandler = httpHandler{"/pkg/", filepath.Join(*goroot, "src", "pkg"), true}
}
--- 78,92 ----
pkgHandler httpHandler
)
+ // for openSUSE packaging of godoc
+ const docroot = "/usr/share/doc/packages/go-doc/"
+ const srcroot = "/usr/share/go/"
func initHandlers() {
fsMap.Init(*pkgPath)
! fileServer = http.FileServer(docroot, "")
! cmdHandler = httpHandler{"/cmd/", filepath.Join(srcroot, "src/cmd"), false}
! pkgHandler = httpHandler{"/pkg/", filepath.Join(srcroot, "src/pkg"), true}
}
***************
*** 634,640 ****
func readTemplate(name string) *template.Template {
! path := filepath.Join(*goroot, "lib", "godoc", name)
data, err := ioutil.ReadFile(path)
if err != nil {
log.Fatalf("ReadFile %s: %v", path, err)
--- 637,643 ----
func readTemplate(name string) *template.Template {
! path := filepath.Join(*goroot, "lib/"+name)
data, err := ioutil.ReadFile(path)
if err != nil {
log.Fatalf("ReadFile %s: %v", path, err)
***************
*** 819,831 ****
func serveFile(w http.ResponseWriter, r *http.Request) {
relpath := r.URL.Path[1:] // serveFile URL paths start with '/'
! abspath := absolutePath(relpath, *goroot)
// pick off special cases and hand the rest to the standard file server
switch r.URL.Path {
case "/":
! serveHTMLDoc(w, r, filepath.Join(*goroot, "doc", "root.html"), "doc/root.html")
return
case "/doc/root.html":
--- 822,840 ----
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, docroot)
// pick off special cases and hand the rest to the standard file server
switch r.URL.Path {
case "/":
! serveHTMLDoc(w, r, filepath.Join(docroot, "root.html"), "root.html")
return
case "/doc/root.html":