From 96166f3f17a048499cd6c9af95e81d8f4c655978 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sun, 6 Apr 2025 09:59:04 +0200 Subject: refactor: rename views/ to templates/ --- lexsurf.go | 6 +++--- templates/index.html.tmpl | 17 +++++++++++++++++ templates/search.html.tmpl | 30 ++++++++++++++++++++++++++++++ views/index.html | 17 ----------------- views/search.html | 30 ------------------------------ 5 files changed, 50 insertions(+), 50 deletions(-) create mode 100644 templates/index.html.tmpl create mode 100644 templates/search.html.tmpl delete mode 100644 views/index.html delete mode 100644 views/search.html diff --git a/lexsurf.go b/lexsurf.go index 5c1e15a..45eca6a 100644 --- a/lexsurf.go +++ b/lexsurf.go @@ -53,7 +53,7 @@ func main() { var tpl, _ = template.New("").Funcs(template.FuncMap{ "ToUpper": strings.ToUpper, -}).ParseGlob("views/*") +}).ParseGlob("templates/*") type handler struct { domain string @@ -68,7 +68,7 @@ func (h *handler) handle(w http.ResponseWriter, r *http.Request) { w.Write([]byte("page not found")) return } - err := tpl.ExecuteTemplate(w, "index.html", map[string]any{ + err := tpl.ExecuteTemplate(w, "index.html.tmpl", map[string]any{ "Countries": h.countries, "Domain": r.Host, }) @@ -109,7 +109,7 @@ func (h *handler) handle(w http.ResponseWriter, r *http.Request) { } } _, hasJSONLaws := h.lawsByCC[cc] - err := tpl.ExecuteTemplate(w, "search.html", map[string]any{ + err := tpl.ExecuteTemplate(w, "search.html.tmpl", map[string]any{ "TLD": cc, "Domain": h.domain, "Country": h.countries[cc], diff --git a/templates/index.html.tmpl b/templates/index.html.tmpl new file mode 100644 index 0000000..3d8c04f --- /dev/null +++ b/templates/index.html.tmpl @@ -0,0 +1,17 @@ + + + + Lex.surf: Portal to National Law + + + + + +

The portal to national law.

+
+ {{range $key, $c := .Countries -}} + {{$key | ToUpper}} + {{- end}} +
+ + diff --git a/templates/search.html.tmpl b/templates/search.html.tmpl new file mode 100644 index 0000000..70c8c86 --- /dev/null +++ b/templates/search.html.tmpl @@ -0,0 +1,30 @@ + + + + National Law of {{.Country.Name}} + + + + + +

National Law of {{.Country.Name}}

+ {{if not .Country.HasPlaceholder}} +

{{.Country.SearchURL}}

+ + {{if not .HasJSONLaws}} + (No search form here because the search isn't linkable.) + {{end}} + {{end}} + {{if .Country.HasPlaceholder}} +
+ {{end}} + {{if or .Country.HasPlaceholder .HasJSONLaws}} + + + {{end}} + {{if .Country.HasPlaceholder}} +
+ {{end}} + + + diff --git a/views/index.html b/views/index.html deleted file mode 100644 index 3d8c04f..0000000 --- a/views/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - Lex.surf: Portal to National Law - - - - - -

The portal to national law.

-
- {{range $key, $c := .Countries -}} - {{$key | ToUpper}} - {{- end}} -
- - diff --git a/views/search.html b/views/search.html deleted file mode 100644 index 70c8c86..0000000 --- a/views/search.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - National Law of {{.Country.Name}} - - - - - -

National Law of {{.Country.Name}}

- {{if not .Country.HasPlaceholder}} -

{{.Country.SearchURL}}

- - {{if not .HasJSONLaws}} - (No search form here because the search isn't linkable.) - {{end}} - {{end}} - {{if .Country.HasPlaceholder}} -
- {{end}} - {{if or .Country.HasPlaceholder .HasJSONLaws}} - - - {{end}} - {{if .Country.HasPlaceholder}} -
- {{end}} - - - -- cgit v1.2.3