add routes for icon.png

This commit is contained in:
Ted Unangst 2022-03-02 14:24:18 -05:00
parent c947c99f8a
commit a21fb44491
2 changed files with 18 additions and 10 deletions

View File

@ -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

26
web.go
View File

@ -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)