added initial favicon
This commit is contained in:
parent
799ff0fb2f
commit
6a2dc8146c
7 changed files with 39 additions and 7 deletions
|
|
@ -73,6 +73,9 @@ func staticHandler(ctx *Context) {
|
|||
err = ctx.Write(ctx.Srv.res["bootstrap.css"])
|
||||
case "/custom.css":
|
||||
err = ctx.Write(ctx.Srv.res["custom.css"])
|
||||
case "/favicon.ico":
|
||||
ctx.SetHeader("Content-Type", "image/x-icon")
|
||||
err = ctx.Write(ctx.Srv.res["favicon.ico"])
|
||||
}
|
||||
if err != nil {
|
||||
log.Println("static:", err)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@ var routes = []route{
|
|||
indexHandler,
|
||||
[]string{"GET"},
|
||||
},
|
||||
{
|
||||
"/favicon.ico",
|
||||
staticHandler,
|
||||
[]string{"GET"},
|
||||
},
|
||||
{
|
||||
"/bootstrap.css",
|
||||
staticHandler,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
7
sri.sh
7
sri.sh
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
HASH="sha256"
|
||||
DIR="templates"
|
||||
FILES="*.css *.js *.ico"
|
||||
FILES="*.css *.js"
|
||||
BINS="*.ico"
|
||||
echo "SRI (subresource integrity) hashes"
|
||||
cd ${DIR}
|
||||
for f in $(ls ${FILES} 2>/dev/null); do
|
||||
|
|
@ -12,3 +13,7 @@ for f in $(ls ${FILES} 2>/dev/null); do
|
|||
printf "%13s: " ${f}
|
||||
echo "${HASH}-$(cat ${f}|openssl dgst -${HASH} -binary|openssl enc -base64 -A)"
|
||||
done
|
||||
for f in $(ls ${BINS} 2>/dev/null); do
|
||||
printf "%13s: " ${f}
|
||||
echo "${HASH}-$(cat ${f}|openssl dgst -${HASH} -binary|openssl enc -base64 -A)"
|
||||
done
|
||||
|
|
|
|||
15
templates.sh
15
templates.sh
|
|
@ -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"))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
templates/favicon.ico
Normal file
BIN
templates/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
|
|
@ -2,6 +2,7 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<title>GoWiki | {{.Title}}</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" integrity="sha256-bgotk/IPq4Yvt6s8AQGPTM5ZjPjQ6rrBRa2EyxpnFSc="></link>
|
||||
<link rel="stylesheet" type="text/css" href="/bootstrap.css" media="screen" integrity="sha256-NeLmQ7cX66J4MdtgGlG3O/TgvsSyP1b9WbaQtxYZUbQ="></link>
|
||||
<link rel="stylesheet" type="text/css" href="/custom.css" media="screen" integrity="sha256-o0xveJH8qNnWr/39Jnx97yDlYrvjuUnzE4q3p+94Yp4="></link>
|
||||
<meta name="theme-color" content="#375a7f">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue