From b5b902b02ebe60b771495378a173f9a5d4ee176b Mon Sep 17 00:00:00 2001 From: siddharth Date: Sun, 22 May 2022 20:51:08 -0400 Subject: templates: update weather template --- main.go | 5 +-- templates/weather.tmpl | 92 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 58 insertions(+), 39 deletions(-) diff --git a/main.go b/main.go index 4401f70..a423f21 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "net/http" "regexp" "strconv" + "strings" "time" "ricketyspace.net/peach/nws" @@ -133,8 +134,8 @@ func showWeather(w http.ResponseWriter, lat, lng float32) { func NewWeather(point *nws.NWSPoint, f, fh *nws.NWSForecast) (*Weather, error) { w := new(Weather) w.Location = fmt.Sprintf("%s, %s", - point.Properties.RelativeLocation.Properties.City, - point.Properties.RelativeLocation.Properties.State, + strings.ToLower(point.Properties.RelativeLocation.Properties.City), + strings.ToLower(point.Properties.RelativeLocation.Properties.State), ) w.Now = WeatherNow{ Temperature: fh.Properties.Periods[0].Temperature, diff --git a/templates/weather.tmpl b/templates/weather.tmpl index 520c284..904e45b 100644 --- a/templates/weather.tmpl +++ b/templates/weather.tmpl @@ -1,42 +1,60 @@ - - - peach - - - - - - -
-
-

{{.Location}}

-
+ + + peach - {{.Location}} + + + + + + +
+
+
+
+

{{.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 }} +
+
+
+ {{.Now.Temperature}}{{.Now.TemperatureUnit}} +
+
+ {{.Now.Forecast}} +
+
-
- +
+ {{.Now.WindSpeed}} {{.Now.WindDirection}} +
+
+ +
+

{{.Period.Forecast}}

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

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

+

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

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