add settings page, better navigation

This commit is contained in:
2026-02-13 23:10:08 -08:00
parent 5c5b295961
commit b3c2446add
4 changed files with 214 additions and 64 deletions

View File

@@ -25,6 +25,9 @@ type ProfileData struct {
Titles []string
Times []string
Page int
Title string
LoggedInUsername string
TemplateName string
}
// Render a page of the profile in the URL
@@ -57,6 +60,9 @@ func profilePageHandler() http.HandlerFunc {
var profileData ProfileData
profileData.Username = username
profileData.Page = pageInt
profileData.Title = username + "'s Profile"
profileData.LoggedInUsername = getLoggedInUsername(r)
profileData.TemplateName = "profile"
err = db.Pool.QueryRow(
r.Context(),
@@ -100,7 +106,7 @@ func profilePageHandler() http.HandlerFunc {
profileData.Times = append(profileData.Times, time.Time.String())
}
err = templates.ExecuteTemplate(w, "profile.gohtml", profileData)
err = templates.ExecuteTemplate(w, "base", profileData)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}

View File

@@ -80,6 +80,7 @@ func Start() {
r.Post("/import/spotify", importSpotifyHandler)
r.Get("/import/lastfm/progress", importLastFMProgressHandler)
r.Get("/import/spotify/progress", importSpotifyProgressHandler)
r.Get("/settings", settingsPageHandler())
fmt.Printf("WebUI starting on %s\n", addr)
prot := http.NewCrossOriginProtection()
http.ListenAndServe(addr, prot.Handler(r))