From 06d4d57a9fd87415b97cc9cacf96e47701522e85 Mon Sep 17 00:00:00 2001 From: Justin Fuller Date: Sat, 12 Aug 2023 08:26:45 -0400 Subject: [PATCH] Imports --- main.go | 8 +- make/grass-service-worker.js | 19 + make/grass.css | 177 +++++++++ make/grass.html | 748 ----------------------------------- make/grass.js | 315 +++++++++++++++ make/grass.template.html | 235 +++++++++++ meta.template.html | 32 ++ 7 files changed, 785 insertions(+), 749 deletions(-) create mode 100644 make/grass.css delete mode 100644 make/grass.html create mode 100644 make/grass.js create mode 100644 make/grass.template.html create mode 100644 meta.template.html diff --git a/main.go b/main.go index 40b951a..286d281 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ import ( type data struct { Title string + Meta string Entries [][]byte Entry []byte } @@ -99,7 +100,12 @@ func main() { }) http.HandleFunc("/grass", func(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, "./make/grass.html") + if err := template.Must(template.ParseFiles("./make/grass.template.html", "./make/grass.js", "./make/grass.css", "./meta.template.html")).Execute(w, data{ + Title: "Grass", + Meta: "grass", + }); err != nil { + log.Printf("Error: %s", err) + } }) http.HandleFunc("/story", func(w http.ResponseWriter, r *http.Request) { diff --git a/make/grass-service-worker.js b/make/grass-service-worker.js index 905feb8..a78c7f9 100644 --- a/make/grass-service-worker.js +++ b/make/grass-service-worker.js @@ -1 +1,20 @@ self.addEventListener('install', event => console.log('ServiceWorker installed')); + +self.addEventListener('push', function(event) { + console.log({ event }); + + event.waitUntil(self.registration.showNotification("Grass | Justin Fuller", { + body: "Today's the day. Water your lawn!", + icon: "/image/grass.png", + })); +}) + +self.addEventListener('notificationclick', function(event) { + console.log('[Service Worker] Notification click received.'); + + event.notification.close(); + + event.waitUntil( + clients.openWindow('https://justindfuller.com/grass') + ); +}); diff --git a/make/grass.css b/make/grass.css new file mode 100644 index 0000000..3a550a6 --- /dev/null +++ b/make/grass.css @@ -0,0 +1,177 @@ + diff --git a/make/grass.html b/make/grass.html deleted file mode 100644 index f82b8ab..0000000 --- a/make/grass.html +++ /dev/null @@ -1,748 +0,0 @@ - - - - - Grass | Justin Fuller - - - - - - - - - - - - - - - - - - - - -
-

Grass

-

- Hey there 👋 I'd like to help you figure out how much to water your - grass. This is trickier than it may seem. The amount changes based on - the grass type and natural rainfall. Overwatering wastes resources; - hurts your grass; and may cause mold, fungus, and moss to grow in your - yard. Underwatering will cause your grass to go dormant and eventually - die. -
-
- To combat these problems, I'll use your area's forecast along with some - information about your lawn's grass to create a custom watering plan. -
-
- To get started, click the button below to grant the page access to your - latitude and longitude. I'll send this over to - weather.gov - to get your seven day forecast. - - -

- - - - - - - - -
- - - - - diff --git a/make/grass.js b/make/grass.js new file mode 100644 index 0000000..8e37c29 --- /dev/null +++ b/make/grass.js @@ -0,0 +1,315 @@ + diff --git a/make/grass.template.html b/make/grass.template.html new file mode 100644 index 0000000..17f24c8 --- /dev/null +++ b/make/grass.template.html @@ -0,0 +1,235 @@ + + + + {{ template "meta.template.html" . }} + {{ template "grass.css" . }} + + + +
+

Grass

+

+ Hey there 👋 I'd like to help you figure out how much to water your + grass. This is trickier than it may seem. The amount changes based on + the grass type and natural rainfall. Overwatering wastes resources; + hurts your grass; and may cause mold, fungus, and moss to grow in your + yard. Underwatering will cause your grass to go dormant and eventually + die. +
+
+ To combat these problems, I'll use your area's forecast along with some + information about your lawn's grass to create a custom watering plan. +
+
+ To get started, click the button below to grant the page access to your + latitude and longitude. I'll send this over to + weather.gov + to get your seven day forecast. + + +

+ + + + + + + + +
+ + {{ template "grass.js" . }} + + diff --git a/meta.template.html b/meta.template.html new file mode 100644 index 0000000..2c0d69b --- /dev/null +++ b/meta.template.html @@ -0,0 +1,32 @@ + + + + +{{ if eq .Title "" }} +Justin Fuller + + +{{ else }} +{{ .Title }} | Justin Fuller + + +{{ end }} + +{{ if eq .Meta "" }} + + + + +{{ else }} + + + + +{{ end }} + + + +