From 70e7afcf39c5889a8eeb814051932fbca7598294 Mon Sep 17 00:00:00 2001 From: nocci Date: Fri, 2 May 2025 12:53:27 +0200 Subject: [PATCH] start building PWA --- setup.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/setup.sh b/setup.sh index 449f080..e78dd38 100644 --- a/setup.sh +++ b/setup.sh @@ -942,6 +942,58 @@ echo "✅ Database migration completed!" SCRIPT_END chmod +x ../upgrade.sh +# Manifest for PWA +cat < static/manifest.json +{ + "name": "Game Key Manager", + "short_name": "GameKeys", + "start_url": "/", + "display": "standalone", + "background_color": "#212529", + "theme_color": "#212529", + "description": "Manage Steam/GOG keys easily!", + "icons": [ + { + "src": "/static/logo_small.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any maskable" + }, + { + "src": "/static/logo.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} +MANIFEST_END + +# Service Worker +cat < static/serviceworker.js +const CACHE_NAME = 'game-key-manager-v1'; +const ASSETS = [ + '/', + '/static/style.css', + '/static/logo.png', + '/static/logo_small.png', + '/static/gog_logo.png' +]; + +self.addEventListener('install', (event) => { + event.waitUntil( + caches.open(CACHE_NAME) + .then(cache => cache.addAll(ASSETS)) + ); +}); + +self.addEventListener('fetch', (event) => { + event.respondWith( + caches.match(event.request) + .then(cachedResponse => cachedResponse || fetch(event.request)) + ); +}); +SW_END + # 9. Templates mkdir -p templates static @@ -957,6 +1009,8 @@ cat < templates/base.html {{ _('Game Key Manager') }} + +