From 295d435a92544347e7718cab0302e0930b812977 Mon Sep 17 00:00:00 2001 From: siddharth Date: Sun, 22 May 2022 18:23:22 -0400 Subject: html -> templates --- html/weather.html | 42 ------------------------------------------ main.go | 6 +++--- templates/weather.tmpl | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 45 deletions(-) delete mode 100644 html/weather.html create mode 100644 templates/weather.tmpl diff --git a/html/weather.html b/html/weather.html deleted file mode 100644 index 520c284..0000000 --- a/html/weather.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - peach - - - - - - -
-
-

{{.Location}}

-
- -
-
-

{{.Now.Forecast}}

-

{{.Now.Temperature}}{{.Now.TemperatureUnit}}

-

{{.Now.WindSpeed}} {{.Now.WindDirection}}

-
-
-

{{.Period.Forecast}}

-
-
- - {{ if .Timeline }} -
-
- {{ range .Timeline.Periods }} -
-

{{.Temperature}}{{.TemperatureUnit}}

-

{{printf "%d" .Hour}}hrs

-
- {{ end }} -
-
- {{ end }} - -
- diff --git a/main.go b/main.go index e6e455b..00ff8d8 100644 --- a/main.go +++ b/main.go @@ -22,11 +22,11 @@ var peachPort = flag.Int("p", 8151, "Port to run peach on") var peachAddr = "" // Holds static content. -//go:embed html static +//go:embed templates static var peachFS embed.FS // HTML templates. -var peachTemplates = template.Must(template.ParseFS(peachFS, "html/*.html")) +var peachTemplates = template.Must(template.ParseFS(peachFS, "templates/*.tmpl")) type Weather struct { Location string @@ -100,7 +100,7 @@ func showWeather(w http.ResponseWriter, lat, lng float32) { return } - err = peachTemplates.ExecuteTemplate(w, "weather.html", weather) + err = peachTemplates.ExecuteTemplate(w, "weather.tmpl", weather) if err != nil { http.Error(w, err.Error(), 500) return diff --git a/templates/weather.tmpl b/templates/weather.tmpl new file mode 100644 index 0000000..520c284 --- /dev/null +++ b/templates/weather.tmpl @@ -0,0 +1,42 @@ + + + + + peach + + + + + + +
+
+

{{.Location}}

+
+ +
+
+

{{.Now.Forecast}}

+

{{.Now.Temperature}}{{.Now.TemperatureUnit}}

+

{{.Now.WindSpeed}} {{.Now.WindDirection}}

+
+
+

{{.Period.Forecast}}

+
+
+ + {{ if .Timeline }} +
+
+ {{ range .Timeline.Periods }} +
+

{{.Temperature}}{{.TemperatureUnit}}

+

{{printf "%d" .Hour}}hrs

+
+ {{ end }} +
+
+ {{ end }} + +
+ -- cgit v1.2.3