2024-07-13 13:58:36 +02:00
|
|
|
package frontend
|
2024-03-28 07:34:36 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"html/template"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
|
2024-07-13 13:58:36 +02:00
|
|
|
"streifling.com/jason/cpolis/cmd/backend"
|
2024-03-28 07:34:36 +01:00
|
|
|
)
|
|
|
|
|
2024-07-13 13:58:36 +02:00
|
|
|
func PublishLatestIssue(c *backend.Config, db *backend.DB, s *backend.CookieStore) http.HandlerFunc {
|
2024-03-28 07:34:36 +01:00
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
if err := db.PublishLatestIssue(); err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
session, err := s.Get(r, "cookie")
|
|
|
|
if err != nil {
|
2024-03-29 09:07:17 +01:00
|
|
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/login.html")
|
2024-03-28 07:34:36 +01:00
|
|
|
msg := "Session nicht mehr gültig. Bitte erneut anmelden."
|
|
|
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", msg)
|
|
|
|
}
|
|
|
|
|
2024-03-29 09:07:17 +01:00
|
|
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
2024-03-28 07:34:36 +01:00
|
|
|
tmpl = template.Must(tmpl, err)
|
|
|
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"])
|
|
|
|
}
|
|
|
|
}
|