diff --git a/website/content/docs/index.html b/doc/README.md similarity index 100% rename from website/content/docs/index.html rename to doc/README.md diff --git a/website/content/docs/arch b/doc/arch.md similarity index 100% rename from website/content/docs/arch rename to doc/arch.md diff --git a/website/content/docs/client-config b/doc/client-config.md similarity index 100% rename from website/content/docs/client-config rename to doc/client-config.md diff --git a/website/content/docs/json-signing b/doc/json-signing/README.md similarity index 100% rename from website/content/docs/json-signing rename to doc/json-signing/README.md diff --git a/website/content/docs/overview b/doc/overview.md similarity index 100% rename from website/content/docs/overview rename to doc/overview.md diff --git a/website/content/docs/principles b/doc/principles.md similarity index 100% rename from website/content/docs/principles rename to doc/principles.md diff --git a/website/content/docs/prior-art b/doc/prior-art.md similarity index 100% rename from website/content/docs/prior-art rename to doc/prior-art.md diff --git a/website/content/docs/protocol b/doc/protocol/README.md similarity index 100% rename from website/content/docs/protocol rename to doc/protocol/README.md diff --git a/website/content/docs/release/0.1 b/doc/release/0.1 similarity index 100% rename from website/content/docs/release/0.1 rename to doc/release/0.1 diff --git a/website/content/docs/release/0.2 b/doc/release/0.2 similarity index 100% rename from website/content/docs/release/0.2 rename to doc/release/0.2 diff --git a/website/content/docs/release/0.3 b/doc/release/0.3 similarity index 100% rename from website/content/docs/release/0.3 rename to doc/release/0.3 diff --git a/website/content/docs/release/0.4 b/doc/release/0.4 similarity index 100% rename from website/content/docs/release/0.4 rename to doc/release/0.4 diff --git a/website/content/docs/release/0.5 b/doc/release/0.5 similarity index 100% rename from website/content/docs/release/0.5 rename to doc/release/0.5 diff --git a/website/content/docs/release/0.6 b/doc/release/0.6 similarity index 100% rename from website/content/docs/release/0.6 rename to doc/release/0.6 diff --git a/website/content/docs/release/0.7 b/doc/release/0.7 similarity index 100% rename from website/content/docs/release/0.7 rename to doc/release/0.7 diff --git a/website/content/docs/release/0.8 b/doc/release/0.8 similarity index 100% rename from website/content/docs/release/0.8 rename to doc/release/0.8 diff --git a/website/content/docs/release/0.9 b/doc/release/0.9 similarity index 100% rename from website/content/docs/release/0.9 rename to doc/release/0.9 diff --git a/website/content/docs/release/log.sh b/doc/release/log.sh similarity index 100% rename from website/content/docs/release/log.sh rename to doc/release/log.sh diff --git a/website/content/docs/schema/index.html b/doc/schema/index.html similarity index 100% rename from website/content/docs/schema/index.html rename to doc/schema/index.html diff --git a/website/content/docs/schema/permanode b/doc/schema/permanode.md similarity index 100% rename from website/content/docs/schema/permanode rename to doc/schema/permanode.md diff --git a/website/content/docs/server-config b/doc/server-config.md similarity index 100% rename from website/content/docs/server-config rename to doc/server-config.md diff --git a/website/content/docs/sharing b/doc/sharing.md similarity index 100% rename from website/content/docs/sharing rename to doc/sharing.md diff --git a/website/content/docs/status b/doc/status.md similarity index 100% rename from website/content/docs/status rename to doc/status.md diff --git a/website/content/docs/terms b/doc/terms.md similarity index 100% rename from website/content/docs/terms rename to doc/terms.md diff --git a/website/content/docs/todo b/doc/todo.md similarity index 100% rename from website/content/docs/todo rename to doc/todo.md diff --git a/website/content/docs/uses b/doc/uses.md similarity index 100% rename from website/content/docs/uses rename to doc/uses.md diff --git a/website/content/docs/web-ui-styleguide b/doc/web-ui-styleguide.md similarity index 100% rename from website/content/docs/web-ui-styleguide rename to doc/web-ui-styleguide.md diff --git a/website/camweb.go b/website/camweb.go index 513cb7245..3fe23886d 100644 --- a/website/camweb.go +++ b/website/camweb.go @@ -68,7 +68,7 @@ var h1TitlePattern = regexp.MustCompile(`

([^<]+)

`) var ( httpAddr = flag.String("http", defaultAddr, "HTTP address") httpsAddr = flag.String("https", "", "HTTPS address") - root = flag.String("root", "", "Website root (parent of 'static', 'content', and 'tmpl") + root = flag.String("root", "", "Website root (parent of 'static', 'content', and 'tmpl)") logDir = flag.String("logdir", "", "Directory to write log files to (one per hour), or empty to not log.") logStdout = flag.Bool("logstdout", true, "Whether to log to stdout") tlsCertFile = flag.String("tlscert", "", "TLS cert file") @@ -228,6 +228,10 @@ func redirectPath(u *url.URL) string { // Assume it's a commit return gerritURLPrefix + path } + + if strings.HasPrefix(u.Path, "/docs/") { + return "/doc/" + strings.TrimPrefix(u.Path, "/docs/") + } return "" } @@ -245,6 +249,10 @@ func mainHandler(rw http.ResponseWriter, req *http.Request) { findAndServeFile(rw, req, filepath.Join(*root, "content")) } +func docHandler(rw http.ResponseWriter, req *http.Request) { + findAndServeFile(rw, req, filepath.Join(filepath.Dir(*root), "doc")) +} + // modtime is the modification time of the resource to be served, or IsZero(). // return value is whether this request is now complete. func checkLastModified(w http.ResponseWriter, r *http.Request, modtime time.Time) bool { @@ -300,18 +308,22 @@ func findAndServeFile(rw http.ResponseWriter, req *http.Request, root string) { for _, index := range []string{"index.html", "README.md"} { absPath = filepath.Join(root, relPath, index) fi, err = os.Lstat(absPath) - if err == nil || !os.IsNotExist(err) { - break - } - if fi.IsDir() { - log.Printf("Error serving website content: %q is a directory", absPath) + if err != nil { + if os.IsNotExist(err) { + // didn't find this file, try the next + continue + } + log.Print(err) + serveError(rw, req, relPath, err) return } + break } } - if err != nil { - log.Print(err) - serveError(rw, req, relPath, err) + + if fi.IsDir() { + log.Printf("Error serving website content: %q is a directory", absPath) + serveError(rw, req, relPath, fmt.Errorf("error: %q is a directory", absPath)) return } @@ -707,6 +719,7 @@ func main() { mux.Handle("/lists", redirTo("/community")) mux.HandleFunc("/contributors", contribHandler()) + mux.Handle("/doc/", http.StripPrefix("/doc", http.HandlerFunc(docHandler))) mux.HandleFunc("/", mainHandler) if *buildbotHost != "" && *buildbotBackend != "" {