feat: PWA support with hockey puck icon
Adds full PWA compliance: web app manifest, service worker with cache-first static / network-first scoreboard strategy, and a generated hockey puck icon (512, 192, 180, 32px) on the app's dark navy background. Includes all required meta tags for iOS standalone mode and a /favicon.ico route. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
BIN
app/static/icon-180x180.png
Normal file
BIN
app/static/icon-180x180.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
app/static/icon-192x192.png
Normal file
BIN
app/static/icon-192x192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
app/static/icon-32x32.png
Normal file
BIN
app/static/icon-32x32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 281 B |
BIN
app/static/icon-512x512.png
Normal file
BIN
app/static/icon-512x512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
24
app/static/manifest.json
Normal file
24
app/static/manifest.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "NHL Scoreboard",
|
||||
"short_name": "NHL Scores",
|
||||
"description": "Live NHL game scores ranked by hype",
|
||||
"start_url": "/",
|
||||
"display": "standalone",
|
||||
"background_color": "#0f172a",
|
||||
"theme_color": "#0f172a",
|
||||
"orientation": "portrait-primary",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/static/icon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/static/icon-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -240,4 +240,9 @@ function autoRefresh() {
|
||||
window.addEventListener('load', () => {
|
||||
autoRefresh();
|
||||
setInterval(tickClocks, 1000);
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('/sw.js').catch(err => {
|
||||
console.warn('Service worker registration failed:', err);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
49
app/static/sw.js
Normal file
49
app/static/sw.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const CACHE = 'nhl-scoreboard-v1';
|
||||
const PRECACHE = [
|
||||
'/',
|
||||
'/static/styles.css',
|
||||
'/static/script.js',
|
||||
'/static/icon-192x192.png',
|
||||
'/static/icon-512x512.png',
|
||||
'/manifest.json',
|
||||
];
|
||||
|
||||
self.addEventListener('install', event => {
|
||||
event.waitUntil(caches.open(CACHE).then(c => c.addAll(PRECACHE)));
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener('activate', event => {
|
||||
event.waitUntil(
|
||||
caches.keys().then(keys =>
|
||||
Promise.all(keys.filter(k => k !== CACHE).map(k => caches.delete(k)))
|
||||
)
|
||||
);
|
||||
self.clients.claim();
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', event => {
|
||||
const { pathname } = new URL(event.request.url);
|
||||
|
||||
// Network-first for the live scoreboard API — stale data is useless
|
||||
if (pathname === '/scoreboard') {
|
||||
event.respondWith(
|
||||
fetch(event.request).catch(() => caches.match(event.request))
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Cache-first for everything else (static assets, shell)
|
||||
event.respondWith(
|
||||
caches.match(event.request).then(cached => {
|
||||
if (cached) return cached;
|
||||
return fetch(event.request).then(response => {
|
||||
if (response.ok) {
|
||||
const clone = response.clone();
|
||||
caches.open(CACHE).then(c => c.put(event.request, clone));
|
||||
}
|
||||
return response;
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user