summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lexsurf.go32
1 files changed, 9 insertions, 23 deletions
diff --git a/lexsurf.go b/lexsurf.go
index 5d25a6a..b9dbb66 100644
--- a/lexsurf.go
+++ b/lexsurf.go
@@ -58,9 +58,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("page not found"))
return
}
- err := tpl.ExecuteTemplate(w, "index.html", StartPageContext{
- Countries: countries,
- Domain: r.Host,
+ err := tpl.ExecuteTemplate(w, "index.html", map[string]any{
+ "Countries": countries,
+ "Domain": r.Host,
})
if err != nil {
log.Fatal(err)
@@ -100,10 +100,12 @@ func handler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusBadRequest)
}
}
- err := tpl.ExecuteTemplate(w, "search.html", SearchContext{
- TLD: cc,
- Domain: host,
- Country: countries[cc],
+ _, hasJSONLaws := lawsByCC[cc]
+ err := tpl.ExecuteTemplate(w, "search.html", map[string]any{
+ "TLD": cc,
+ "Domain": host,
+ "Country": countries[cc],
+ "HasJSONLaws": hasJSONLaws,
})
if err != nil {
log.Fatal(err)
@@ -126,19 +128,3 @@ type country struct {
func (c country) HasPlaceholder() bool {
return strings.Contains(c.SearchURL, "%s")
}
-
-func (c SearchContext) HasJSONLaws() bool {
- _, ok := lawsByCC[c.TLD]
- return ok
-}
-
-type StartPageContext struct {
- Countries map[string]country
- Domain string
-}
-
-type SearchContext struct {
- TLD string
- Domain string
- Country country
-}