Fix some more rendering bugs

This commit is contained in:
soup 2024-11-16 16:22:07 -05:00
parent 54fa17ab25
commit f058177edf
2 changed files with 12 additions and 10 deletions

View file

@ -14,7 +14,7 @@ import (
"git.soup.land/soup/shelves/internal/templates/components" "git.soup.land/soup/shelves/internal/templates/components"
) )
func settingsRenderView(f settingsForm, e settingsFormErrors) template.HTML { func settingsRenderView(f settingsForm, e settingsFormErrors, ctx httpx.Ctx) template.HTML {
body := components.Form{ body := components.Form{
Action: "/settings", Action: "/settings",
Fields: []components.Field{ Fields: []components.Field{
@ -41,7 +41,7 @@ func settingsRenderView(f settingsForm, e settingsFormErrors) template.HTML {
}, },
}.HTML() }.HTML()
return components.Page{Title: "Set up", Body: body}.HTML() return components.Page{Title: "Set up", Body: body, SessionInfo: ctx.SessionInfo}.HTML()
} }
func queryGetOwnerSettings(db *sql.DB) (settingsForm, error) { func queryGetOwnerSettings(db *sql.DB) (settingsForm, error) {
@ -67,7 +67,7 @@ func SettingsGet(w http.ResponseWriter, r *http.Request) {
return return
} }
html(w, settingsRenderView(form, settingsFormErrors{})) html(w, settingsRenderView(form, settingsFormErrors{}, ctx))
} }
type settingsForm struct { type settingsForm struct {
@ -129,7 +129,7 @@ func SettingsPost(w http.ResponseWriter, r *http.Request) {
if failed { if failed {
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
html(w, settingsRenderView(form, errs)) html(w, settingsRenderView(form, errs, ctx))
return return
} }

View file

@ -2,13 +2,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>{{block "Title" .Title}}{{end}} - Shelves</title> <title>{{block "Title" .Title}}{{.}}{{end}} - Shelves</title>
<link rel="stylesheet" href="/static/css/mu.css" /> <link rel="stylesheet" href="/static/css/mu.css" />
<script module src="/static/js/vendor/htmx-2.0.3.js"></script> <script module src="/static/js/vendor/htmx-2.0.3.js"></script>
{{block "Head" .Head}}{{end}} {{block "Head" .Head}}{{.}}{{end}}
</head> </head>
<body> <body>
<nav> <nav aria-label="Main navigation">
<ul> <ul>
<li> <li>
{{if eq .SessionInfo.SessionId ""}} {{if eq .SessionInfo.SessionId ""}}
@ -19,9 +19,11 @@
</li> </li>
</ul> </ul>
</nav> </nav>
{{block "BodyBefore" .BodyBefore}}{{end}} {{block "BodyBefore" .BodyBefore}}{{.}}{{end}}
<main>
{{block "Body" .Body}}{{.}}{{end}} {{block "Body" .Body}}{{.}}{{end}}
{{block "BodyAfter" .BodyAfter}}{{end}} </main>
{{block "BodyAfter" .BodyAfter}}{{.}}{{end}}
</body> </body>
</html> </html>
{{end}} {{end}}