diff --git a/assets/static/images/favicon.ico b/assets/static/images/favicon.ico new file mode 100644 index 00000000..d7057bd0 Binary files /dev/null and b/assets/static/images/favicon.ico differ diff --git a/assets/static/js/service_worker.js b/assets/static/js/service_worker.js new file mode 100644 index 00000000..57f793ac --- /dev/null +++ b/assets/static/js/service_worker.js @@ -0,0 +1,25 @@ +self.addEventListener('install', function(e) { + e.waitUntil( + caches.open('progessive-elm').then(function(cache) { + return cache.addAll([ + '/elm/capture', + ]); + }) + ); + }); + + self.addEventListener('fetch', function(event) { + console.log('Service Worker Intercept: ' + event.request.url); + + event.respondWith( + + caches.match(event.request).then(function(response) { + + console.log('Service Worker Serve: ' + event.request.url); + + return response || fetch(event.request); + + }) + + ); + }); \ No newline at end of file diff --git a/assets/static/manifest.json b/assets/static/manifest.json new file mode 100644 index 00000000..162c5aa5 --- /dev/null +++ b/assets/static/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "DWYL App", + "name": "Spike using progressive web app", + "icons": [ + { + "src": "/images/favicon.ico", + "sizes": "192x192", + "type": "image/png" + } + ], + "start_url": "/", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" + } \ No newline at end of file diff --git a/lib/app_web/endpoint.ex b/lib/app_web/endpoint.ex index 2fe6aa9b..b8c0afd6 100644 --- a/lib/app_web/endpoint.ex +++ b/lib/app_web/endpoint.ex @@ -13,7 +13,7 @@ defmodule AppWeb.Endpoint do at: "/", from: :app, gzip: false, - only: ~w(css fonts images js favicon.ico robots.txt) + only: ~w(css fonts images js favicon.ico robots.txt cache_manifest.json service_worker.js) # Code reloading can be explicitly enabled under the # :code_reloader configuration of your endpoint. diff --git a/lib/app_web/templates/capture/init_elm.html.eex b/lib/app_web/templates/capture/init_elm.html.eex index 6398b0b3..d409f797 100644 --- a/lib/app_web/templates/capture/init_elm.html.eex +++ b/lib/app_web/templates/capture/init_elm.html.eex @@ -1,3 +1,3 @@

Elm PWA

-
\ No newline at end of file +
diff --git a/lib/app_web/templates/layout/app.html.eex b/lib/app_web/templates/layout/app.html.eex index 0516576c..726f6ac2 100644 --- a/lib/app_web/templates/layout/app.html.eex +++ b/lib/app_web/templates/layout/app.html.eex @@ -22,6 +22,7 @@ +
@@ -35,5 +36,12 @@ <%= render @view_module, @view_template, assigns %> +