mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
Resolve #11.
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user