diff --git a/internal/dis/component/control/home/home.html b/internal/dis/component/control/home/home.html
index fa543db..54e8f0c 100644
--- a/internal/dis/component/control/home/home.html
+++ b/internal/dis/component/control/home/home.html
@@ -6,11 +6,13 @@
{{ end }}
{{ define "content" }}
+{{ block "@custom/about" . }}
WissKIs on this Distillery
diff --git a/internal/dis/component/control/static/custom/assets.go b/internal/dis/component/control/static/custom/assets.go
index 7efe957..c0ad5b4 100644
--- a/internal/dis/component/control/static/custom/assets.go
+++ b/internal/dis/component/control/static/custom/assets.go
@@ -11,8 +11,8 @@ func (custom *Custom) CustomAssetsPath() string {
return filepath.Join(custom.Config.DeployRoot, "core", "assets")
}
-func (custom *Custom) FooterPath() string {
- return filepath.Join(custom.CustomAssetsPath(), "footer.html")
+func (custom *Custom) CustomAssetPath(name string) string {
+ return filepath.Join(custom.CustomAssetsPath(), name)
}
func (custom *Custom) BackupName() string { return "custom" }
diff --git a/internal/dis/component/control/static/custom/template.go b/internal/dis/component/control/static/custom/template.go
index 52d076f..267f589 100644
--- a/internal/dis/component/control/static/custom/template.go
+++ b/internal/dis/component/control/static/custom/template.go
@@ -8,35 +8,56 @@ import (
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
)
-const footerName = "footer"
+const (
+ footerName = "@custom/footer"
+ aboutName = "@custom/about"
+)
//go:embed "footer.html"
-var defaultTemplateStr string
-var defaultTemplate = template.Must(template.New("footer.html").Parse(defaultTemplateStr))
+var footerTemplateStr string
+var defaultFooterTemplate = template.Must(template.New("footer.html").Parse(footerTemplateStr))
// Template creates a copy of template with shared template parts updated accordingly.
// Any template using this should use one of the template contexts in this package.
func (custom *Custom) Template(tpl *template.Template) *template.Template {
- tree := custom.footerTemplate()
+ // create a clone of the template
+ clone := template.Must(tpl.Clone())
- clone := template.Must(tpl.Clone()) // create a clone of the template
- template.Must(clone.AddParseTree(footerName, tree)) // add the parse tree to it
- return clone // and return the tree
+ // add all the fixed parse trees
+ footerTree := custom.getTemplateAsset(defaultFooterTemplate)
+ template.Must(clone.AddParseTree(footerName, footerTree))
+
+ // optionally add the about asset
+ if aboutTree := custom.readTemplateAsset("about.html"); clone.Lookup(aboutName) != nil && aboutTree != nil {
+ template.Must(clone.AddParseTree(aboutName, aboutTree))
+ }
+ return clone // and return the tree
}
-// footerTemplate returns a new copy of the footer template
-func (custom *Custom) footerTemplate() *parse.Tree {
- footer, err := (func() (*template.Template, error) {
- data, err := environment.ReadFile(custom.Environment, custom.FooterPath())
+// getTemplateAsset returns an overridable template asset.
+//
+// If the asset named can successfully be parsed, it is returned.
+// If it can not be parsed, the default template is returned.
+func (custom *Custom) getTemplateAsset(dflt *template.Template) *parse.Tree {
+ tree := custom.readTemplateAsset(dflt.Name())
+ if tree == nil {
+ return dflt.Tree.Copy()
+ }
+ return tree
+}
+
+// readTemplateAsset is like getTemplateAssets, but takes an explicit name to read.
+// when the asset does not exist, or cannot be opened, returns nil.
+func (custom *Custom) readTemplateAsset(name string) *parse.Tree {
+ template, err := (func() (*template.Template, error) {
+ data, err := environment.ReadFile(custom.Environment, custom.CustomAssetPath(name))
if err != nil {
return nil, err
}
- return template.New("footer.html").Parse(string(data))
+ return template.New(name).Parse(string(data))
})()
-
if err != nil {
- return defaultTemplate.Tree.Copy()
+ return nil
}
-
- return footer.Tree
+ return template.Tree
}
diff --git a/internal/dis/component/control/static/templates/_base.html b/internal/dis/component/control/static/templates/_base.html
index b2d4ff1..59cff02 100644
--- a/internal/dis/component/control/static/templates/_base.html
+++ b/internal/dis/component/control/static/templates/_base.html
@@ -21,8 +21,10 @@