forked from thedevs-network/kutt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fe76fa
commit 03e7cf1
Showing
12 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}); | ||
}); | ||
}) | ||
); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |