From 29b6022f976355112b9779ae996a32876cc3b477 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Mon, 12 Jun 2023 16:45:23 +0200 Subject: [PATCH] Allow to overwrite legal texts --- web/web.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/web/web.go b/web/web.go index 452ed48..3547b85 100644 --- a/web/web.go +++ b/web/web.go @@ -9,6 +9,7 @@ import ( "html/template" "io/fs" "net/http" + "os" "strings" "github.com/ClusterCockpit/cc-backend/internal/auth" @@ -46,6 +47,23 @@ func init() { return nil } + if path == "templates/imprint.tmpl" { + if _, err := os.Stat("./var/imprint.tmpl"); err == nil { + log.Info("overwrite imprint.tmpl with local file") + templates[strings.TrimPrefix(path, "templates/")] = + template.Must(template.Must(base.Clone()).ParseFiles("./var/imprint.tmpl")) + return nil + } + } + if path == "templates/privacy.tmpl" { + if _, err := os.Stat("./var/privacy.tmpl"); err == nil { + log.Info("overwrite privacy.tmpl with local file") + templates[strings.TrimPrefix(path, "templates/")] = + template.Must(template.Must(base.Clone()).ParseFiles("./var/privacy.tmpl")) + return nil + } + } + templates[strings.TrimPrefix(path, "templates/")] = template.Must(template.Must(base.Clone()).ParseFS(templateFiles, path)) return nil }); err != nil {