Changed .gitignore, and started using service-worker again

This commit is contained in:
Kasper Rynning-Tønnesen
2017-05-03 19:26:02 +02:00
parent c9af861073
commit 730cf0d724
6 changed files with 15 additions and 17 deletions

2
.gitignore vendored
View File

@@ -1,4 +1,4 @@
server/views/assets/images/thumbnails/
server/public/assets/images/thumbnails/
server/node_modules/
node_modules/
scripts/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -89,7 +89,6 @@ var fromFront = false;
var fromChannel = false;
try{
/*
if (navigator.serviceWorker && window.location.host != "zoff.dev") {
navigator.serviceWorker.register('/service-worker.js', {scope: '/'})
.then(function (registration) {
@@ -100,10 +99,10 @@ try{
});
} else {
Helper.log('Service Worker is not supported in this browser.');
}*/
}/*
navigator.serviceWorker.getRegistration('/').then(function(registration) {
registration.unregister();
});
});*/
} catch(e) {}
$().ready(function(){

View File

@@ -1,8 +1,8 @@
var version = 'v3.4';
var CACHE_FILES = [
'/public/html/offline.html',
'/manifest.json',
'/public/images/favicon.png'
'/assets/html/offline.html',
'/assets/manifest.json',
'/assets/images/favicon.png'
];
self.addEventListener("install", function(event) {
@@ -43,11 +43,11 @@ self.addEventListener('fetch', event => {
fetch(event.request.url).catch(error => {
if(event.request.url.includes('manifest.json')){
return caches.open(version + "::zoff").then(function(cache) {
return cache.match("/manifest.json");
return cache.match("/assets/manifest.json");
});
} else if (event.request.url.includes('favicon')) {
return caches.open(version + "::zoff").then(function(cache) {
return cache.match("/public/images/favicon.png");
return cache.match("/assets/images/favicon.png");
});
} else if (event.request.url.includes('service-worker')) {
return caches.open(version + "::zoff").then(function(cache) {
@@ -55,7 +55,7 @@ self.addEventListener('fetch', event => {
});
} else {
return caches.open(version + "::zoff").then(function(cache) {
return cache.match("/public/html/offline.html");
return cache.match("/assets/html/offline.html");
});
}
})

View File

@@ -104,11 +104,14 @@ app.use(function (req, res, next) {
next();
});
app.use('/service-worker.js', function(req, res) {
res.sendFile(publicPath + '/service-worker.js');
});
app.use('/', router);
app.use('/assets', express.static(publicPath + '/assets'));
/*process.on('uncaughtException', function(e){
console.log("\n" + new Date().toString() + "\n", e.stack || e);
process.exit(1);