Refactor template loading around the handler

This commit is contained in:
Las Zenow 2017-06-06 14:18:47 +00:00
parent d40dc21627
commit 5517da6a69
9 changed files with 40 additions and 42 deletions

View file

@ -29,7 +29,7 @@ func aboutHandler(h handler) {
data.S = GetStatus(h)
data.S.Title = "About -- " + data.S.Title
data.S.About = true
h.template.load(h, "about", data)
h.load("about", data)
}
func helpHandler(h handler) {
@ -37,7 +37,7 @@ func helpHandler(h handler) {
data.S = GetStatus(h)
data.S.Title = "Help -- " + data.S.Title
data.S.Help = true
h.template.load(h, "help", data)
h.load("help", data)
}
func logoutHandler(h handler) {
@ -72,7 +72,7 @@ func bookHandler(h handler) {
data.S.Title = book.Title + author + " -- " + data.S.Title
data.Description = strings.Split(data.Book.Description, "\n")
h.template.load(h, "book", data)
h.load("book", data)
}
func downloadHandler(h handler) {
@ -121,7 +121,7 @@ func indexHandler(h handler) {
data.VisitedBooks = frontPage.Visited
data.DownloadedBooks = frontPage.Download
h.template.load(h, "index", data)
h.load("index", data)
}
func notFound(h handler) {
@ -130,7 +130,7 @@ func notFound(h handler) {
data.S = GetStatus(h)
data.S.Title = "Not found --" + data.S.Title
h.w.WriteHeader(http.StatusNotFound)
h.template.load(h, "404", data)
h.load("404", data)
}
func UpdateLogger(loggerConfig string) error {