From 3b00a71391c89091ab7389c31f63f1ee135a5f3e Mon Sep 17 00:00:00 2001 From: Kenneth Date: Sat, 10 May 2025 16:21:43 +0100 Subject: [PATCH] improve website style --- main.go | 13 +++++++++++-- web/index.html | 39 +++++++++++++++++++++++++-------------- web/style.css | 40 ++++++++++++++++++++++++++++++++++++---- web/summary.html | 13 ++++++++----- 4 files changed, 80 insertions(+), 25 deletions(-) diff --git a/main.go b/main.go index 1e70b6a..aa7b4f1 100644 --- a/main.go +++ b/main.go @@ -89,7 +89,7 @@ type state struct { //go:embed web var webDir embed.FS -var prompt = "Provide a summaries of the weather below, mentioning the location. Provide suggestions on how to cope with the weather. Use celsius and fahrenheit for temperature. Do not add anything else. Respond in one line." +var prompt = "The current time is 7am. Provide a summary of today's weather in %v below, as well as how to deal with the weather, such as how to dress for the weather, and whether they need an umbrella Use celsius and fahrenheit for temperature. Mention %v in the summary, but don't add anything else, as the summary will be displayed on a website." var supportedLocations = map[string]location{ "london": {51.507351, -0.127758, "Europe/London"}, @@ -100,6 +100,15 @@ var supportedLocations = map[string]location{ "tokyo": {35.689487, 139.691711, "Asia/Tokyo"}, } +var locationNames = map[string]string{ + "london": "London", + "sf": "San Francisco", + "sj": "San Jose", + "la": "Los Angeles", + "nyc": "New York City", + "tokyo": "Tokyo", +} + func main() { port := flag.Int("port", 8080, "the port that the server should listen on") genKeys := flag.Bool("generate-vapid-keys", false, "generate a new vapid key pair, which will be outputted to stdout.") @@ -469,7 +478,7 @@ func updateSummaries(state *state, locKey string, loc *location) { result, err := state.genai.Models.GenerateContent(state.ctx, "gemini-2.0-flash", []*genai.Content{{ Parts: []*genai.Part{ - {Text: prompt}, + {Text: fmt.Sprintf(prompt, locationNames[locKey])}, {Text: string(b)}, }, }}, nil) diff --git a/web/index.html b/web/index.html index 4f2911d..27b3bd2 100644 --- a/web/index.html +++ b/web/index.html @@ -7,25 +7,36 @@ - + -
-

7am

-

Daily weather updates delivered to you at 7am.

-
- -
+
+
+

7am

+

Daily weather updates delivered to you at 7am.

+
+ +
+
+ +
+ +
+

+ Source code: GitHub +

+
+
diff --git a/web/style.css b/web/style.css index 4f35ee9..73d8b6e 100644 --- a/web/style.css +++ b/web/style.css @@ -17,14 +17,27 @@ html, body { font-family: Geist, sans-serif; width: 100%; - padding-top: 4rem; + height: 100%; display: flex; - align-items: center; justify-content: center; background-color: var(--background-color); color: var(--text-color); } +body { + margin: 0; +} + +.container { + display: flex; + flex-direction: column; + align-items: start; + justify-content: center; + padding-top: 8rem; + padding-left: 1rem; + padding-right: 1rem; +} + h1 { font-weight: bolder; font-size: 1em; @@ -57,11 +70,12 @@ a { hr.divider { border-color: var(--text-color); margin: 1.5rem 0; + width: 100%; } main { - padding-left: 1rem; - padding-right: 1rem; + width: 100%; + flex: 1; } button { @@ -73,7 +87,25 @@ button { font-weight: bold; } +footer { + padding-top: 2rem; + padding-bottom: 4rem; + opacity: 80%; + font-size: 0.8em; + display: flex; + flex-direction: column; + justify-content: center; +} + +footer > p { + margin: 0; +} + .summary { max-width: 30ch; font-size: 2em; } + +.back-link { + font-size: 0.8em; +} diff --git a/web/summary.html b/web/summary.html index 64a4d2d..05c689b 100644 --- a/web/summary.html +++ b/web/summary.html @@ -7,16 +7,19 @@ - + -
-

{{.Summary}}

- -
+
+
+ <- All locations +

{{.Summary}}

+ +
+