2018-11-12 22:31:10 +00:00
|
|
|
package main
|
|
|
|
|
2020-09-02 13:25:34 +00:00
|
|
|
//go:generate go-bindata -ignore "\\.go|\\.less" -pkg "main" -o "bindata.go" static/...
|
|
|
|
//go:generate go fmt bindata.go
|
|
|
|
|
2018-11-12 22:31:10 +00:00
|
|
|
import (
|
|
|
|
"html/template"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
func displayTmpl(w http.ResponseWriter, page string, vars map[string]interface{}) {
|
2020-09-02 13:25:34 +00:00
|
|
|
data := MustAsset("static/" + page)
|
|
|
|
tpl := template.Must(template.New("page").Parse(string(data)))
|
|
|
|
tpl.New("footer.html").Parse(string(MustAsset("static/footer.html")))
|
|
|
|
tpl.New("header.html").Parse(string(MustAsset("static/header.html")))
|
|
|
|
tpl.ExecuteTemplate(w, "page", vars)
|
2018-11-12 22:31:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func displayTmplError(w http.ResponseWriter, statusCode int, page string, vars map[string]interface{}) {
|
|
|
|
w.WriteHeader(statusCode)
|
|
|
|
displayTmpl(w, page, vars)
|
|
|
|
}
|
|
|
|
|
|
|
|
func displayMsg(w http.ResponseWriter, msg string, statusCode int) {
|
|
|
|
w.WriteHeader(statusCode)
|
|
|
|
|
|
|
|
label := "error"
|
|
|
|
if statusCode < 400 {
|
|
|
|
label = "message"
|
|
|
|
}
|
|
|
|
|
|
|
|
displayTmpl(w, "message.html", map[string]interface{}{label: msg})
|
|
|
|
}
|