From eb867528e39cd7449f8c5f112c5a2ea564daa038 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Thu, 22 Jun 2023 07:01:29 +0200 Subject: [PATCH] feat - Allow to overwrite login template --- cmd/cc-backend/main.go | 7 +++++++ web/web.go | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/cmd/cc-backend/main.go b/cmd/cc-backend/main.go index f9868e6..86c5323 100644 --- a/cmd/cc-backend/main.go +++ b/cmd/cc-backend/main.go @@ -325,6 +325,13 @@ func main() { if config.Keys.EmbedStaticFiles { r.PathPrefix("/").Handler(web.ServeFiles()) + + if i, err := os.Stat("./var/img"); err == nil { + if i.IsDir() { + log.Info("Use local directory for static images") + r.Handle("/img", http.FileServer(http.Dir("./var/img"))) + } + } } else { r.PathPrefix("/").Handler(http.FileServer(http.Dir(config.Keys.StaticFiles))) } diff --git a/web/web.go b/web/web.go index 3547b85..d045b05 100644 --- a/web/web.go +++ b/web/web.go @@ -47,6 +47,14 @@ func init() { return nil } + if path == "templates/login.tmpl" { + if _, err := os.Stat("./var/login.tmpl"); err == nil { + log.Info("overwrite login.tmpl with local file") + templates[strings.TrimPrefix(path, "templates/")] = + template.Must(template.Must(base.Clone()).ParseFiles("./var/login.tmpl")) + return nil + } + } if path == "templates/imprint.tmpl" { if _, err := os.Stat("./var/imprint.tmpl"); err == nil { log.Info("overwrite imprint.tmpl with local file")