aboutsummaryrefslogtreecommitdiffhomepage
path: root/public
diff options
context:
space:
mode:
Diffstat (limited to 'public')
-rw-r--r--public/icons/icon-192.pngbin0 -> 3897 bytes
-rw-r--r--public/icons/icon-512.pngbin0 -> 14112 bytes
-rw-r--r--public/icons/icon.svg6
-rw-r--r--public/kodaira-data/parks/LICENSE.txt10
-rw-r--r--public/manifest.webmanifest32
-rw-r--r--public/sw.js70
6 files changed, 118 insertions, 0 deletions
diff --git a/public/icons/icon-192.png b/public/icons/icon-192.png
new file mode 100644
index 0000000..1ba1e59
--- /dev/null
+++ b/public/icons/icon-192.png
Binary files differ
diff --git a/public/icons/icon-512.png b/public/icons/icon-512.png
new file mode 100644
index 0000000..cb56518
--- /dev/null
+++ b/public/icons/icon-512.png
Binary files differ
diff --git a/public/icons/icon.svg b/public/icons/icon.svg
new file mode 100644
index 0000000..9b105c1
--- /dev/null
+++ b/public/icons/icon.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512">
+ <rect width="512" height="512" rx="96" fill="#1b5e20"/>
+ <path fill="#fff" d="M256 72c-63 0-114 51-114 114 0 42 23 79 57 99v53h-47l104 104 104-104h-47v-53c34-20 57-57 57-99 0-63-51-114-114-114z"/>
+ <rect x="238" y="340" width="36" height="104" rx="14" fill="#fff"/>
+ <rect x="140" y="430" width="232" height="20" rx="10" fill="#fff" opacity="0.85"/>
+</svg>
diff --git a/public/kodaira-data/parks/LICENSE.txt b/public/kodaira-data/parks/LICENSE.txt
new file mode 100644
index 0000000..6149587
--- /dev/null
+++ b/public/kodaira-data/parks/LICENSE.txt
@@ -0,0 +1,10 @@
+小平市の公園一覧 手入力ポリゴン
+
+作成: 安竹洋平(https://yasutakeyohei.com/)
+ライセンス: Creative Commons Attribution 4.0 International (CC BY 4.0)
+https://creativecommons.org/licenses/by/4.0/deed.ja
+
+注記:
+このポリゴンは正確な境界座標ではありません。参考としてご利用ください。
+出典として「安竹洋平(https://yasutakeyohei.com/)」を明示すれば、自由に利用できます。
+OSM由来のデータはOpenStreetMapのODbLライセンスです。
diff --git a/public/manifest.webmanifest b/public/manifest.webmanifest
new file mode 100644
index 0000000..91af084
--- /dev/null
+++ b/public/manifest.webmanifest
@@ -0,0 +1,32 @@
+{
+ "id": "/kodaira-data/parks/",
+ "name": "小平市の公園一覧",
+ "short_name": "小平市公園",
+ "description": "小平市内の公園・公共施設・近隣公園を検索できる一覧",
+ "lang": "ja",
+ "start_url": "/kodaira-data/parks/",
+ "scope": "/",
+ "display": "standalone",
+ "background_color": "#ffffff",
+ "theme_color": "#1b5e20",
+ "icons": [
+ {
+ "src": "/icons/icon-192.png",
+ "sizes": "192x192",
+ "type": "image/png",
+ "purpose": "any"
+ },
+ {
+ "src": "/icons/icon-512.png",
+ "sizes": "512x512",
+ "type": "image/png",
+ "purpose": "any"
+ },
+ {
+ "src": "/icons/icon-512.png",
+ "sizes": "512x512",
+ "type": "image/png",
+ "purpose": "maskable"
+ }
+ ]
+}
diff --git a/public/sw.js b/public/sw.js
new file mode 100644
index 0000000..99af941
--- /dev/null
+++ b/public/sw.js
@@ -0,0 +1,70 @@
+const CACHE = "kodaira-parks-v1";
+const APP_SHELL = [
+ "/kodaira-data/parks/",
+ "/manifest.webmanifest",
+ "/icons/icon-192.png",
+ "/icons/icon-512.png",
+];
+
+self.addEventListener("install", (event) => {
+ event.waitUntil(
+ caches
+ .open(CACHE)
+ .then((cache) => cache.addAll(APP_SHELL))
+ .then(() => self.skipWaiting()),
+ );
+});
+
+self.addEventListener("activate", (event) => {
+ event.waitUntil(
+ caches
+ .keys()
+ .then((keys) =>
+ Promise.all(keys.filter((key) => key !== CACHE).map((key) => caches.delete(key))),
+ )
+ .then(() => self.clients.claim()),
+ );
+});
+
+self.addEventListener("fetch", (event) => {
+ const request = event.request;
+ if (request.method !== "GET") return;
+
+ const url = new URL(request.url);
+ // OSMのタイルなど外部オリジンのものはキャッシュしない。
+ if (url.origin !== self.location.origin) return;
+
+ // ページ遷移はネットワーク優先。オフライン時はキャッシュ→公園ページ。
+ if (request.mode === "navigate") {
+ event.respondWith(
+ fetch(request)
+ .then((response) => {
+ const copy = response.clone();
+ caches.open(CACHE).then((cache) => cache.put(request, copy));
+ return response;
+ })
+ .catch(() =>
+ caches
+ .match(request)
+ .then((cached) => cached || caches.match("/kodaira-data/parks/")),
+ ),
+ );
+ return;
+ }
+
+ // それ以外はキャッシュ優先。取得できたらキャッシュを更新する。
+ event.respondWith(
+ caches.match(request).then((cached) => {
+ const network = fetch(request)
+ .then((response) => {
+ if (response.ok) {
+ const copy = response.clone();
+ caches.open(CACHE).then((cache) => cache.put(request, copy));
+ }
+ return response;
+ })
+ .catch(() => cached);
+ return cached || network;
+ }),
+ );
+});