refactor the preferences page

jocadbz
Joca 2026-02-20 13:26:58 -03:00
parent 5553a8af01
commit 56416b78ec
Signed by: jocadbz
GPG Key ID: B1836DCE2F50BDF7
2 changed files with 25 additions and 36 deletions

View File

@ -69,6 +69,7 @@ func PreferencesHandler(app *App) http.HandlerFunc {
BasePath: app.Config.ThreadrDir,
StaticPath: app.Config.ThreadrDir + "/static",
CurrentURL: r.URL.Path,
ContentTemplate: "preferences-content",
},
Preferences: prefs,
ShowSuccess: showSuccess,

View File

@ -1,23 +1,15 @@
{{define "preferences"}}
<!DOCTYPE html>
<html>
<head>
<title>{{.Title}}</title>
<link rel="stylesheet" href="{{.StaticPath}}/style.css">
<script src="{{.StaticPath}}/app.js" defer></script>
</head>
<body>
{{template "navbar" .}}
<main>
<header>
{{define "preferences"}}{{template "base" .}}{{end}}
{{define "preferences-content"}}
<header>
<h2>Preferences</h2>
</header>
{{if .ShowSuccess}}
<div class="notification success" style="position: static; margin-bottom: 1em; animation: none;">
</header>
{{if .ShowSuccess}}
<div class="notification success" style="position: static; margin-bottom: 1em; animation: none;">
Preferences saved successfully!
</div>
{{end}}
<section>
</div>
{{end}}
<section>
<form method="post" action="{{.BasePath}}/preferences/">
<h3>Draft Auto-Save</h3>
<label for="auto_save_drafts" style="display: flex; align-items: center; gap: 0.5em; cursor: pointer;">
@ -30,9 +22,5 @@
<input type="submit" value="Save Preferences" style="margin-top: 2em;">
</form>
</section>
</main>
{{template "cookie_banner" .}}
</body>
</html>
</section>
{{end}}