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() read_config()
init_dav_client() init_dav_client()
webserver.ServeLoginPage("/login") webserver.ServeLoginPage("/login", webserver.CustomizableLoginData{
ServiceName: "Astral Calendar",
})
webserver.EnableLogoRoute() webserver.EnableLogoRoute()
webserver.EnableStaticRoute() webserver.EnableStaticRoute()
webserver.ServeWebserver() webserver.ServeWebserver()
+8 -1
View File
@@ -8,13 +8,20 @@ import (
type LoginPageData struct { type LoginPageData struct {
IsHiddenClassList string IsHiddenClassList string
LoginData CustomizableLoginData
} }
type CustomizableLoginData struct {
ServiceName string
}
var LoginPageDataCustomizations CustomizableLoginData
func loginHandler(w http.ResponseWriter, r *http.Request) { func loginHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Header().Set("Content-Type", "text/html; charset=utf-8")
tmpl := template.Must(template.ParseFiles("webserver/pages/login_page.html")) tmpl := template.Must(template.ParseFiles("webserver/pages/login_page.html"))
if r.Method == http.MethodGet { if r.Method == http.MethodGet {
tmpl.Execute(w, LoginPageData{IsHiddenClassList: "hidden"}) tmpl.Execute(w, LoginPageData{IsHiddenClassList: "hidden", LoginData: LoginPageDataCustomizations})
return return
} }
+1 -1
View File
@@ -13,7 +13,7 @@
<img id="logo_image" alt="logo" src="/logo" /> <img id="logo_image" alt="logo" src="/logo" />
<form id="login_card" class="card" method="POST"> <form id="login_card" class="card" method="POST">
<div id="welcome_text"> <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>
<div class="error {{.IsHiddenClassList}}"> <div class="error {{.IsHiddenClassList}}">
+2 -1
View File
@@ -7,7 +7,8 @@ import (
var routes []string var routes []string
func ServeLoginPage(route string) { func ServeLoginPage(route string, data CustomizableLoginData) {
LoginPageDataCustomizations = data
ServeWebpage(route, loginHandler) ServeWebpage(route, loginHandler)
} }