2024-02-11 19:28:00 +00:00
|
|
|
package handlers
|
2024-02-10 17:35:16 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"text/template"
|
|
|
|
|
2024-02-11 19:28:00 +00:00
|
|
|
"code.tjo.space/mentos1386/zdravko/web/templates"
|
2024-02-12 10:22:14 +00:00
|
|
|
"code.tjo.space/mentos1386/zdravko/web/templates/components"
|
2024-02-10 17:35:16 +00:00
|
|
|
)
|
|
|
|
|
2024-02-12 10:22:14 +00:00
|
|
|
type Settings struct {
|
|
|
|
*components.Base
|
|
|
|
User *AuthenticatedUser
|
|
|
|
}
|
|
|
|
|
2024-02-11 22:48:37 +00:00
|
|
|
func (h *BaseHandler) Settings(w http.ResponseWriter, r *http.Request, user *AuthenticatedUser) {
|
2024-02-11 19:28:00 +00:00
|
|
|
ts, err := template.ParseFS(templates.Templates,
|
2024-02-11 10:56:21 +00:00
|
|
|
"components/base.tmpl",
|
|
|
|
"pages/settings.tmpl",
|
2024-02-10 17:35:16 +00:00
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-02-12 10:22:14 +00:00
|
|
|
err = ts.ExecuteTemplate(w, "base", &Settings{
|
|
|
|
Base: &components.Base{
|
|
|
|
Page: GetPageByTitle("Settings"),
|
|
|
|
Pages: Pages,
|
|
|
|
},
|
|
|
|
User: user,
|
|
|
|
})
|
2024-02-10 17:35:16 +00:00
|
|
|
if err != nil {
|
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
|
|
}
|
|
|
|
}
|