added initial favicon

This commit is contained in:
ston1th 2019-01-23 00:37:51 +01:00
commit 6a2dc8146c
7 changed files with 39 additions and 7 deletions

View file

@ -22,6 +22,7 @@ cat << EOF > ${templates_go}
package server
import (
"encoding/base64"
"errors"
"git.giftfish.de/ston1th/gowiki/pkg/log"
"html/template"
@ -43,11 +44,13 @@ for f in $(ls templates/*.css); do
echo " ${fname} = \`$(cat ${f})\`" >> ${templates_go}
done
echo " favicon = \"$(base64 -w 0 templates/favicon.ico)\"" >> ${templates_go}
cat << EOF >> ${templates_go}
)
func (s *HTTPServer) loadTemplates() {
var errf bool
var fatal bool
s.templ = make(map[string]*template.Template)
s.res = make(map[string][]byte)
parse := func(html ...string) (temp *template.Template) {
@ -57,7 +60,7 @@ func (s *HTTPServer) loadTemplates() {
temp, err = temp.Parse(s)
if err != nil {
log.Println("parse:", err)
errf = true
fatal = true
return
}
}
@ -67,6 +70,12 @@ func (s *HTTPServer) loadTemplates() {
// resources
s.res["bootstrap.css"] = []byte(bootstrapCSS)
s.res["custom.css"] = []byte(customCSS)
fav, err := base64.StdEncoding.DecodeString(favicon)
if err != nil {
log.Println("favicon:", err)
fatal = true
}
s.res["favicon.ico"] = fav
// pages
s.templ["notFoundHandler"] = parse(index, menu, notFound)
@ -92,7 +101,7 @@ func (s *HTTPServer) loadTemplates() {
// totp
s.templ["userTotpHandler"] = parse(index, menu, userTotp)
if errf {
if fatal {
log.Fatal("parse: ", errors.New("parsing templates failed"))
}
}