Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add in browser cache layer #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"outDir": "dist",
"assets": [
"assets",
"manifest.json",
"favicon.ico"
],
"index": "index.html",
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"start": "pm2 start process.json --only qedu-provas-front --no-daemon",
"start:dev": "ng serve",
"build:stag": "ng build --env=stag --aot=true",
"build:prod": "ng build --env=prod --aot=true",
"build:stag": "ng build --env=stag --aot=true --output-hashing=bundle && sw-precache --verbose --config sw-precache.conf.js",
"build:prod": "ng build --env=prod --aot=true --output-hashing=bundle && sw-precache --verbose --config sw-precache.conf.js",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
Expand Down Expand Up @@ -56,6 +56,7 @@
"karma-remap-istanbul": "^0.6.0",
"nodemon": "^1.11.0",
"protractor": "~5.1.1",
"sw-precache": "^5.2.0",
"ts-node": "2.1.0",
"tslint": "^4.3.0",
"typescript": "~2.2.1",
Expand Down
Binary file added src/assets/images/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 17 additions & 4 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>QEdu Provas</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">
<meta name="msapplication-TileColor" content="#2c8230">
<meta name="msapplication-TileImage" content="assets/images/mstile-150x150.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="QEdu Provas">
<meta name="application-name" content="QEdu Provas">
<meta name="format-detection" content="telephone=no">
<meta name="theme-color" content="#2c8230">
<link rel="apple-touch-icon" sizes="180x180" href="assets/images/apple-touch-icon.png">
<link rel="manifest" href="manifest.json">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<meta name="viewport" content="width=device-width, user-scalable=no">
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', 'UA-105536840-1', 'auto');</script>
<link rel="canonical" href="/">
<base href="/">
<title>QEdu Provas</title>
</head>
<body>
<qp-app>Loading..</qp-app>
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', 'UA-105536840-1', 'auto');</script>
<script src="service-worker.js"></script>
<script>if ('serviceWorker' in navigator && window.location.protocol === 'https:') navigator.serviceWorker.register('/service-worker.js')</script>
</body>
</html>
19 changes: 19 additions & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "QEdu Provas",
"short_name": "QEdu Provas",
"start_url": "./",
"display": "standalone",
"orientation": "portrait",
"background_color": "#2c8230",
"theme_color": "#2c8230",
"icons": [{
"src": "assets/images/android-chrome-192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "assets/images/android-chrome-512x512.png",
"type": "image/png",
"sizes": "512x512"
}]
}
24 changes: 24 additions & 0 deletions sw-precache.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
staticFileGlobs: [
'dist/assets/**',
'dist/**.html',
'dist/**.css}',
'dist/**.js',
'dist/**.svg',
'dist/**.gif',
'dist/**.png',
'dist/**.jpg',
'dist/**.jpeg',
'dist/**.ico',
'dist/**.eot',
'dist/**.ttf',
'dist/**.woff',
'dist/**.woff2'
],
root: 'dist',
stripPrefix: 'dist/',
directoryIndex: 'index.html',
navigateFallback: 'index.html',
maximumFileSizeToCacheInBytes: 3 * 1024 * 1024,
runtimeCaching: []
}