Skip to content
Snippets Groups Projects
Commit efe6904a authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

change pwabuilder to django-pwa

parent 74b8c450
No related branches found
No related tags found
1 merge request!86Merge school-apps
......@@ -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
......@@ -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">
......
......@@ -34,7 +34,8 @@ ALLOWED_HOSTS = [
'178.63.239.184',
'159.69.181.50',
'localhost',
'127.0.0.1'
'127.0.0.1',
'ce64cd13.ngrok.io'
]
INTERNAL_IPS = [
......@@ -63,6 +64,7 @@ INSTALLED_APPS = [
'django_react_templatetags',
'martor',
'widget_tweaks',
'pwa',
]
MIDDLEWARE = [
......@@ -241,4 +243,32 @@ if DEBUG:
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# PWA
PWA_APP_NAME = 'SchoolApps'
PWA_APP_DESCRIPTION = "Eine Sammlung an nützlichen Apps für den Schulalltag am Katharineum zu Lübeck"
PWA_APP_THEME_COLOR = '#da1f3d'
PWA_APP_BACKGROUND_COLOR = '#ffffff'
PWA_APP_DISPLAY = 'standalone'
PWA_APP_SCOPE = '/'
PWA_APP_ORIENTATION = 'any'
PWA_APP_START_URL = '/'
PWA_APP_ICONS = [
{
"src": "/static/icons/android_192.png",
"sizes": "192x192",
"type": "image/png"
}
]
PWA_APP_SPLASH_SCREEN = [
{
'src': '/static/icons/android_512.png',
'media': '(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)'
}
]
PWA_APP_DIR = 'ltr'
PWA_APP_LANG = 'de-DE'
# DB
DBSETTINGS_USE_CACHE = False
......@@ -28,11 +28,6 @@ from schoolapps.settings import BASE_DIR
def manifest(request):
return serve(request, "manifest.json")
def serviceworker(request):
return serve(request, "common/pwabuilder-sw.js")
urlpatterns = [
#############
# Dashboard #
......@@ -76,7 +71,7 @@ urlpatterns = [
#######
path('faq/', include('faq.urls')),
path("pwabuilder-sw.js", serviceworker),
path('', include('pwa.urls')),
path('martor/', include('martor.urls')),
]
......
File mode changed from 100755 to 100644
{
"dir": "ltr",
"lang": "de",
"name": "SchoolApps",
"scope": "",
"display": "standalone",
"start_url": "https://info.katharineum.de/",
"short_name": "SchoolApps",
"theme_color": "#da1f3d",
"description": "",
"background_color": "#ffffff",
"related_applications": [],
"prefer_related_applications": false,
"icons": [
{
"src": "/static/icons/android_192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/static/icons/android_512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
//This is the "Offline copy of pages" service worker
//Add this below content to your HTML page, or add the js file to your page at the very top to register service worker
if (navigator.serviceWorker.controller) {
console.log('[PWA Builder] active service worker found, no need to register')
} else {
//Register the ServiceWorker
navigator.serviceWorker.register('pwabuilder-sw.js', {
scope: './'
}).then(function (reg) {
console.log('Service worker has been registered for scope:' + reg.scope);
});
}
//This is the "Offline copy of pages" service worker
//Install stage sets up the index page (home page) in the cache and opens a new cache
self.addEventListener('install', function (event) {
var indexPage = new Request('/');
event.waitUntil(
fetch(indexPage).then(function (response) {
return caches.open('pwabuilder-offline').then(function (cache) {
console.log('[PWA Builder] Cached index page during Install' + response.url);
return cache.put(indexPage, response);
});
}));
});
//If any fetch fails, it will look for the request in the cache and serve it from there first
self.addEventListener('fetch', function (event) {
var updateCache = function (request) {
return caches.open('pwabuilder-offline').then(function (cache) {
return fetch(request).then(function (response) {
console.log('[PWA Builder] add page to offline' + response.url)
return cache.put(request, response);
});
});
};
event.waitUntil(updateCache(event.request));
event.respondWith(
fetch(event.request).catch(function (error) {
console.log('[PWA Builder] Network request Failed. Serving content from cache: ' + error);
//Check to see if you have it in the cache
//Return response
//If not in the cache, then return error page
return caches.open('pwabuilder-offline').then(function (cache) {
return cache.match(event.request).then(function (matching) {
var report = !matching || matching.status === 404 ? Promise.reject('no-match') : matching;
return report
});
});
})
);
})
File mode changed from 100755 to 100644
......@@ -4,8 +4,8 @@
<h3>Leider existiert diese Seite nicht. (Fehler 404)</h3>
<p class="flow-text">
Beim Aufrufen dieser Seite ist ein Fehler aufgetreten. Vermutlich existiert sie nicht. Wenn Sie der Meinung
sind, dass diese Seiten eigentlich existieren müsste, wenden Sie sich bitte an den <a
Beim Aufrufen dieser Seite ist ein Fehler aufgetreten. Vermutlich existiert sie nicht. Wenn Du der Meinung
bist, dass diese Seiten eigentlich existieren müsste, wende Dich bitte an den <a
href="mailto:support@katharineum.de">Support</a>.
</p>
......
......@@ -22,7 +22,6 @@
<!-- JavaScript (jquery v. 3.3.1.slim)-->
<!---------------->
<script src="{% static 'common/manup.min.js' %}"></script>
<script src="{% static "common/pwabuilder-sw-register.js" %}"></script>
<script src="{% static 'js/materialize.min.js' %}"></script>
<script src="{% static 'common/helper.js' %}"></script>
</body>
......
{% load static %}
{% load pwa %}
<!DOCTYPE html>
<html lang="de">
......@@ -65,7 +66,9 @@
<!-- Favicon -->
<link rel="shortcut icon" type="image/x-icon" href="{% static 'common/favicon.ico' %}">
<link rel="manifest" href="{% static "common/manifest.json" %}">
<!-- PWA -->
{% progressive_web_app_meta %}
<!--------->
<!-- CSS -->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment