add login page customization

This commit is contained in:
2026-07-31 13:01:25 -07:00
parent f0da8aac87
commit f63259dcbc
4 changed files with 14 additions and 4 deletions
+3 -1
View File
@@ -16,7 +16,9 @@ func main() {
read_config()
init_dav_client()
webserver.ServeLoginPage("/login")
webserver.ServeLoginPage("/login", webserver.CustomizableLoginData{
ServiceName: "Astral Calendar",
})
webserver.EnableLogoRoute()
webserver.EnableStaticRoute()
webserver.ServeWebserver()
+8 -1
View File
@@ -8,13 +8,20 @@ import (
type LoginPageData struct {
IsHiddenClassList string
LoginData CustomizableLoginData
}
type CustomizableLoginData struct {
ServiceName string
}
var LoginPageDataCustomizations CustomizableLoginData
func loginHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
tmpl := template.Must(template.ParseFiles("webserver/pages/login_page.html"))
if r.Method == http.MethodGet {
tmpl.Execute(w, LoginPageData{IsHiddenClassList: "hidden"})
tmpl.Execute(w, LoginPageData{IsHiddenClassList: "hidden", LoginData: LoginPageDataCustomizations})
return
}
+1 -1
View File
@@ -13,7 +13,7 @@
<img id="logo_image" alt="logo" src="/logo" />
<form id="login_card" class="card" method="POST">
<div id="welcome_text">
Welcome to Astral Tech, Please Sign in to your account below
Welcome to {{.LoginData.ServiceName}}, Please Sign in to your account below
</div>
<div class="error {{.IsHiddenClassList}}">
+2 -1
View File
@@ -7,7 +7,8 @@ import (
var routes []string
func ServeLoginPage(route string) {
func ServeLoginPage(route string, data CustomizableLoginData) {
LoginPageDataCustomizations = data
ServeWebpage(route, loginHandler)
}