Skip to content

Commit 5dcb8a4

Browse files
committed
added PWA manifest and basic service worker
1 parent 1f3f878 commit 5dcb8a4

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

www/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
<meta property="og:locale" content="en_GB"/>
4949
<meta property="og:locale:alternate" content="en_US"/>
5050
<meta property="og:locale:alternate" content="de_DE"/>
51+
52+
<!-- PWA manifest -->
53+
<link rel="manifest" href="sepia.webmanifest">
5154

5255
<!-- imports -->
5356
<!--<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">-->
@@ -665,6 +668,16 @@ <h2><i class="material-icons md-txt">people</i>&nbsp;<script>SepiaFW.local.w('ac
665668
'%3Cscript src="js/index.js"%3E%3C/script%3E'
666669
));
667670
}else{
671+
//register service worker in non-Cordova app only for now
672+
if('serviceWorker' in navigator){
673+
navigator.serviceWorker
674+
.register('sw.js')
675+
.then(function(){
676+
SepiaFW.debug.log('Service Worker: Registered');
677+
});
678+
};
679+
680+
//call setup
668681
appSetup();
669682
}
670683
</script>

www/sepia.webmanifest

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "S.E.P.I.A. Open Assistant",
3+
"short_name": "S.E.P.I.A.",
4+
"description": "S.E.P.I.A. is an app and framework for your own server-based, extendable, private, intelligent assistant.",
5+
"icons": [
6+
{
7+
"src": "./img/icon.png",
8+
"sizes": "192x192",
9+
"type": "image/png"
10+
}, {
11+
"src": "./img/icon-512.png",
12+
"sizes": "512x512",
13+
"type": "image/png"
14+
}
15+
],
16+
"start_url": "./index.html?pwa=true",
17+
"display": "standalone",
18+
"theme_color": "#000000",
19+
"background_color": "#000000",
20+
"shortcuts": [
21+
{
22+
"name": "Always-ON Avatar",
23+
"short_name": "Always-ON",
24+
"description": "Start SEPIA in always-ON avatar mode.",
25+
"url": "./index.html?pwa=true&view=aomode",
26+
"icons": [{ "src": "./img/icon.png", "sizes": "192x192" }]
27+
}, {
28+
"name": "Teach Interface",
29+
"short_name": "Teach-UI",
30+
"description": "Teach SEPIA a new command.",
31+
"url": "./index.html?pwa=true&view=teachui",
32+
"icons": [{ "src": "./img/icon.png", "sizes": "192x192" }]
33+
}
34+
],
35+
"related_applications": [{
36+
"platform": "play",
37+
"url": "https://play.google.com/store/apps/details?id=de.bytemind.sepia.app.web"
38+
}],
39+
"prefer_related_applications": true
40+
}

www/sw.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var cacheName = 'SEPIA_PWA_v0.23.0_b001'; //TODO: remember to clear old caches when the versioned SW cache is active
2+
self.addEventListener('install', function(event){
3+
event.waitUntil(
4+
caches.open(cacheName).then(function(cache){
5+
//Nothing to install yet
6+
return cache.addAll([]);
7+
})
8+
);
9+
});
10+
11+
//Network-Only Mode - see: https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook#network-only
12+
self.addEventListener('fetch', function(event){
13+
event.respondWith(caches.match(event.request).then(function(response){
14+
//is in SW cache?
15+
if (response !== undefined){
16+
return response;
17+
//get it the usual way (this includes default browser HTTP-cache I guess)
18+
}else{
19+
return fetch(event.request);
20+
/*
21+
//put copy in cache
22+
return fetch(event.request).then(function(response){
23+
return caches.open(cacheName).then(function(cache){
24+
console.log('[Service Worker] Caching new resource: ' + event.request.url);
25+
cache.put(event.request, response.clone());
26+
return response;
27+
});
28+
});
29+
*/
30+
}
31+
}));
32+
});

0 commit comments

Comments
 (0)