diff --git a/index.html b/index.html index 40db0bbe..5e5b92b2 100644 --- a/index.html +++ b/index.html @@ -10,10 +10,19 @@ + + + + + + + + +
diff --git a/static/manifest.json b/static/manifest.json new file mode 100644 index 00000000..335b37b4 --- /dev/null +++ b/static/manifest.json @@ -0,0 +1,29 @@ +{ + "name": "☽ D̷i̵s̴q̴ordi̴a ☾", + "short_name": "☽ D̷i̵s̴q̴ordi̴a ☾", + "start_url": "/", + "display": "standalone", + "background_color": "#000000", + "theme_color": "#000000", + "orientation": "portrait-primary", + "icons": [ + { + "src": "/images/icons/icon-128x128.png", + "sizes": "128x128", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "/images/icons/icon-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "/images/icons/icon-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable any" + } + ] +} diff --git a/static/service-worker.js b/static/service-worker.js new file mode 100644 index 00000000..ec100569 --- /dev/null +++ b/static/service-worker.js @@ -0,0 +1,39 @@ +// Installing service worker +const CACHE_NAME = 'Disqordia'; + +/* Add relative URL of all the static content you want to store in + * cache storage (this will help us use our app offline)*/ +let resourcesToCache = ["/", "/static/font/css/fontello.css", "/static/font/css/animation.css", "/static/font/tiresias.css", "/static/font/css/lato.css", "/static/mfm.css", "/favicon.png", "/static/css/app.d7c75a48f7d627e0493f.css", "/static/js/vendors~app.4600ad9d6a3c807e6688.js", "/static/js/app.afaee31b8c11ba3c67aa.js"]; + +self.addEventListener("install", e=>{ + e.waitUntil( + caches.open(CACHE_NAME).then(cache =>{ + return cache.addAll(resourcesToCache); + }) + ); +}); + +// Cache and return requests +self.addEventListener("fetch", e=>{ + e.respondWith( + caches.match(e.request).then(response=>{ + return response || fetch(e.request); + }) + ); +}); + +// Update a service worker +const cacheWhitelist = ['Disqordia']; +self.addEventListener('activate', event => { + event.waitUntil( + caches.keys().then(cacheNames => { + return Promise.all( + cacheNames.map(cacheName => { + if (cacheWhitelist.indexOf(cacheName) === -1) { + return caches.delete(cacheName); + } + }) + ); + }) + ); + });