From c68ebc39096d93867058f011b4e6313f53128819 Mon Sep 17 00:00:00 2001 From: Kit La Touche Date: Tue, 5 Nov 2024 22:22:22 -0500 Subject: Start to make this a PWA --- ui/app.html | 1 + ui/routes/(app)/+layout.svelte | 2 +- ui/routes/+layout.svelte | 2 +- ui/service-worker.js | 35 ++++++++++++++++++++++++++++++++++ ui/static/manifest.json | 43 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 ui/service-worker.js create mode 100644 ui/static/manifest.json (limited to 'ui') diff --git a/ui/app.html b/ui/app.html index 51a6780..4dc66f4 100644 --- a/ui/app.html +++ b/ui/app.html @@ -4,6 +4,7 @@ + %sveltekit.head% diff --git a/ui/routes/(app)/+layout.svelte b/ui/routes/(app)/+layout.svelte index ae3dc6a..2725c65 100644 --- a/ui/routes/(app)/+layout.svelte +++ b/ui/routes/(app)/+layout.svelte @@ -55,7 +55,7 @@ - understory + pilcrow {#if loading} diff --git a/ui/routes/+layout.svelte b/ui/routes/+layout.svelte index d786389..da5bbe0 100644 --- a/ui/routes/+layout.svelte +++ b/ui/routes/+layout.svelte @@ -28,7 +28,7 @@ logo - understory + pilcrow {#if $currentUser} diff --git a/ui/service-worker.js b/ui/service-worker.js new file mode 100644 index 0000000..e29fab3 --- /dev/null +++ b/ui/service-worker.js @@ -0,0 +1,35 @@ +/// +/// +/// +/// + +import { build, files, version } from '$service-worker'; + +// Create a unique cache name for this deployment +const CACHE = `cache-${version}`; + +const ASSETS = [ + ...build, // the app itself + ...files // everything in `static` +]; + +self.addEventListener('install', (event) => { + // Create a new cache and add all files to it + async function addFilesToCache() { + const cache = await caches.open(CACHE); + await cache.addAll(ASSETS); + } + + event.waitUntil(addFilesToCache()); +}); + +self.addEventListener('activate', (event) => { + // Remove previous cached data from disk + async function deleteOldCaches() { + for (const key of await caches.keys()) { + if (key !== CACHE) await caches.delete(key); + } + } + + event.waitUntil(deleteOldCaches()); +}); diff --git a/ui/static/manifest.json b/ui/static/manifest.json new file mode 100644 index 0000000..2d4cf39 --- /dev/null +++ b/ui/static/manifest.json @@ -0,0 +1,43 @@ +{ + "name": "Pilcrow", + "short_name": "Pilcrow", + "start_url": "index.html", + "display": "standalone", + "background_color": "#fdfdfd", + "theme_color": "#db4938", + "orientation": "portrait-primary", + "icons": [ + { + "src": "/favicon.png", + "type": "image/png", "sizes": "72x72" + }, + { + "src": "/favicon.png", + "type": "image/png", "sizes": "96x96" + }, + { + "src": "/favicon.png", + "type": "image/png","sizes": "128x128" + }, + { + "src": "/favicon.png", + "type": "image/png", "sizes": "144x144" + }, + { + "src": "/favicon.png", + "type": "image/png", "sizes": "152x152" + }, + { + "src": "/favicon.png", + "type": "image/png", "sizes": "192x192" + }, + { + "src": "/favicon.png", + "type": "image/png", "sizes": "384x384" + }, + { + "src": "/favicon.png", + "type": "image/png", "sizes": "512x512" + } + ] +} -- cgit v1.2.3 From 8751155e24f020802d1c387af19318edceaa39d2 Mon Sep 17 00:00:00 2001 From: Kit La Touche Date: Wed, 6 Nov 2024 22:59:29 -0500 Subject: Add comment explaining why this isn't happy in Firefox --- ui/service-worker.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ui') diff --git a/ui/service-worker.js b/ui/service-worker.js index e29fab3..033c8d9 100644 --- a/ui/service-worker.js +++ b/ui/service-worker.js @@ -3,6 +3,12 @@ /// /// +// Because of this line, this service worker won't run in dev mode in Firefox. +// Only Safari, Edge, Chrome can run it at the moment, because only they +// support modules in service workers. +// +// That's okay! If you run `tools/run` with HI_DEV unset, you will get the +// bundled version, and can work on it. Or just use Safari. import { build, files, version } from '$service-worker'; // Create a unique cache name for this deployment -- cgit v1.2.3 From 27fb577abab4dba7c3edafc396421644ee9e7c5e Mon Sep 17 00:00:00 2001 From: Kit La Touche Date: Fri, 8 Nov 2024 22:06:59 -0500 Subject: Fix start path in manifest --- ui/static/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/static/manifest.json b/ui/static/manifest.json index 2d4cf39..29e3e90 100644 --- a/ui/static/manifest.json +++ b/ui/static/manifest.json @@ -1,7 +1,7 @@ { "name": "Pilcrow", "short_name": "Pilcrow", - "start_url": "index.html", + "start_url": "/", "display": "standalone", "background_color": "#fdfdfd", "theme_color": "#db4938", -- cgit v1.2.3 From 9c0fcc5534b77d9fd1d712c9472c57d01c8c5274 Mon Sep 17 00:00:00 2001 From: Kit La Touche Date: Fri, 8 Nov 2024 22:08:02 -0500 Subject: Remove stray reference to "hi" --- ui/service-worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/service-worker.js b/ui/service-worker.js index 033c8d9..fc619d9 100644 --- a/ui/service-worker.js +++ b/ui/service-worker.js @@ -7,7 +7,7 @@ // Only Safari, Edge, Chrome can run it at the moment, because only they // support modules in service workers. // -// That's okay! If you run `tools/run` with HI_DEV unset, you will get the +// That's okay! If you run `tools/run` with PILCROW_DEV unset, you will get the // bundled version, and can work on it. Or just use Safari. import { build, files, version } from '$service-worker'; -- cgit v1.2.3 From a784af6f5f125ec9188801dade41c207d8111e93 Mon Sep 17 00:00:00 2001 From: Kit La Touche Date: Sat, 9 Nov 2024 22:46:44 -0500 Subject: Replace favicon and logo with Pilcrow logo It's not very legible at small sizes, but it's a first draft, it'll be fine. --- ui/lib/assets/logo.png | Bin 137101 -> 92469 bytes ui/static/favicon.png | Bin 137101 -> 92469 bytes 2 files changed, 0 insertions(+), 0 deletions(-) (limited to 'ui') diff --git a/ui/lib/assets/logo.png b/ui/lib/assets/logo.png index 5df6b4e..4b35d9b 100644 Binary files a/ui/lib/assets/logo.png and b/ui/lib/assets/logo.png differ diff --git a/ui/static/favicon.png b/ui/static/favicon.png index 5df6b4e..4b35d9b 100644 Binary files a/ui/static/favicon.png and b/ui/static/favicon.png differ -- cgit v1.2.3 From 541e994595dc7fe02b9f21640d1f2c754fc6514d Mon Sep 17 00:00:00 2001 From: Kit La Touche Date: Sat, 9 Nov 2024 22:53:04 -0500 Subject: Add extra images macOS PWAs expect --- ui/static/apple-touch-icon-precomposed.png | Bin 0 -> 92469 bytes ui/static/apple-touch-icon.png | Bin 0 -> 92469 bytes ui/static/favicon.ico | Bin 0 -> 92469 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 ui/static/apple-touch-icon-precomposed.png create mode 100644 ui/static/apple-touch-icon.png create mode 100644 ui/static/favicon.ico (limited to 'ui') diff --git a/ui/static/apple-touch-icon-precomposed.png b/ui/static/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..4b35d9b Binary files /dev/null and b/ui/static/apple-touch-icon-precomposed.png differ diff --git a/ui/static/apple-touch-icon.png b/ui/static/apple-touch-icon.png new file mode 100644 index 0000000..4b35d9b Binary files /dev/null and b/ui/static/apple-touch-icon.png differ diff --git a/ui/static/favicon.ico b/ui/static/favicon.ico new file mode 100644 index 0000000..4b35d9b Binary files /dev/null and b/ui/static/favicon.ico differ -- cgit v1.2.3 From dfca11aceffaafc105509a2800d70eb9c9bed2e7 Mon Sep 17 00:00:00 2001 From: Kit La Touche Date: Mon, 11 Nov 2024 13:51:42 -0500 Subject: Actually return things in the cache, from the cache Service worker basics I guess. --- ui/service-worker.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ui') diff --git a/ui/service-worker.js b/ui/service-worker.js index fc619d9..e2143b3 100644 --- a/ui/service-worker.js +++ b/ui/service-worker.js @@ -39,3 +39,16 @@ self.addEventListener('activate', (event) => { event.waitUntil(deleteOldCaches()); }); + +// The simplest possible use of the caches above: +async function cacheFirst(request) { + const responseFromCache = await caches.match(request); + if (responseFromCache) { + return responseFromCache; + } + return fetch(request); +}; + +self.addEventListener("fetch", (event) => { + event.respondWith(cacheFirst(event.request)); +}); -- cgit v1.2.3 From c82e40caa38edf02ebda49be6ce42afb0e0907c4 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Mon, 11 Nov 2024 23:04:35 -0500 Subject: npm run format --- ui/service-worker.js | 36 ++++++++++++++++++------------------ ui/static/manifest.json | 24 ++++++++++++++++-------- 2 files changed, 34 insertions(+), 26 deletions(-) (limited to 'ui') diff --git a/ui/service-worker.js b/ui/service-worker.js index e2143b3..9855a73 100644 --- a/ui/service-worker.js +++ b/ui/service-worker.js @@ -15,29 +15,29 @@ import { build, files, version } from '$service-worker'; const CACHE = `cache-${version}`; const ASSETS = [ - ...build, // the app itself - ...files // everything in `static` + ...build, // the app itself + ...files // everything in `static` ]; self.addEventListener('install', (event) => { - // Create a new cache and add all files to it - async function addFilesToCache() { - const cache = await caches.open(CACHE); - await cache.addAll(ASSETS); - } + // Create a new cache and add all files to it + async function addFilesToCache() { + const cache = await caches.open(CACHE); + await cache.addAll(ASSETS); + } - event.waitUntil(addFilesToCache()); + event.waitUntil(addFilesToCache()); }); self.addEventListener('activate', (event) => { - // Remove previous cached data from disk - async function deleteOldCaches() { - for (const key of await caches.keys()) { - if (key !== CACHE) await caches.delete(key); - } - } - - event.waitUntil(deleteOldCaches()); + // Remove previous cached data from disk + async function deleteOldCaches() { + for (const key of await caches.keys()) { + if (key !== CACHE) await caches.delete(key); + } + } + + event.waitUntil(deleteOldCaches()); }); // The simplest possible use of the caches above: @@ -47,8 +47,8 @@ async function cacheFirst(request) { return responseFromCache; } return fetch(request); -}; +} -self.addEventListener("fetch", (event) => { +self.addEventListener('fetch', (event) => { event.respondWith(cacheFirst(event.request)); }); diff --git a/ui/static/manifest.json b/ui/static/manifest.json index 29e3e90..938955e 100644 --- a/ui/static/manifest.json +++ b/ui/static/manifest.json @@ -9,35 +9,43 @@ "icons": [ { "src": "/favicon.png", - "type": "image/png", "sizes": "72x72" + "type": "image/png", + "sizes": "72x72" }, { "src": "/favicon.png", - "type": "image/png", "sizes": "96x96" + "type": "image/png", + "sizes": "96x96" }, { "src": "/favicon.png", - "type": "image/png","sizes": "128x128" + "type": "image/png", + "sizes": "128x128" }, { "src": "/favicon.png", - "type": "image/png", "sizes": "144x144" + "type": "image/png", + "sizes": "144x144" }, { "src": "/favicon.png", - "type": "image/png", "sizes": "152x152" + "type": "image/png", + "sizes": "152x152" }, { "src": "/favicon.png", - "type": "image/png", "sizes": "192x192" + "type": "image/png", + "sizes": "192x192" }, { "src": "/favicon.png", - "type": "image/png", "sizes": "384x384" + "type": "image/png", + "sizes": "384x384" }, { "src": "/favicon.png", - "type": "image/png", "sizes": "512x512" + "type": "image/png", + "sizes": "512x512" } ] } -- cgit v1.2.3 From 2fb328089f01776e5bb553a1d50a061396588c8c Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Mon, 11 Nov 2024 23:11:01 -0500 Subject: Match chrome colour to top bar colour --- ui/static/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/static/manifest.json b/ui/static/manifest.json index 938955e..5d735d0 100644 --- a/ui/static/manifest.json +++ b/ui/static/manifest.json @@ -4,7 +4,7 @@ "start_url": "/", "display": "standalone", "background_color": "#fdfdfd", - "theme_color": "#db4938", + "theme_color": "#2c3656", "orientation": "portrait-primary", "icons": [ { -- cgit v1.2.3