mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-23 08:13:33 +00:00
36 lines
770 B
Go
36 lines
770 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
"text/template"
|
|
|
|
"code.tjo.space/mentos1386/zdravko/web/templates"
|
|
"code.tjo.space/mentos1386/zdravko/web/templates/components"
|
|
)
|
|
|
|
type Settings struct {
|
|
*components.Base
|
|
User *AuthenticatedUser
|
|
}
|
|
|
|
func (h *BaseHandler) Settings(w http.ResponseWriter, r *http.Request, user *AuthenticatedUser) {
|
|
ts, err := template.ParseFS(templates.Templates,
|
|
"components/base.tmpl",
|
|
"pages/settings.tmpl",
|
|
)
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
err = ts.ExecuteTemplate(w, "base", &Settings{
|
|
Base: &components.Base{
|
|
Page: GetPageByTitle("Settings"),
|
|
Pages: Pages,
|
|
},
|
|
User: user,
|
|
})
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
}
|
|
}
|