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 14:09:11 +02:00
|
|
|
b "streifling.com/jason/cpolis/cmd/backend"
|
2024-03-28 07:34:36 +01:00
|
|
|
)
|
|
|
|
|
2024-07-13 14:09:11 +02:00
|
|
|
func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
2024-03-28 07:34:36 +01:00
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
2024-08-18 11:20:06 +02:00
|
|
|
session, err := getSession(w, r, c, s)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-03-28 07:34:36 +01:00
|
|
|
if err := db.PublishLatestIssue(); err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
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"])
|
|
|
|
}
|
|
|
|
}
|