feat(webui): bootstrap a proper UI

This commit is contained in:
Julien Dessaux 2025-01-26 00:04:38 +01:00
parent 09885ef1e4
commit 4e029fb83a
Signed by: adyxax
GPG key ID: F92E51B86E07177E
11 changed files with 127 additions and 75 deletions

View file

@ -14,6 +14,7 @@ import (
var loginTemplate = template.Must(template.ParseFS(htmlFS, "html/base.html", "html/login.html"))
type loginPage struct {
Page
Forbidden bool
Username string
}
@ -28,7 +29,9 @@ func handleLoginGET() http.Handler {
return
}
render(w, loginTemplate, http.StatusOK, loginPage{})
render(w, loginTemplate, http.StatusOK, loginPage{
Page: Page{Title: "Login", Section: "login"},
})
})
}
@ -36,6 +39,7 @@ func handleLoginPOST(db *database.DB) http.Handler {
var validUsername = regexp.MustCompile(`^[a-zA-Z]\w*$`)
renderForbidden := func(w http.ResponseWriter, username string) {
render(w, loginTemplate, http.StatusForbidden, loginPage{
Page: Page{Title: "Login", Section: "login"},
Forbidden: true,
Username: username,
})