allow overriding css with local.css. from qbit@bsd.network
This commit is contained in:
parent
dea10a4bd5
commit
75cd95d751
9
honk.go
9
honk.go
|
@ -116,7 +116,8 @@ func keymatch(keyname string, actor string) bool {
|
||||||
|
|
||||||
func getInfo(r *http.Request) map[string]interface{} {
|
func getInfo(r *http.Request) map[string]interface{} {
|
||||||
templinfo := make(map[string]interface{})
|
templinfo := make(map[string]interface{})
|
||||||
templinfo["StyleParam"] = getstyleparam()
|
templinfo["StyleParam"] = getstyleparam("views/style.css")
|
||||||
|
templinfo["LocalStyleParam"] = getstyleparam("views/local.css")
|
||||||
templinfo["ServerName"] = serverName
|
templinfo["ServerName"] = serverName
|
||||||
templinfo["IconName"] = iconName
|
templinfo["IconName"] = iconName
|
||||||
templinfo["UserInfo"] = GetUserInfo(r)
|
templinfo["UserInfo"] = GetUserInfo(r)
|
||||||
|
@ -1123,7 +1124,10 @@ func serve() {
|
||||||
"views/header.html",
|
"views/header.html",
|
||||||
)
|
)
|
||||||
if !debug {
|
if !debug {
|
||||||
savedstyleparam = getstyleparam()
|
s := "views/style.css"
|
||||||
|
savedstyleparams[s] = getstyleparam(s)
|
||||||
|
s = "views/local.css"
|
||||||
|
savedstyleparams[s] = getstyleparam(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
mux := mux.NewRouter()
|
mux := mux.NewRouter()
|
||||||
|
@ -1145,6 +1149,7 @@ func serve() {
|
||||||
getters.HandleFunc("/.well-known/webfinger", fingerlicker)
|
getters.HandleFunc("/.well-known/webfinger", fingerlicker)
|
||||||
|
|
||||||
getters.HandleFunc("/style.css", servecss)
|
getters.HandleFunc("/style.css", servecss)
|
||||||
|
getters.HandleFunc("/local.css", servecss)
|
||||||
getters.HandleFunc("/login", servehtml)
|
getters.HandleFunc("/login", servehtml)
|
||||||
posters.HandleFunc("/dologin", dologin)
|
posters.HandleFunc("/dologin", dologin)
|
||||||
getters.HandleFunc("/logout", dologout)
|
getters.HandleFunc("/logout", dologout)
|
||||||
|
|
14
util.go
14
util.go
|
@ -49,15 +49,19 @@ import (
|
||||||
_ "humungus.tedunangst.com/r/go-sqlite3"
|
_ "humungus.tedunangst.com/r/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var savedstyleparam string
|
var savedstyleparams = make(map[string]string)
|
||||||
|
|
||||||
func getstyleparam() string {
|
func getstyleparam(file string) string {
|
||||||
if savedstyleparam != "" {
|
if p, ok := savedstyleparams[file]; ok {
|
||||||
return savedstyleparam
|
return p
|
||||||
|
}
|
||||||
|
data, err := ioutil.ReadFile(file)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
data, _ := ioutil.ReadFile("views/style.css")
|
|
||||||
hasher := sha512.New()
|
hasher := sha512.New()
|
||||||
hasher.Write(data)
|
hasher.Write(data)
|
||||||
|
|
||||||
return fmt.Sprintf("?v=%.8x", hasher.Sum(nil))
|
return fmt.Sprintf("?v=%.8x", hasher.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
<head>
|
<head>
|
||||||
<title>honk</title>
|
<title>honk</title>
|
||||||
<link href="/style.css{{ .StyleParam }}" rel="stylesheet">
|
<link href="/style.css{{ .StyleParam }}" rel="stylesheet">
|
||||||
|
{{ if .LocalStyleParam }}
|
||||||
|
<link href="/local.css{{ .LocalStyleParam }}" rel="stylesheet">
|
||||||
|
{{ end }}
|
||||||
<link href="/icon.png" rel="icon">
|
<link href="/icon.png" rel="icon">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
Loading…
Reference in New Issue