UI Customize: add white-label flags (logo, brand, website, email, phone) (#32582)

This commit is contained in:
Michael Geers 2026-08-07 18:30:58 +02:00 • committed by GitHub
parent 5e69a6226d
commit 84cf093d3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 303 additions and 52 deletions

View file

@ -41,7 +41,42 @@ func getPreferredLanguage(header string) string {
return base.String()
}
func indexHandler(customCss bool) http.HandlerFunc {
// globalsJsHandler serves version and ui customization as window.evcc globals
func globalsJsHandler(custom Customization) http.HandlerFunc {
globals := struct {
Version string `json:"version"`
Commit string `json:"commit"`
CustomCss bool `json:"customCss"`
CustomLogo bool `json:"customLogo"`
Brand string `json:"customBrand"`
Website string `json:"customWebsite"`
Email string `json:"customEmail"`
Phone string `json:"customPhone"`
}{
Version: util.Version,
Commit: util.Commit,
CustomCss: custom.Css != "",
CustomLogo: custom.LogoLight != "",
Brand: custom.Brand,
Website: custom.Website,
Email: custom.Email,
Phone: custom.Phone,
}
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/javascript; charset=UTF-8")
w.Header().Set("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0")
if _, err := w.Write([]byte("window.evcc = ")); err != nil {
return
}
if err := json.NewEncoder(w).Encode(globals); err != nil {
log.ERROR.Println("httpd: failed to render globals:", err.Error())
}
}
}
func indexHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=UTF-8")
w.Header().Set("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0")
@ -64,9 +99,7 @@ func indexHandler(customCss bool) http.HandlerFunc {
if err := t.Execute(w, map[string]any{
"Version": util.Version,
"Commit": util.Commit,
"DefaultLang": defaultLang,
"CustomCss": customCss,
}); err != nil {
log.ERROR.Println("httpd: failed to render main page:", err.Error())
}