mirror of https://github.com/perkeep/perkeep.git
website: serve godocs for /app/ packages
Change-Id: If2836840aa5523e74a734051111e0ed614ea200e
This commit is contained in:
parent
7df8dbb2db
commit
fc619464df
|
@ -723,6 +723,7 @@ func main() {
|
|||
mux.Handle("/talks/", http.StripPrefix("/talks/", http.FileServer(http.Dir(filepath.Join(*root, "talks")))))
|
||||
mux.Handle(pkgPattern, godocHandler{})
|
||||
mux.Handle(cmdPattern, godocHandler{})
|
||||
mux.Handle(appPattern, godocHandler{})
|
||||
mux.HandleFunc(errPattern, errHandler)
|
||||
|
||||
mux.HandleFunc("/r/", gerritRedirect)
|
||||
|
|
|
@ -45,10 +45,11 @@ const (
|
|||
domainName = "camlistore.org"
|
||||
pkgPattern = "/pkg/"
|
||||
cmdPattern = "/cmd/"
|
||||
appPattern = "/app/"
|
||||
fileembedPattern = "fileembed.go"
|
||||
)
|
||||
|
||||
var docRx = regexp.MustCompile(`^/((?:pkg|cmd)/([\w/]+?)(\.go)??)/?$`)
|
||||
var docRx = regexp.MustCompile(`^/((?:pkg|cmd|app)/([\w/]+?)(\.go)??)/?$`)
|
||||
|
||||
var tabwidth = 4
|
||||
|
||||
|
@ -232,7 +233,8 @@ func (pi *PageInfo) populateDirs(diskPath string, depth int) {
|
|||
|
||||
func getPageInfo(pkgName, diskPath string) (pi PageInfo, err error) {
|
||||
if pkgName == pathpkg.Join(domainName, pkgPattern) ||
|
||||
pkgName == pathpkg.Join(domainName, cmdPattern) {
|
||||
pkgName == pathpkg.Join(domainName, cmdPattern) ||
|
||||
pkgName == pathpkg.Join(domainName, appPattern) {
|
||||
pi.Dirname = diskPath
|
||||
pi.populateDirs(diskPath, -1)
|
||||
return
|
||||
|
@ -397,7 +399,7 @@ func (godocHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
m := docRx.FindStringSubmatch(r.URL.Path)
|
||||
suffix := ""
|
||||
if m == nil {
|
||||
if r.URL.Path != pkgPattern && r.URL.Path != cmdPattern {
|
||||
if r.URL.Path != pkgPattern && r.URL.Path != cmdPattern && r.URL.Path != appPattern {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue