Skip to content

Commit 50c56ac

Browse files
argiloTheSkorm
authored andcommitted
Fix PWA caching
1 parent ee394c5 commit 50c56ac

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.pyc
33
*.log
44
/index.html
5+
/service-worker.js
56
/js/version.json
67
cache.manifest
78
tiles/

DEVELOPER_README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ To get a copy of the code and run a test web server:
44

55
1. [Fork the repository](https://github.com/projecthorus/sondehub-tracker/fork) by visiting [https://github.com/projecthorus/sondehub-tracker/fork](https://github.com/projecthorus/sondehub-tracker/fork).
66
2. Clone the repository with your git tool of choice.
7-
3. Run `build.sh` to generate `index.html` and `js/version.json`.
7+
3. Run `build.sh` to generate `index.html`, `service-worker.js`, and `js/version.json`.
88
4. Run `python serve.py` to run a simple web server to (This requires python 3.x)
99
5. Visit [http://localhost:8000](http://localhost:8000) to view the local version of the server!

build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ echo -n "Generating index.html... "
1515
sed -e "s/{VER}/$VERSION/" -e "s/{BUILD_DATE}/$BUILD_DATE/" index.template.html > index.html
1616
echo "Done!"
1717

18+
echo -n "Generating service-worker.js... "
19+
sed -e "s/{VER}/$VERSION/" service-worker.template.js > service-worker.js
20+
echo "Done!"
21+
1822
echo "Build version: $VERSION Build date: $BUILD_DATE"

index.template.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<script type="text/javascript" language="javascript" src="js/pwa.js?v={VER}"></script>
5151

5252
</head>
53-
<body data-version="{VER}" data-build-date="{BUILD_DATE}">
53+
<body data-version="{VER}">
5454

5555
<div id="loading">
5656
<div>
@@ -150,9 +150,9 @@ <h4>Contribute</h4>
150150
<a href="https://github.com/projecthorus/sondehub-tracker" target="_blank" rel="noopener">github/sondehub-tracker</a>.
151151
Bug reports, suggestions and pull requests are welcome. A huge thanks to RGP for developing the mobile tracker that this site is based on.
152152
<br/><br/>
153-
Tracker Revision: <span class="r" id="build_version"></span>
153+
Tracker Revision: <span class="r">{VER}</span>
154154
<br/>
155-
Build Date: <span class="r" id="build_date"></span>
155+
Build Date: <span class="r">{BUILD_DATE}</span>
156156

157157
</p>
158158
</div>

js/app.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,6 @@ $(window).ready(function() {
493493
updateTime(new Date());
494494
}, 1000);
495495

496-
// Update Tracker version info
497-
$('#build_version').text(document.body.dataset.version);
498-
$('#build_date').text(document.body.dataset.buildDate);
499-
500496
// resize elements if needed
501497
checkSize();
502498

service-worker.js renamed to service-worker.template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
self.addEventListener('install', function(event) {
22
event.waitUntil(
3-
caches.open(document.body.dataset.version).then(function(cache) {
3+
caches.open("{VER}").then(function(cache) {
44
return cache.addAll(
55
[
66
'/css/base.css',

0 commit comments

Comments
 (0)