online help facility

This commit is contained in:
Ted Unangst 2019-10-07 01:25:41 -04:00
parent 6df0094a68
commit 3c2088bac9
3 changed files with 9 additions and 0 deletions

View File

@ -52,6 +52,8 @@ table.results { margin-top: 1em;
margin-left: 2em;
font-size: smaller; }
img { max-width: 100%; }
/* Header and footer lines. */
table.head { width: 100%;

View File

@ -40,6 +40,7 @@
<li><a href="/hfcs">hfcs</a>
<li><a href="/funzone">funzone</a>
<li><a href="/account">account</a>
<li><a href="/help/honk.1.html">help</a>
<li>
<form action="/q" method="GET">
<input type="text" name="q" autocomplete=off size=10 placeholder="search">

6
web.go
View File

@ -1449,6 +1449,11 @@ func serveasset(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "max-age=7776000")
http.ServeFile(w, r, "views"+r.URL.Path)
}
func servehelp(w http.ResponseWriter, r *http.Request) {
name := mux.Vars(r)["name"]
w.Header().Set("Cache-Control", "max-age=0")
http.ServeFile(w, r, "docs/" + name)
}
func servehtml(w http.ResponseWriter, r *http.Request) {
templinfo := getInfo(r)
err := readviews.Execute(w, r.URL.Path[1:]+".html", templinfo)
@ -1615,6 +1620,7 @@ func serve() {
getters.HandleFunc("/login", servehtml)
posters.HandleFunc("/dologin", login.LoginFunc)
getters.HandleFunc("/logout", login.LogoutFunc)
getters.HandleFunc("/help/{name:[[:alnum:]_.-]+}", servehelp)
loggedin := mux.NewRoute().Subrouter()
loggedin.Use(login.Required)