all repos — honk @ d207a9a462b15864cbf37c1ff39d981dec3fbd09

my fork of honk

add routes for icon.png
Ted Unangst tedu@tedunangst.com
Wed, 02 Mar 2022 14:24:18 -0500
commit

d207a9a462b15864cbf37c1ff39d981dec3fbd09

parent

7fc65173054ff234db65c78f211c7369c567eeff

2 files changed, 18 insertions(+), 10 deletions(-)

jump to
M docs/honk.8docs/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
M web.goweb.go

@@ -2137,15 +2137,18 @@ }

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 @@ getters.HandleFunc("/server", serveractor)

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)