From 1ce14973b7b09fe404dc61c74dbc6715a598de2b Mon Sep 17 00:00:00 2001 From: akuma06 Date: Tue, 9 May 2017 04:12:32 +0200 Subject: [PATCH] Fixed --- router/notFoundHandler.go | 8 -------- router/template.go | 7 ++++++- templates/_user_list_torrents.html | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/router/notFoundHandler.go b/router/notFoundHandler.go index f7a9827a..ed41e902 100644 --- a/router/notFoundHandler.go +++ b/router/notFoundHandler.go @@ -1,20 +1,12 @@ package router import ( - "html/template" "net/http" "github.com/ewhal/nyaa/util/languages" "github.com/gorilla/mux" ) -var notFoundTemplate = template.Must(template.New("NotFound").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/404.html")) - -func init() { - // common - template.Must(notFoundTemplate.ParseGlob("templates/_*.html")) -} - func NotFoundHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotFound) diff --git a/router/template.go b/router/template.go index 4a26fdb4..6a6148c5 100644 --- a/router/template.go +++ b/router/template.go @@ -7,7 +7,7 @@ import ( var TemplateDir = "templates" -var homeTemplate, searchTemplate, faqTemplate, uploadTemplate, viewTemplate, viewRegisterTemplate, viewLoginTemplate, viewRegisterSuccessTemplate, viewVerifySuccessTemplate, viewProfileTemplate *template.Template +var homeTemplate, searchTemplate, faqTemplate, uploadTemplate, viewTemplate, viewRegisterTemplate, viewLoginTemplate, viewRegisterSuccessTemplate, viewVerifySuccessTemplate, viewProfileTemplate, notFoundTemplate *template.Template type templateLoader struct { templ **template.Template @@ -68,6 +68,11 @@ func ReloadTemplates() { name: "user_profile", file: "user/profile.html", }, + templateLoader{ + templ: ¬FoundTemplate, + name: "404", + file: "404.html", + }, } for _, templ := range templs { t := template.Must(template.New(templ.name).Funcs(FuncMap).ParseFiles(filepath.Join(TemplateDir, "index.html"), filepath.Join(TemplateDir, templ.file))) diff --git a/templates/_user_list_torrents.html b/templates/_user_list_torrents.html index d5518975..37d87807 100644 --- a/templates/_user_list_torrents.html +++ b/templates/_user_list_torrents.html @@ -1,6 +1,6 @@ {{define "profile_content"}} {{with .UserProfile}} -{{ if gt (len .ListTorrents) 0 }} +{{ if gt (len .Torrents) 0 }}