From 709919a9624ed4336e9e5ae382e29cd34c795a82 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 3 May 2019 20:43:46 +0200 Subject: Experimental PWA support (#13) --- public/service-worker.js | 47 +++++++++++++++++++++++++++++++++++ public/static/icons/icon-128x128.png | Bin 0 -> 1456 bytes public/static/icons/icon-144x144.png | Bin 0 -> 1565 bytes public/static/icons/icon-152x152.png | Bin 0 -> 1738 bytes public/static/icons/icon-192x192.png | Bin 0 -> 2139 bytes public/static/icons/icon-256x256.png | Bin 0 -> 2923 bytes public/static/icons/icon-512x512.png | Bin 0 -> 6611 bytes public/static/manifest.json | 34 +++++++++++++++++++++++++ 8 files changed, 81 insertions(+) create mode 100644 public/service-worker.js create mode 100644 public/static/icons/icon-128x128.png create mode 100644 public/static/icons/icon-144x144.png create mode 100644 public/static/icons/icon-152x152.png create mode 100644 public/static/icons/icon-192x192.png create mode 100644 public/static/icons/icon-256x256.png create mode 100644 public/static/icons/icon-512x512.png create mode 100644 public/static/manifest.json (limited to 'public') diff --git a/public/service-worker.js b/public/service-worker.js new file mode 100644 index 0000000..2b5c556 --- /dev/null +++ b/public/service-worker.js @@ -0,0 +1,47 @@ +const CACHE_NAME = 'static-cache-v10'; +const FILES_TO_CACHE = [ + '/offline.html', + '/static/v10/css/materialize.min.css', + '/static/v10/css/material-icons.css', + '/static/v10/css/local.css', + '/static/v10/js/jquery-2.2.4.min.js', + '/static/v10/js/materialize.min.js', + '/static/v10/js/travelynx-actions.min.js', +]; + +self.addEventListener('install', (evt) => { + evt.waitUntil( + caches.open(CACHE_NAME).then((cache) => { + return cache.addAll(FILES_TO_CACHE); + }) + ); + self.skipWaiting(); +}); + +self.addEventListener('activate', (evt) => { + evt.waitUntil( + caches.keys().then((keyList) => { + return Promise.all(keyList.map((key) => { + if (key !== CACHE_NAME) { + return caches.delete(key); + } + })); + }) + ); + self.clients.claim(); +}); + +self.addEventListener('fetch', (evt) => { + if (evt.request.mode !== 'navigate') { + return; + } + evt.respondWith( + fetch(evt.request) + .catch(() => { + return caches.open(CACHE_NAME) + .then((cache) => { + return cache.match('offline.html'); + }); + }) + ); +}); diff --git a/public/static/icons/icon-128x128.png b/public/static/icons/icon-128x128.png new file mode 100644 index 0000000..2dfa5b4 Binary files /dev/null and b/public/static/icons/icon-128x128.png differ diff --git a/public/static/icons/icon-144x144.png b/public/static/icons/icon-144x144.png new file mode 100644 index 0000000..151e555 Binary files /dev/null and b/public/static/icons/icon-144x144.png differ diff --git a/public/static/icons/icon-152x152.png b/public/static/icons/icon-152x152.png new file mode 100644 index 0000000..a5a034d Binary files /dev/null and b/public/static/icons/icon-152x152.png differ diff --git a/public/static/icons/icon-192x192.png b/public/static/icons/icon-192x192.png new file mode 100644 index 0000000..a00418e Binary files /dev/null and b/public/static/icons/icon-192x192.png differ diff --git a/public/static/icons/icon-256x256.png b/public/static/icons/icon-256x256.png new file mode 100644 index 0000000..e9493a3 Binary files /dev/null and b/public/static/icons/icon-256x256.png differ diff --git a/public/static/icons/icon-512x512.png b/public/static/icons/icon-512x512.png new file mode 100644 index 0000000..074e828 Binary files /dev/null and b/public/static/icons/icon-512x512.png differ diff --git a/public/static/manifest.json b/public/static/manifest.json new file mode 100644 index 0000000..7e856f2 --- /dev/null +++ b/public/static/manifest.json @@ -0,0 +1,34 @@ +{ + "name": "travelynx", + "short_name": "travelynx", + "scope": "/", + "icons": [{ + "src": "/static/icons/icon-128x128.png", + "sizes": "128x128", + "type": "image/png" + }, { + "src": "/static/icons/icon-144x144.png", + "sizes": "144x144", + "type": "image/png" + }, { + "src": "/static/icons/icon-152x152.png", + "sizes": "152x152", + "type": "image/png" + }, { + "src": "/static/icons/icon-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, { + "src": "/static/icons/icon-256x256.png", + "sizes": "256x256", + "type": "image/png" + }, { + "src": "/static/icons/icon-512x512.png", + "sizes": "512x512", + "type": "image/png" + }], + "start_url": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#673ab7" +} -- cgit v1.2.3