diff --git a/cmd/frontend/articles.go b/cmd/frontend/articles.go index a408280..9393897 100644 --- a/cmd/frontend/articles.go +++ b/cmd/frontend/articles.go @@ -23,25 +23,6 @@ const ( PreviewMode ) -func ShowHub(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - session, err := getSession(w, r, c, s) - if err != nil { - return - } - - session.Values["article"] = nil - if err = session.Save(r, w); err != nil { - log.Println(err) - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html") - template.Must(tmpl, err).ExecuteTemplate(w, "page-content", session.Values["role"].(int)) - } -} - func WriteArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { session, err := getSession(w, r, c, s) diff --git a/cmd/frontend/sessions.go b/cmd/frontend/sessions.go index 2f34d3d..514d9cf 100644 --- a/cmd/frontend/sessions.go +++ b/cmd/frontend/sessions.go @@ -107,3 +107,22 @@ func Logout(c *b.Config, s *b.CookieStore) http.HandlerFunc { template.Must(tmpl, err).ExecuteTemplate(w, "page-content", nil) } } + +func ShowHub(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + session, err := getSession(w, r, c, s) + if err != nil { + return + } + + session.Values["article"] = nil + if err = session.Save(r, w); err != nil { + log.Println(err) + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html") + template.Must(tmpl, err).ExecuteTemplate(w, "page-content", session.Values["role"].(int)) + } +}