BIN
spa/public/apple-touch-icon.png
Normal file
BIN
spa/public/apple-touch-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
spa/public/favicon.ico
Normal file
BIN
spa/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
spa/public/logo.png
Normal file
BIN
spa/public/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
BIN
spa/public/logo192.png
Normal file
BIN
spa/public/logo192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
spa/public/logo512.png
Normal file
BIN
spa/public/logo512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
39
spa/public/manifest.json
Normal file
39
spa/public/manifest.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "k-mood — Mood Tracking Journal",
|
||||
"short_name": "k-mood",
|
||||
"description": "Self-hosted mood tracking journal with activities, photos, and voice memos.",
|
||||
"start_url": "/",
|
||||
"display": "standalone",
|
||||
"orientation": "portrait",
|
||||
"theme_color": "#0f0f1e",
|
||||
"background_color": "#0f0f1e",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "256x256",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "apple-touch-icon.png",
|
||||
"sizes": "180x180",
|
||||
"type": "image/png"
|
||||
}
|
||||
],
|
||||
"categories": ["health", "lifestyle", "productivity"]
|
||||
}
|
||||
4
spa/public/robots.txt
Normal file
4
spa/public/robots.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
User-agent: *
|
||||
Allow: /
|
||||
|
||||
Sitemap: /sitemap.xml
|
||||
85
spa/public/sw.js
Normal file
85
spa/public/sw.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const CACHE_NAME = "k-mood-v1"
|
||||
const STATIC_ASSETS = [
|
||||
"/",
|
||||
"/manifest.json",
|
||||
"/logo192.png",
|
||||
"/logo512.png",
|
||||
"/favicon.ico",
|
||||
]
|
||||
|
||||
self.addEventListener("install", (event) => {
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME).then((cache) => cache.addAll(STATIC_ASSETS))
|
||||
)
|
||||
self.skipWaiting()
|
||||
})
|
||||
|
||||
self.addEventListener("activate", (event) => {
|
||||
event.waitUntil(
|
||||
caches
|
||||
.keys()
|
||||
.then((keys) =>
|
||||
Promise.all(
|
||||
keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k))
|
||||
)
|
||||
)
|
||||
)
|
||||
self.clients.claim()
|
||||
})
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
const url = new URL(event.request.url)
|
||||
|
||||
if (url.pathname.startsWith("/api/")) return
|
||||
|
||||
if (event.request.mode === "navigate") {
|
||||
event.respondWith(
|
||||
fetch(event.request)
|
||||
.then((response) => {
|
||||
const clone = response.clone()
|
||||
caches
|
||||
.open(CACHE_NAME)
|
||||
.then((cache) => cache.put(event.request, clone))
|
||||
return response
|
||||
})
|
||||
.catch(() => caches.match("/"))
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
event.respondWith(
|
||||
caches.match(event.request).then((cached) => {
|
||||
const fetched = fetch(event.request).then((response) => {
|
||||
const clone = response.clone()
|
||||
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone))
|
||||
return response
|
||||
})
|
||||
return cached || fetched
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
self.addEventListener("push", (event) => {
|
||||
const data = event.data?.json() ?? {}
|
||||
const title = data.title || "K-Mood"
|
||||
const options = {
|
||||
body: data.body || "How are you feeling?",
|
||||
icon: "/logo192.png",
|
||||
badge: "/logo192.png",
|
||||
data: { url: data.url || "/" },
|
||||
}
|
||||
event.waitUntil(self.registration.showNotification(title, options))
|
||||
})
|
||||
|
||||
self.addEventListener("notificationclick", (event) => {
|
||||
event.notification.close()
|
||||
const url = event.notification.data?.url || "/"
|
||||
event.waitUntil(
|
||||
clients.matchAll({ type: "window" }).then((windowClients) => {
|
||||
for (const client of windowClients) {
|
||||
if (client.url.includes(url) && "focus" in client) return client.focus()
|
||||
}
|
||||
return clients.openWindow(url)
|
||||
})
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user