diff options
-rw-r--r-- | .bowerrc | 3 | ||||
-rw-r--r-- | .gitignore | 67 | ||||
-rw-r--r-- | bower.json | 21 | ||||
-rw-r--r-- | package.json | 3 | ||||
-rw-r--r-- | public/sw.js | 31 | ||||
-rw-r--r-- | views/index.jade | 10 |
6 files changed, 133 insertions, 2 deletions
diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..0b92d57 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory" : "public/components" +} @@ -1,5 +1,6 @@ +/public/components -# Created by https://www.gitignore.io/api/node +# Created by https://www.gitignore.io/api/node,bower ### Node ### # Logs @@ -43,3 +44,67 @@ jspm_packages # Optional REPL history .node_repl_history + +# Output of 'npm pack' +*.tgz + + +### Bower ### +bower_components +.bower-cache +.bower-registry +.bower-tmp +# Created by https://www.gitignore.io/api/node,bower + +### Node ### +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + + +### Bower ### +bower_components +.bower-cache +.bower-registry +.bower-tmp diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..05be5df --- /dev/null +++ b/bower.json @@ -0,0 +1,21 @@ +{ + "name": "rooster", + "description": "", + "main": "app.js", + "authors": [ + "Noah Loomans <noahloomans@gmail.com>" + ], + "license": "MIT", + "homepage": "https://github.com/nloomans/rooster-mml", + "private": true, + "ignore": [ + "**/.*", + "node_modules", + "public/components", + "test", + "tests" + ], + "dependencies": { + "sw-toolbox": "^3.3.0" + } +} diff --git a/package.json b/package.json index 950ddb2..e6b0a58 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "main": "app.js", "private": true, "scripts": { - "start": "node ./bin/www" + "start": "node ./bin/www", + "setup": "npm install && bower install" }, "dependencies": { "bluebird": "^3.4.6", diff --git a/public/sw.js b/public/sw.js new file mode 100644 index 0000000..1168c93 --- /dev/null +++ b/public/sw.js @@ -0,0 +1,31 @@ +/* global importScripts toolbox self */ + +// random string: CHfHo0GjMJAoOC + +(global => { + 'use strict' + + // Load the sw-toolbox library. + importScripts('/components/sw-toolbox/sw-toolbox.js') + + // Ensure that our service worker takes control of the page as soon as possible. + global.addEventListener('install', event => event.waitUntil(global.skipWaiting())) + global.addEventListener('activate', event => event.waitUntil(global.clients.claim())) + + toolbox.precache([ + '/', + '/hello', + '/untisinfo.css', + '/javascripts/bundle.js', + '/stylesheets/style.css', + '/stylesheets/hello.css' + ]) + + toolbox.router.get('/', toolbox.cacheFirst) + toolbox.router.get('/hello', toolbox.cacheFirst) + + toolbox.router.get('/javascripts/bundle.js', toolbox.cacheFirst) + toolbox.router.get('/stylesheets/*', toolbox.cacheFirst) + toolbox.router.get('/untisinfo.css', toolbox.cacheFirst) + toolbox.router.get('/meetingpointProxy/*', toolbox.networkFirst) +})(self) diff --git a/views/index.jade b/views/index.jade index b4db649..c219d94 100644 --- a/views/index.jade +++ b/views/index.jade @@ -30,3 +30,13 @@ block content iframe(src='/hello', scrolling='no')#schedule script(src='/javascripts/bundle.js') + script. + if ('serviceWorker' in navigator) { + navigator.serviceWorker.register('/sw.js').then(function(registration) { + // Registration was successful + console.log('ServiceWorker registration successful with scope: ', registration.scope) + }).catch(function(err) { + // registration failed :( + console.log('ServiceWorker registration failed: ', err) + }) + } |