diff --git a/.idea/misc.xml b/.idea/misc.xml index 7c7709e01ee2155b7c0a4e707b518b02f2274eb5..f967d638a7fcfd76693951f28f989c088f769539 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -6,5 +6,5 @@ <component name="NodePackageJsonFileManager"> <packageJsonPaths /> </component> - <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (school-apps)" project-jdk-type="Python SDK" /> + <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (SchoolApps)" project-jdk-type="Python SDK" /> </project> \ No newline at end of file diff --git a/.idea/school-apps.iml b/.idea/school-apps.iml index 60fb427d477958236a96ce6b6d249cbf6097e7a2..96873b7da10fa79cb630f41924905744bec63b0c 100644 --- a/.idea/school-apps.iml +++ b/.idea/school-apps.iml @@ -23,7 +23,7 @@ <excludeFolder url="file://$MODULE_DIR$/env" /> <excludeFolder url="file://$MODULE_DIR$/schoolapps/staticcollect" /> </content> - <orderEntry type="jdk" jdkName="Python 3.7 (school-apps)" jdkType="Python SDK" /> + <orderEntry type="jdk" jdkName="Python 3.7 (SchoolApps)" jdkType="Python SDK" /> <orderEntry type="sourceFolder" forTests="false" /> </component> <component name="TemplatesService"> diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ffa7302ab357de373c50ef91f1175f443043f35..2dc8e229104aee482fd7bba92d1c47979d611d77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,4 +80,7 @@ Weitere Verbesserungen der vorangegeangen Versionen dieses Releases. ## 1.1.3 "Aebli" * Bugfix in REBUS (Submit wieder erlaubt) (#335) -* Klassenlehrkräfte werden im Plan angezeigt (#334) \ No newline at end of file +* Klassenlehrkräfte werden im Plan angezeigt (#334) + +## 1.1.4 "Aebli" +* Bugfix in der PWA (Offline-Fallback-Page wird nicht mehr bei teils aktiver Netzwerkverbindung fälschlicherweise angezeigt) \ No newline at end of file diff --git a/schoolapps/meta.py b/schoolapps/meta.py index de0df08893bff712f1eb06f65cee7cc02d502c9f..9af2f86c59f640d67970a38470a11f3f616d5fbe 100644 --- a/schoolapps/meta.py +++ b/schoolapps/meta.py @@ -10,7 +10,7 @@ with open(copyright_path, "r") as f: COPYRIGHT_SHORT = "© 2018–2019 Mitglieder der Computer-AG, Katharineum zu Lübeck" -VERSION = '1.1.3 "Aebli"' +VERSION = '1.1.4 "Aebli"' LICENSE_APACHE_2 = "Apache 2.0 License" LICENSE_BSD = "2-Clause BSD License" diff --git a/schoolapps/static/common/serviceworker.js b/schoolapps/static/common/serviceworker.js index db21e62f0b96d19e568b4f6a97308900e63736f4..637d61da06351813116379fea7733931eb4a38ea 100644 --- a/schoolapps/static/common/serviceworker.js +++ b/schoolapps/static/common/serviceworker.js @@ -1,22 +1,19 @@ -//This is the SchoolApps service worker with Advanced caching +//This is the SchoolApps service worker const CACHE = "schoolapps-cache"; const precacheFiles = [ - '/', - '/faq', + '', + '/faq/', ]; const offlineFallbackPage = '/offline'; -const cacheFirstPaths = [ - '/faq', -]; - const avoidCachingPaths = [ '/admin', '/settings', '/support', + '/tools', '/faq/ask', '/aub/apply_for', '/aub/check1', @@ -44,14 +41,14 @@ function comparePaths(requestUrl, pathsArray) { } self.addEventListener("install", function (event) { - console.log("[SchoolApps PWA] Install Event processing"); + console.log("[SchoolApps PWA] Install Event processing."); - console.log("[SchoolApps PWA] Skip waiting on install"); + console.log("[SchoolApps PWA] Skipping waiting on install."); self.skipWaiting(); event.waitUntil( caches.open(CACHE).then(function (cache) { - console.log("[SchoolApps PWA] Caching pages during install"); + console.log("[SchoolApps PWA] Caching pages during install."); return cache.addAll(precacheFiles).then(function () { return cache.add(offlineFallbackPage); @@ -62,84 +59,43 @@ self.addEventListener("install", function (event) { // Allow sw to control of current page self.addEventListener("activate", function (event) { - console.log("[SchoolApps PWA] Claiming clients for current page"); + console.log("[SchoolApps PWA] Claiming clients for current page."); event.waitUntil(self.clients.claim()); }); // If any fetch fails, it will look for the request in the cache and serve it from there first self.addEventListener("fetch", function (event) { if (event.request.method !== "GET") return; - - if (comparePaths(event.request.url, cacheFirstPaths)) { - cacheFirstFetch(event); - } else { - networkFirstFetch(event); - } + networkFirstFetch(event); }); -function cacheFirstFetch(event) { - event.respondWith( - fromCache(event.request).then( - function (response) { - // The response was found in the cache so we respond with it and update the entry - - // This is where we call the server to get the newest version of the - // file to use the next time we show view - event.waitUntil( - fetch(event.request).then(function (response) { - return updateCache(event.request, response); - }) - ); - - return response; - }, - function () { - // The response was not found in the cache so we look for it on the server - return fetch(event.request) - .then(function (response) { - // If request was successful, add or update it in the cache - event.waitUntil(updateCache(event.request, response.clone())); - - return response; - }) - .catch(function (error) { - // The following validates that the request was for a navigation to a new document - if (event.request.destination !== "document" || event.request.mode !== "navigate") { - return; - } - - console.log("[SchoolApps PWA] Network request failed and no cache." + error); - // Use the precached offline page as fallback - return caches.match(offlineFallbackPage) - }); - } - ) - ); -} - function networkFirstFetch(event) { event.respondWith( fetch(event.request) .then(function (response) { // If request was successful, add or update it in the cache + console.log("[SchoolApps PWA] Network request successful."); event.waitUntil(updateCache(event.request, response.clone())); return response; }) .catch(function (error) { console.log("[SchoolApps PWA] Network request failed. Serving content from cache: " + error); - return fromCache(event.request); + return fromCache(event); }) ); } -function fromCache(request) { +function fromCache(event) { // Check to see if you have it in the cache // Return response // If not in the cache, then return offline fallback page return caches.open(CACHE).then(function (cache) { - return cache.match(request).then(function (matching) { + return cache.match(event.request) + .then(function (matching) { if (!matching || matching.status === 404) { - return caches.match(offlineFallbackPage); + console.log("[SchoolApps PWA] Cache request failed. Serving offline fallback page."); + // Use the precached offline page as fallback + return caches.match(offlineFallbackPage) } return matching; diff --git a/schoolapps/static/common/workbox-sw.js b/schoolapps/static/common/workbox-sw.js deleted file mode 100644 index 61b3289a81a12f15841f55e57ace9063bafa3e51..0000000000000000000000000000000000000000 --- a/schoolapps/static/common/workbox-sw.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(){"use strict";try{self["workbox:sw:4.3.1"]&&_()}catch(t){}const t="https://storage.googleapis.com/workbox-cdn/releases/4.3.1",e={backgroundSync:"background-sync",broadcastUpdate:"broadcast-update",cacheableResponse:"cacheable-response",core:"core",expiration:"expiration",googleAnalytics:"offline-ga",navigationPreload:"navigation-preload",precaching:"precaching",rangeRequests:"range-requests",routing:"routing",strategies:"strategies",streams:"streams"};self.workbox=new class{constructor(){return this.v={},this.t={debug:"localhost"===self.location.hostname,modulePathPrefix:null,modulePathCb:null},this.s=this.t.debug?"dev":"prod",this.o=!1,new Proxy(this,{get(t,s){if(t[s])return t[s];const o=e[s];return o&&t.loadModule(`workbox-${o}`),t[s]}})}setConfig(t={}){if(this.o)throw new Error("Config must be set before accessing workbox.* modules");Object.assign(this.t,t),this.s=this.t.debug?"dev":"prod"}loadModule(t){const e=this.i(t);try{importScripts(e),this.o=!0}catch(s){throw console.error(`Unable to import module '${t}' from '${e}'.`),s}}i(e){if(this.t.modulePathCb)return this.t.modulePathCb(e,this.t.debug);let s=[t];const o=`${e}.${this.s}.js`,r=this.t.modulePathPrefix;return r&&""===(s=r.split("/"))[s.length-1]&&s.splice(s.length-1,1),s.push(o),s.join("/")}}}(); -//# sourceMappingURL=workbox-sw.js.map