fixed bugs
This commit is contained in:
parent
49b32ab4d9
commit
51f56c14a1
2
main.go
2
main.go
@ -39,7 +39,7 @@ func main() {
|
||||
)
|
||||
defer Database.Close()
|
||||
|
||||
if tmpl, err := template.New("homepage").ParseFS(TemplateFS, "templates/*"); err == nil {
|
||||
if tmpl, err := template.New("homepage").Funcs(tmplFuncs).ParseFS(TemplateFS, "templates/*"); err == nil {
|
||||
Templates = tmpl
|
||||
} else {
|
||||
panic(err)
|
||||
|
@ -1,3 +1,3 @@
|
||||
<a href="{{ .Link }}" class="bookmark" style='background-color: {{ .GetColor }}; {{ if not .HideBorder }} box-shadow: 0px 0px 3px black; {{ end }}; {{ if not (eq .IconPadding "") }} padding: {{ .IconPadding }}; {{ end }}'>
|
||||
<div class="background" style='background-image: url("{{ .Image }}"); background-size: {{ .GetImageSize }}'></div>
|
||||
<div class="background" style='background-image: url("{{ .Image | url }}"); background-size: {{ .GetImageSize }}'></div>
|
||||
</a>
|
||||
|
22
utils.go
22
utils.go
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
crand "crypto/rand"
|
||||
"encoding/hex"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
@ -84,3 +85,24 @@ func makeNewSession(w http.ResponseWriter) (*Session, error) {
|
||||
|
||||
return session, nil
|
||||
}
|
||||
|
||||
var tmplFuncs = template.FuncMap{
|
||||
"js": func(s string) template.JS {
|
||||
return template.JS(s)
|
||||
},
|
||||
"jss": func(s string) template.JSStr {
|
||||
return template.JSStr(s)
|
||||
},
|
||||
"css": func(s string) template.CSS {
|
||||
return template.CSS(s)
|
||||
},
|
||||
"attr": func(s string) template.HTMLAttr {
|
||||
return template.HTMLAttr(s)
|
||||
},
|
||||
"safe": func(s string) template.HTML {
|
||||
return template.HTML(s)
|
||||
},
|
||||
"url": func(s string) template.URL {
|
||||
return template.URL(s)
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user