Skip to content

Commit

Permalink
Viewer: add shell service worker for ATHS support (#1571)
Browse files Browse the repository at this point in the history
* Viewer: add sw for ATHS

* feedback

* no scope

* Register sw on path

* feedback
  • Loading branch information
ebidel committed Jan 31, 2017
1 parent c191238 commit 8fa5ecc
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lighthouse-viewer/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<title>Lighthouse Report Viewer</title>
<link rel="manifest" href="manifest.json">
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAADjklEQVR4AWI08P/HQEvAQrxSQKvlECfLFYXx75xCY2qmh89GbNvOMjb3v9jOOlxnFWxj206ebQ3b7q6q+z1rNagu8/zvPSZACAABpeUAA0miMgU7SA7JjCraFGwZwECOwvL75dWjsKgWBKtx0jvWo+vkBAFbACCkByMP6nMn48+AVgXB2fzSCwsv22/lMGlUhmJ0AE7BH8dyUUDbUEgN6RzJRSeaPxhdRYR0Inel+7Hd5lBiFpkMAxACc0394//9C4voFHDiAAGLpuOXebdfdHfctgwJKaZRLRKy6ItrSis6RBnVBgGtbHyKTEmJHQoEXoBCE5BCrDeA2ogMUIGDAKEBDEhUqwgMqBYDjW4DQzmuffVdqff42/ZQYYqVcMXGZsMPyCsH3lyJSetxvEaxAQXdjR1HjfwCdIS7lo2DZke26Qe+MXO12OWkGT0O6oE7vMGkMnkYw4aN1KQgMKExhXqswfiov4+a7MQ11XPnbr/5qpKlgACAAQj94Lu271bN9DUecQasIZlNzG72llRAAKJiAi+/BSHrSFjRvQhg3DEKEqJh08tsmLTx597+f6enr4cc2Zpk57pihfX24dW7RHcOLLUbJYhJSl0ErQCI9BVXH/XrO97QasuvQQSiECa0BrQCIIJp6X9T/r8QG6L71WYSqCoIIGo2BZDUBnS/D9EA9Nun1iYvbM0MFExIDQRoKFatc1Z6zrm5uWeObJotq0BGV9FuQBWq5a4Fw3PPz848rZHstZSuA5FWAFSMP2nOppOOGpl6qh9PCSg0IFyHKjSQyDNQHTru2t75NOEe0fsf246oAmFkI6vCdnWvbQFQFCKx8vCswV8TrDLiDLgH4Nr7RAtNsrC9d8sfk7b8ls4igdNy8CQKAISlsB0FjZfd3Lfp155tf8fKI4BxZZIj/oTdVEAIAcJFOCmzauHG71I7/rdreUAgAqpDP05fDARCAQQARwEIBQSVxq0FyaLvZZtevpHa8WHw8cft6cpxlq8eAJtIhnSbWDf951yx3y13OqUuu5qyGgkxCgGFh9cDihDGbTa6BqvT1lWmrav3bmt2ZMJ4mU6TGgIC4DBzcv/JqAau1WhzSt3x9Ixk/4Jk/8J4ZrrViFMA4W6A7+WK8xcVjvyrOmVD0FbAXokcT48r+xVqLKvuJYbmpNadnlp3mpufJHOe/GXktM+r09bT8kEdq9BRYAbGSgzP7ll82U71Mc+ZFooXgwAAAABJRU5ErkJggg==">
<link rel="manifest" href="images/manifest.json">
<meta name="theme-color" content="#304ffe">

<!-- build:css styles/main.css -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
"short_name": "Lighthouse",
"icons": [
{
"src": "android-chrome-192x192.png",
"src": "images/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "android-chrome-512x512.png",
"src": "images/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#304ffe",
"background_color": "#304ffe",
"display": "standalone"
"display": "standalone",
"start_url": "./"
}
4 changes: 4 additions & 0 deletions lighthouse-viewer/app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ Promise.all(loadPolyfillPromises).then(_ => {
// eslint-disable-next-line no-new
new LighthouseViewerReport();
});

if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js');
}
18 changes: 18 additions & 0 deletions lighthouse-viewer/app/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2017 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Intentionally empty for now.
13 changes: 10 additions & 3 deletions lighthouse-viewer/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function license() {
gulp.task('lint', () => {
return gulp.src([
'app/src/**/*.js',
'gulpfile.js'
'gulpfile.js',
'sw.js'
])
.pipe($.eslint())
.pipe($.eslint.format())
Expand All @@ -65,7 +66,11 @@ gulp.task('concat-css', ['html', 'css'], () => {
});

gulp.task('html', () => {
return gulp.src('app/*.html').pipe(gulp.dest(DIST_FOLDER));
return gulp.src([
'app/*.html',
'app/sw.js',
'app/manifest.json'
]).pipe(gulp.dest(DIST_FOLDER));
});

gulp.task('polyfills', () => {
Expand Down Expand Up @@ -124,7 +129,9 @@ gulp.task('watch', ['lint', 'browserify', 'polyfills', 'html', 'images', 'css'],
});

gulp.watch([
'app/index.html'
'app/index.html',
'app/manifest.json',
'app/sw.js'
]).on('change', () => {
runSequence('html');
});
Expand Down

0 comments on commit 8fa5ecc

Please sign in to comment.