diff --git a/docs/honk.8 b/docs/honk.8 index 5d78e32..9f0f5c7 100644 --- a/docs/honk.8 +++ b/docs/honk.8 @@ -108,6 +108,8 @@ Site CSS may be overridden by creating a .Pa views/local.css file in the data directory. A restart is required after changes. +A site icon.png and favicon.ico will be served from the views directory +in the data directory, if present. .Pp Custom HTML messages may be added to select pages by using the .Ic admin diff --git a/web.go b/web.go index e98d426..71898a5 100644 --- a/web.go +++ b/web.go @@ -2137,15 +2137,18 @@ func avatate(w http.ResponseWriter, r *http.Request) { w.Write(a) } -func serveasset(w http.ResponseWriter, r *http.Request) { +func serveviewasset(w http.ResponseWriter, r *http.Request) { + serveasset(w, r, viewDir) +} +func servedataasset(w http.ResponseWriter, r *http.Request) { + serveasset(w, r, dataDir) +} + +func serveasset(w http.ResponseWriter, r *http.Request, basedir string) { if !develMode { w.Header().Set("Cache-Control", "max-age=7776000") } - dir := viewDir - if r.URL.Path == "/local.css" { - dir = dataDir - } - http.ServeFile(w, r, dir+"/views"+r.URL.Path) + http.ServeFile(w, r, basedir+"/views"+r.URL.Path) } func servehelp(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] @@ -2514,10 +2517,13 @@ func serve() { posters.HandleFunc("/server/inbox", serverinbox) posters.HandleFunc("/inbox", serverinbox) - getters.HandleFunc("/style.css", serveasset) - getters.HandleFunc("/local.css", serveasset) - getters.HandleFunc("/honkpage.js", serveasset) - getters.HandleFunc("/wonk.js", serveasset) + getters.HandleFunc("/style.css", serveviewasset) + getters.HandleFunc("/honkpage.js", serveviewasset) + getters.HandleFunc("/wonk.js", serveviewasset) + getters.HandleFunc("/local.css", servedataasset) + getters.HandleFunc("/icon.png", servedataasset) + getters.HandleFunc("/favicon.ico", servedataasset) + getters.HandleFunc("/about", servehtml) getters.HandleFunc("/login", servehtml) posters.HandleFunc("/dologin", login.LoginFunc)