website: serve godocs for /app/ packages

Change-Id: If2836840aa5523e74a734051111e0ed614ea200e
This commit is contained in:
Will Norris 2016-04-25 22:40:17 -07:00
parent 7df8dbb2db
commit fc619464df
2 changed files with 6 additions and 3 deletions

View File

@ -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)

View File

@ -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
}