diff --git a/html/embed.go b/html/embed.go
index 03ba01f5..da6ae110 100644
--- a/html/embed.go
+++ b/html/embed.go
@@ -72,21 +72,14 @@ func (ts templateSystemEmbed) loadTemplateSubdir(subdir string) error {
return fmt.Errorf("error parsing '%s': %w", path, err)
}
short_path := removeLeadingDir(path)
- shared_template_holder := template.New("shared")
shared_subdirs := []string{"template/sync/component", "template/sync/layout"}
for _, shared_subdir := range shared_subdirs {
- err := ts.addSubdirTemplates(shared_template_holder, shared_subdir)
+ err := ts.addSubdirTemplates(new_t, shared_subdir)
if err != nil {
return fmt.Errorf("Failed to add subdir '%s' templates: %w", shared_subdir, err)
}
}
- if shared_template_holder.Tree == nil {
- return fmt.Errorf("shared template holder tree is nil")
- }
- _, err = new_t.AddParseTree(short_path, shared_template_holder.Tree)
- if err != nil {
- return fmt.Errorf("error adding shared parse tree to '%s': %w", path, err)
- }
+ ts.nameToTemplate[short_path] = new_t
log.Debug().Str("path", short_path).Msg("Loaded page template")
return nil
})
@@ -95,7 +88,7 @@ func (ts templateSystemEmbed) loadTemplateSubdir(subdir string) error {
func (ts templateSystemEmbed) addSubdirTemplates(t *template.Template, subdir string) error {
var err error
- log.Debug().Msg("Adding subdir templates")
+ //log.Debug().Msg("Adding subdir templates")
err = fs.WalkDir(ts.sourceFS, subdir, func(path string, d fs.DirEntry, err error) error {
if err != nil || d.IsDir() {
return err
@@ -117,8 +110,8 @@ func (ts templateSystemEmbed) addSubdirTemplates(t *template.Template, subdir st
if err != nil {
return fmt.Errorf("error adding parse tree '%s': %w", path, err)
}
- ts.nameToTemplate[short_path] = new_t
- //log.Debug().Str("path", short_path).Msg("Loaded shared component template")
+ //ts.nameToTemplate[short_path] = new_t
+ log.Debug().Str("path", short_path).Msg("Loaded shared component template")
return nil
})
return err
@@ -131,7 +124,8 @@ func (ts templateSystemEmbed) renderOrError(w http.ResponseWriter, template_name
templ, ok := ts.nameToTemplate[template_name]
if !ok {
log.Error().Str("template_name", template_name).Msg("Can't find template")
- RespondError(w, "Failed to render template", nil, http.StatusInternalServerError)
+ RespondError(w, "Failed to find template", nil, http.StatusInternalServerError)
+ return
}
err := templ.Execute(buf, context)
if err != nil {
diff --git a/html/filesystem.go b/html/filesystem.go
index dcc76835..32e60f56 100644
--- a/html/filesystem.go
+++ b/html/filesystem.go
@@ -36,7 +36,7 @@ type templateSystemDisk struct {
func LoadTemplates() error {
_, err := os.Stat("html/template")
- if err != nil {
+ if err == nil {
templates = templateSystemDisk{
sourceFS: os.DirFS("./html/template"),
}
diff --git a/html/template/rmo/district-list.html b/html/template/rmo/district-list.html
index 5d3214d3..4975ac9e 100644
--- a/html/template/rmo/district-list.html
+++ b/html/template/rmo/district-list.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Districts{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/email-confirm-complete.html b/html/template/rmo/email-confirm-complete.html
index d45d6fea..697dad2f 100644
--- a/html/template/rmo/email-confirm-complete.html
+++ b/html/template/rmo/email-confirm-complete.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Main{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/email-confirm.html b/html/template/rmo/email-confirm.html
index d72a6f24..46a5e83b 100644
--- a/html/template/rmo/email-confirm.html
+++ b/html/template/rmo/email-confirm.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Main{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/email-subscribe-confirm.html b/html/template/rmo/email-subscribe-confirm.html
index 0b861d9e..bfa386b0 100644
--- a/html/template/rmo/email-subscribe-confirm.html
+++ b/html/template/rmo/email-subscribe-confirm.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Main{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/email-subscribe.html b/html/template/rmo/email-subscribe.html
index d71c3da7..78ec010e 100644
--- a/html/template/rmo/email-subscribe.html
+++ b/html/template/rmo/email-subscribe.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Main{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/email-unsubscribe-complete.html b/html/template/rmo/email-unsubscribe-complete.html
index 78068b3a..4acc449a 100644
--- a/html/template/rmo/email-unsubscribe-complete.html
+++ b/html/template/rmo/email-unsubscribe-complete.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Main{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/email-unsubscribe.html b/html/template/rmo/email-unsubscribe.html
index 2cbb50de..b0209d61 100644
--- a/html/template/rmo/email-unsubscribe.html
+++ b/html/template/rmo/email-unsubscribe.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Main{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/base.html b/html/template/rmo/layout/base.html
similarity index 100%
rename from html/template/rmo/base.html
rename to html/template/rmo/layout/base.html
diff --git a/html/template/rmo/nuisance.html b/html/template/rmo/nuisance.html
index a7951992..664a9f7b 100644
--- a/html/template/rmo/nuisance.html
+++ b/html/template/rmo/nuisance.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Report Nuisance{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/privacy.html b/html/template/rmo/privacy.html
index 5314f780..3f6155ab 100644
--- a/html/template/rmo/privacy.html
+++ b/html/template/rmo/privacy.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Privacy Policy{{ end }}
{{ define "extraheader" }}
{{ end }}
diff --git a/html/template/rmo/quick-submit-complete.html b/html/template/rmo/quick-submit-complete.html
index 693c3828..8c56c483 100644
--- a/html/template/rmo/quick-submit-complete.html
+++ b/html/template/rmo/quick-submit-complete.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Quick Report Complete{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/quick.html b/html/template/rmo/quick.html
index d95bc9cc..7e0d99d3 100644
--- a/html/template/rmo/quick.html
+++ b/html/template/rmo/quick.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Quick Report{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/register-notifications-complete.html b/html/template/rmo/register-notifications-complete.html
index aa35332e..82818d3c 100644
--- a/html/template/rmo/register-notifications-complete.html
+++ b/html/template/rmo/register-notifications-complete.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Notification Request Complete{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/root.html b/html/template/rmo/root.html
index 67c010b8..5729cde8 100644
--- a/html/template/rmo/root.html
+++ b/html/template/rmo/root.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Main{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/search.html b/html/template/rmo/search.html
index 62f7332c..2122c076 100644
--- a/html/template/rmo/search.html
+++ b/html/template/rmo/search.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Status{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/status-by-id.html b/html/template/rmo/status-by-id.html
index 7fad3afa..bc2c6f8c 100644
--- a/html/template/rmo/status-by-id.html
+++ b/html/template/rmo/status-by-id.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Status of report {{ .Report.ID|publicReportID }}{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/status.html b/html/template/rmo/status.html
index 5d95b6da..bbc6f4a0 100644
--- a/html/template/rmo/status.html
+++ b/html/template/rmo/status.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Status{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/submit-complete.html b/html/template/rmo/submit-complete.html
index 09de1990..47fc636d 100644
--- a/html/template/rmo/submit-complete.html
+++ b/html/template/rmo/submit-complete.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Report Submission Complete{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/rmo/terms.html b/html/template/rmo/terms.html
index 2f069b7a..901d3bf2 100644
--- a/html/template/rmo/terms.html
+++ b/html/template/rmo/terms.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Privacy Policy{{ end }}
{{ define "extraheader" }}
{{ end }}
diff --git a/html/template/rmo/water.html b/html/template/rmo/water.html
index 1f2ce8b0..f5970f5b 100644
--- a/html/template/rmo/water.html
+++ b/html/template/rmo/water.html
@@ -1,4 +1,4 @@
-{{ template "rmo/base.html" . }}
+{{ template "rmo/layout/base.html" . }}
{{ define "title" }}Report Standing Water{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/sync/admin.html b/html/template/sync/admin.html
index a12b8884..0a29774e 100644
--- a/html/template/sync/admin.html
+++ b/html/template/sync/admin.html
@@ -1,4 +1,4 @@
-{{ template "sync/base.html" . }}
+{{ template "sync/layout/base.html" . }}
{{ define "title" }}Dash{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/sync/cell.html b/html/template/sync/cell.html
index d70b18f3..0bd7d065 100644
--- a/html/template/sync/cell.html
+++ b/html/template/sync/cell.html
@@ -1,4 +1,4 @@
-{{ template "sync/authenticated.html" . }}
+{{ template "sync/layout/authenticated.html" . }}
{{ define "title" }}Dash{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/sync/dashboard.html b/html/template/sync/dashboard.html
index 81f533aa..cc50281a 100644
--- a/html/template/sync/dashboard.html
+++ b/html/template/sync/dashboard.html
@@ -1,4 +1,4 @@
-{{ template "sync/authenticated.html" . }}
+{{ template "sync/layout/authenticated.html" . }}
{{ define "title" }}Dash{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/sync/data-entry-bad.html b/html/template/sync/data-entry-bad.html
index 0febab27..433510df 100644
--- a/html/template/sync/data-entry-bad.html
+++ b/html/template/sync/data-entry-bad.html
@@ -1,4 +1,4 @@
-{{ template "sync/base.html" . }}
+{{ template "sync/layout/base.html" . }}
{{ define "title" }}Data Entry{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/sync/data-entry-good.html b/html/template/sync/data-entry-good.html
index db222785..823ef123 100644
--- a/html/template/sync/data-entry-good.html
+++ b/html/template/sync/data-entry-good.html
@@ -1,4 +1,4 @@
-{{ template "sync/base.html" . }}
+{{ template "sync/layout/base.html" . }}
{{ define "title" }}Data Entry{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/sync/data-entry.html b/html/template/sync/data-entry.html
index fb5e3eab..285c1e6c 100644
--- a/html/template/sync/data-entry.html
+++ b/html/template/sync/data-entry.html
@@ -1,4 +1,4 @@
-{{ template "sync/base.html" . }}
+{{ template "sync/layout/base.html" . }}
{{ define "title" }}Data Entry{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/sync/dispatch-results.html b/html/template/sync/dispatch-results.html
index 70b02431..23983a28 100644
--- a/html/template/sync/dispatch-results.html
+++ b/html/template/sync/dispatch-results.html
@@ -1,4 +1,4 @@
-{{ template "sync/base.html" . }}
+{{ template "sync/layout/base.html" . }}
{{ define "title" }}Data Entry{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/sync/dispatch.html b/html/template/sync/dispatch.html
index 74bbe1c0..2fae7257 100644
--- a/html/template/sync/dispatch.html
+++ b/html/template/sync/dispatch.html
@@ -1,4 +1,4 @@
-{{ template "sync/base.html" . }}
+{{ template "sync/layout/base.html" . }}
{{ define "title" }}Data Entry{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/sync/district.html b/html/template/sync/district.html
index be3d8853..b56ea3e7 100644
--- a/html/template/sync/district.html
+++ b/html/template/sync/district.html
@@ -1,4 +1,4 @@
-{{ template "sync/base.html" . }}
+{{ template "sync/layout/base.html" . }}
{{ define "title" }}Dash{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/sync/empty-auth.html b/html/template/sync/empty-auth.html
index cfdab34a..aaf493dd 100644
--- a/html/template/sync/empty-auth.html
+++ b/html/template/sync/empty-auth.html
@@ -1,4 +1,4 @@
-{{ template "sync/authenticated.html" . }}
+{{ template "sync/layout/authenticated.html" . }}
{{ define "title" }}Dash{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/sync/empty.html b/html/template/sync/empty.html
index 068470fc..45dfd935 100644
--- a/html/template/sync/empty.html
+++ b/html/template/sync/empty.html
@@ -1,4 +1,4 @@
-{{ template "sync/base.html" . }}
+{{ template "sync/layout/base.html" . }}
{{ define "title" }}Dash{{ end }}
{{ define "extraheader" }}
diff --git a/html/template/sync/layout-test.html b/html/template/sync/layout-test.html
index f82868ea..e0e9a427 100644
--- a/html/template/sync/layout-test.html
+++ b/html/template/sync/layout-test.html
@@ -1,4 +1,4 @@
-{{ template "sync/authenticated.html" . }}
+{{ template "sync/layout/authenticated.html" . }}
{{ define "title" }}Layout Test{{ end }}
{{ define "extraheader" }}