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"
)
func settingsRenderView(f settingsForm, e settingsFormErrors) template.HTML {
func settingsRenderView(f settingsForm, e settingsFormErrors, ctx httpx.Ctx) template.HTML {
body := components.Form{
Action: "/settings",
Fields: []components.Field{
@ -41,7 +41,7 @@ func settingsRenderView(f settingsForm, e settingsFormErrors) template.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) {
@ -67,7 +67,7 @@ func SettingsGet(w http.ResponseWriter, r *http.Request) {
return
}
html(w, settingsRenderView(form, settingsFormErrors{}))
html(w, settingsRenderView(form, settingsFormErrors{}, ctx))
}
type settingsForm struct {
@ -129,7 +129,7 @@ func SettingsPost(w http.ResponseWriter, r *http.Request) {
if failed {
w.WriteHeader(http.StatusBadRequest)
html(w, settingsRenderView(form, errs))
html(w, settingsRenderView(form, errs, ctx))
return
}

View file

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