diff --git a/client/pages/_document.js b/client/pages/_document.js
index df030960a..92e2c2949 100644
--- a/client/pages/_document.js
+++ b/client/pages/_document.js
@@ -39,6 +39,8 @@ class AppDocument extends Document {
+
+
@@ -59,6 +61,17 @@ class AppDocument extends Document {
}}
/>
+
+
diff --git a/server/offline/sw.js b/server/offline/sw.js
new file mode 100644
index 000000000..0c6c090bb
--- /dev/null
+++ b/server/offline/sw.js
@@ -0,0 +1,45 @@
+//This is the "Offline copy of pages" service worker
+
+//Install stage sets up the index page (home page) in the cache and opens a new cache
+const {self} = window;
+
+self.addEventListener('install', function(event) {
+ var indexPage = new Request('index.html');
+ event.waitUntil(
+ fetch(indexPage).then(function(response) {
+ return caches.open('kutt-offline').then(function(cache) {
+ console.log('Kutt Cached index page during Install' + response.url);
+ return cache.put(indexPage, response);
+ });
+ }));
+});
+
+//If any fetch fails, it will look for the request in the cache and serve it from there first
+self.addEventListener('fetch', function(event) {
+ var updateCache = function(request) {
+ return caches.open('kutt-offline').then(function(cache) {
+ return fetch(request).then(function(response) {
+ console.log('Kutt add page to offline' + response.url)
+ return cache.put(request, response);
+ });
+ });
+ };
+
+ event.waitUntil(updateCache(event.request));
+
+ event.respondWith(
+ fetch(event.request).catch(function(error) {
+ console.log('Kutt Network request Failed. Serving content from cache: ' + error);
+
+ //Check to see if you have it in the cache
+ //Return response
+ //If not in the cache, then return error page
+ return caches.open('kutt-offline').then(function(cache) {
+ return cache.match(event.request).then(function(matching) {
+ var report = !matching || matching.status == 404 ? Promise.reject(new Error('no-match')) : matching;
+ return report
+ });
+ });
+ })
+ );
+})
\ No newline at end of file
diff --git a/server/server.js b/server/server.js
index f942658a6..362af228c 100644
--- a/server/server.js
+++ b/server/server.js
@@ -86,6 +86,9 @@ app.prepare().then(() => {
server.get('/verify/:verificationToken?', catchErrors(auth.verify), (req, res) =>
app.render(req, res, '/verify', req.user)
);
+ server.get('/sw.js', (_req, res) => {
+ res.sendFile(__dirname + '/offline/sw.js')
+});
/* User and authentication */
server.post('/api/auth/signup', validationCriterias, validateBody, catchErrors(auth.signup));
diff --git a/static/images/icons/icon-128x128.png b/static/images/icons/icon-128x128.png
new file mode 100644
index 000000000..9f11d26e2
Binary files /dev/null and b/static/images/icons/icon-128x128.png differ
diff --git a/static/images/icons/icon-144x144.png b/static/images/icons/icon-144x144.png
new file mode 100644
index 000000000..95a1815f2
Binary files /dev/null and b/static/images/icons/icon-144x144.png differ
diff --git a/static/images/icons/icon-152x152.png b/static/images/icons/icon-152x152.png
new file mode 100644
index 000000000..4b5323303
Binary files /dev/null and b/static/images/icons/icon-152x152.png differ
diff --git a/static/images/icons/icon-192x192.png b/static/images/icons/icon-192x192.png
new file mode 100644
index 000000000..796aa7b69
Binary files /dev/null and b/static/images/icons/icon-192x192.png differ
diff --git a/static/images/icons/icon-384x384.png b/static/images/icons/icon-384x384.png
new file mode 100644
index 000000000..edd2c6b5c
Binary files /dev/null and b/static/images/icons/icon-384x384.png differ
diff --git a/static/images/icons/icon-512x512.png b/static/images/icons/icon-512x512.png
new file mode 100644
index 000000000..d0df2465c
Binary files /dev/null and b/static/images/icons/icon-512x512.png differ
diff --git a/static/images/icons/icon-72x72.png b/static/images/icons/icon-72x72.png
new file mode 100644
index 000000000..e2375a209
Binary files /dev/null and b/static/images/icons/icon-72x72.png differ
diff --git a/static/images/icons/icon-96x96.png b/static/images/icons/icon-96x96.png
new file mode 100644
index 000000000..b2dfce979
Binary files /dev/null and b/static/images/icons/icon-96x96.png differ
diff --git a/static/manifest.webmanifest b/static/manifest.webmanifest
new file mode 100644
index 000000000..0e4fd11bd
--- /dev/null
+++ b/static/manifest.webmanifest
@@ -0,0 +1,53 @@
+{
+ "name": "Kutt",
+ "short_name": "Kutt",
+ "theme_color": "#f3f3f3",
+ "background_color": "#f3f3f3",
+ "display": "standalone",
+ "description": "Kutt.it is a free and open source URL shortener with custom domains and stats.",
+ "Scope": "/",
+ "start_url": "/",
+ "icons": [
+ {
+ "src": "images/icons/icon-72x72.png",
+ "sizes": "72x72",
+ "type": "image/png"
+ },
+ {
+ "src": "images/icons/icon-96x96.png",
+ "sizes": "96x96",
+ "type": "image/png"
+ },
+ {
+ "src": "images/icons/icon-128x128.png",
+ "sizes": "128x128",
+ "type": "image/png"
+ },
+ {
+ "src": "images/icons/icon-144x144.png",
+ "sizes": "144x144",
+ "type": "image/png"
+ },
+ {
+ "src": "images/icons/icon-152x152.png",
+ "sizes": "152x152",
+ "type": "image/png"
+ },
+ {
+ "src": "images/icons/icon-192x192.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ },
+ {
+ "src": "images/icons/icon-384x384.png",
+ "sizes": "384x384",
+ "type": "image/png"
+ },
+ {
+ "src": "images/icons/icon-512x512.png",
+ "sizes": "512x512",
+ "type": "image/png"
+ }
+ ],
+ "splash_pages": null
+}
\ No newline at end of file