1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00
This commit is contained in:
Ferdinand Mütsch
2020-02-20 15:39:56 +01:00
parent b7f700e7a5
commit 6d3891b398
8 changed files with 85 additions and 91 deletions

View File

@ -28,18 +28,20 @@ type SummaryHandler struct {
}
func (m *SummaryHandler) Init() {
m.loadTemplates()
m.Initialized = true
}
func (m *SummaryHandler) loadTemplates() {
indexTplPath := "views/index.tpl.html"
indexTpl, err := template.New(path.Base(indexTplPath)).Funcs(template.FuncMap{
"json": utils.Json,
"date": utils.FormatDateHuman,
}).ParseFiles(indexTplPath)
if err != nil {
panic(err)
}
m.indexTemplate = indexTpl
m.Initialized = true
}
func (h *SummaryHandler) Get(w http.ResponseWriter, r *http.Request) {
@ -72,6 +74,10 @@ func (h *SummaryHandler) Index(w http.ResponseWriter, r *http.Request) {
h.Init()
}
if h.SummarySrvc.Config.IsDev() {
h.loadTemplates()
}
summary, err, status := loadUserSummary(r, h.SummarySrvc)
if err != nil {
w.WriteHeader(status)