*: update docs for hackdoc

Change-Id: I256ec4499da2289f8f7ea3766ce40f2b0ffb0dc1
diff --git a/devtools/hackdoc/README.md b/devtools/hackdoc/README.md
index 45d4486..3226cf2 100644
--- a/devtools/hackdoc/README.md
+++ b/devtools/hackdoc/README.md
@@ -18,6 +18,6 @@
 
 To run hackdoc locally on a filesystem checkout (ie. when working on docs, templates, or hackdoc itself), run:
 
-     bazel run //devtools/hackdoc:local
+     bazel run //devtools/hackdoc  -- -hspki_disable -docroot /path/to/hscloud
 
 The output log should tell you where hackdoc just started listening at. Currently this is `127.0.0.1:8080` by default. You can change this by passing a `-listen` flag, eg. `-listen 127.0.0.1:4242`.
diff --git a/devtools/hackdoc/main.go b/devtools/hackdoc/main.go
index 558268b..413a129 100644
--- a/devtools/hackdoc/main.go
+++ b/devtools/hackdoc/main.go
@@ -111,7 +111,6 @@
 		return
 	}
 
-	glog.Infof("%+v", r.URL.Query())
 	ref := r.URL.Query().Get("ref")
 	if ref == "" {
 		ref = flagGitwebDefaultBranch
@@ -206,7 +205,8 @@
 		}
 
 		if file {
-			r.handleMarkdown(fpath, cfg)
+			http.Redirect(r.w, r.r, "/"+fpath, 302)
+			//r.handleMarkdown(fpath, cfg)
 			return
 		}
 	}
@@ -238,6 +238,11 @@
 	if file {
 		parts := strings.Split(r.rpath, "/")
 		dirpath := strings.Join(parts[:(len(parts)-1)], "/")
+		// TODO(q3k): figure out this hack, hopefully by implementing a real path type
+		if dirpath == "/" {
+			dirpath = "//"
+		}
+
 		cfg, err := config.ForPath(r.ctx, r.source, dirpath)
 		if err != nil {
 			glog.Errorf("could not get config for path %q: %w", dirpath, err)
diff --git a/devtools/hackdoc/markdown.go b/devtools/hackdoc/markdown.go
index 911c2c0..d20f9e3 100644
--- a/devtools/hackdoc/markdown.go
+++ b/devtools/hackdoc/markdown.go
@@ -31,6 +31,7 @@
 				q["ref"] = []string{ref}
 				u.RawQuery = q.Encode()
 				node.Destination = []byte(u.String())
+				glog.Infof("link fix %q -> %q", dest, u.String())
 			}
 		}
 		return r.RenderNode(&buf, node, entering)
@@ -38,6 +39,11 @@
 	return buf.Bytes()
 }
 
+type pathPart struct {
+	Label string
+	Path  string
+}
+
 func (r *request) handleMarkdown(path string, cfg *config.Config) {
 	data, err := r.source.ReadFile(r.ctx, path)
 	if err != nil {
@@ -60,11 +66,26 @@
 	}
 
 	pathInDepot := strings.TrimPrefix(path, "//")
+	pathParts := []pathPart{
+		{Label: "//", Path: "/"},
+	}
+	parts := strings.Split(pathInDepot, "/")
+	fullPath := ""
+	for i, p := range parts {
+		label := p
+		if i != len(parts)-1 {
+			label = label + "/"
+		}
+		fullPath += "/" + p
+		pathParts = append(pathParts, pathPart{Label: label, Path: fullPath})
+	}
+
 	vars := map[string]interface{}{
 		"Rendered":    template.HTML(rendered),
 		"Title":       path,
 		"Path":        path,
 		"PathInDepot": pathInDepot,
+		"PathParts":   pathParts,
 		"HackdocURL":  flagHackdocURL,
 		"WebLinks":    r.source.WebLinks(pathInDepot),
 	}
diff --git a/devtools/hackdoc/tpl/default.html b/devtools/hackdoc/tpl/default.html
index 7120962..a6c1d42 100644
--- a/devtools/hackdoc/tpl/default.html
+++ b/devtools/hackdoc/tpl/default.html
@@ -58,7 +58,7 @@
 }
 
 .column {
-    max-width: 80em;
+    width: 80em;
     padding: 1rem 0 1rem 0;
 }
 
@@ -85,8 +85,16 @@
     color: #b30014;
 }
 
-.header span.muted {
+.header span.part {
     color: #666;
+    padding-left: 0.2em;
+}
+
+.header span.part a {
+    color: rgb(27, 106, 203);
+}
+.header span.part a:visited {
+    color: rgb(27, 106, 203);
 }
 
 .footer {
@@ -98,6 +106,14 @@
     text-align: right;
 }
 
+.footer .left {
+    float: left;
+}
+
+.footer .right {
+    float: right;
+}
+
 .footer a {
     color: #bbb;
 }
@@ -164,15 +180,20 @@
     <div class="column">
         <div class="page">
             <div class="header">
-                <span class="red">hackdoc:</span><span>{{ .Path }}</span>
-                {{ range .WebLinks }}
-                <span class="muted">[{{ .Kind }} <a href="{{ .LinkURL }}">{{ .LinkLabel }}</a>]</span>
-                {{ end }}
+                <span class="red">hackdoc:</span>
+                {{ range .PathParts }}<span class="part"><a href="{{ .Path }}">{{ .Label }}</a></span>{{ end }}
+                <span class="red" style="margin-left: 1em;">shortcuts:</span> <a href="/">root</a>, <a href="/cluster/doc">cluster docs</a>, <a href="/doc/codelabs">codelabs</a>
             </div>
             {{ .Rendered }}
         </div>
         <div class="footer">
-            Generated by <a href="{{ .HackdocURL }}/devtools/hackdoc">hackdoc</a>.
+            <div class="left">
+                View in:
+                {{ range .WebLinks }}
+                <span class="muted">[{{ .Kind }} <a href="{{ .LinkURL }}">{{ .LinkLabel }}</a>]</span>
+                {{ end }}
+            </div>
+            <div class="right">Generated by <a href="{{ .HackdocURL }}/devtools/hackdoc">hackdoc</a>.</div>
         </div>
     </div>
 </div>