added admin options

This commit is contained in:
tumillanino
2025-10-28 14:19:54 +11:00
parent e88d625130
commit 788b46a5ea
10 changed files with 162 additions and 20 deletions

View File

@@ -7,6 +7,8 @@ import (
"path/filepath"
"sort"
ory "github.com/ory/client-go"
"decor-by-hannahs/internal/db"
)
@@ -15,7 +17,7 @@ type Photo struct {
Caption string
}
func GalleryHandler(q *db.Queries, tmpl *template.Template) http.HandlerFunc {
func GalleryHandler(q *db.Queries, tmpl *template.Template, oryClient *ory.APIClient) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var photos []Photo
@@ -40,10 +42,17 @@ func GalleryHandler(q *db.Queries, tmpl *template.Template) http.HandlerFunc {
})
type data struct {
Photos []Photo
ActivePage string
Photos []Photo
ActivePage string
Authenticated bool
OryLoginURL string
}
if err := tmpl.ExecuteTemplate(w, "gallery.tmpl", data{Photos: photos, ActivePage: "gallery"}); err != nil {
if err := tmpl.ExecuteTemplate(w, "gallery.tmpl", data{
Photos: photos,
ActivePage: "gallery",
Authenticated: isAuthenticated(r, oryClient),
OryLoginURL: "/login",
}); err != nil {
http.Error(w, "Failed to render page", http.StatusInternalServerError)
}
}