diff --git a/app/static/app/images/appleicon.png b/app/static/app/images/appleicon.png new file mode 100644 index 0000000..980736b Binary files /dev/null and b/app/static/app/images/appleicon.png differ diff --git a/app/static/app/images/splashscreen.png b/app/static/app/images/splashscreen.png new file mode 100644 index 0000000..6861a01 Binary files /dev/null and b/app/static/app/images/splashscreen.png differ diff --git a/app/static/app/js/serviceworker.js b/app/static/app/js/serviceworker.js new file mode 100644 index 0000000..dced0bf --- /dev/null +++ b/app/static/app/js/serviceworker.js @@ -0,0 +1,52 @@ +var staticCacheName = "django-pwa-v" + new Date().getTime(); +var filesToCache = [ + '/app', +]; + +// Cache on install +// self.addEventListener("install", event => { +// this.skipWaiting(); +// event.waitUntil( +// caches.open(staticCacheName) +// .then(cache => { +// return cache.addAll(filesToCache); +// }) +// ) +// }); +self.addEventListener("install", event => { + this.skipWaiting(); + event.waitUntil( + caches.open(staticCacheName) + .then(cache => { + return fetch('/app') + .then(response => cache.put('/app', new Response(response.body))); + }) + ) +}); + +// Clear cache on activate +self.addEventListener('activate', event => { + event.waitUntil( + caches.keys().then(cacheNames => { + return Promise.all( + cacheNames + .filter(cacheName => (cacheName.startsWith("django-pwa-"))) + .filter(cacheName => (cacheName !== staticCacheName)) + .map(cacheName => caches.delete(cacheName)) + ); + }) + ); +}); + +// Serve from Cache +self.addEventListener("fetch", event => { + event.respondWith( + caches.match(event.request) + .then(response => { + return response || fetch(event.request); + }) + .catch(() => { + return caches.match('app'); + }) + ) +}); \ No newline at end of file diff --git a/app/templates/app/base.html b/app/templates/app/base.html new file mode 100644 index 0000000..06baaaa --- /dev/null +++ b/app/templates/app/base.html @@ -0,0 +1,17 @@ +{% load pwa %} + + + + + + + + {% progressive_web_app_meta %} + + PioMint - Install + + + {% block content %} + {% endblock %} + + \ No newline at end of file diff --git a/app/templates/app/home.html b/app/templates/app/home.html new file mode 100644 index 0000000..f745025 --- /dev/null +++ b/app/templates/app/home.html @@ -0,0 +1,5 @@ +{% extends 'app/base.html' %} + +{% block content %} +

Home

+{% endblock %} diff --git a/app/templates/app/install.html b/app/templates/app/install.html new file mode 100644 index 0000000..7496052 --- /dev/null +++ b/app/templates/app/install.html @@ -0,0 +1,15 @@ +{% extends 'app/base.html' %} + +{% block content %} +

Installieren

+
+

+ Folgende Schritte sind nötig um PioMint unter IOS zu installieren: +
+ 1. Auf das Teilen Symbol klicken. +
+ 2. Auf Zum Home-Bildschirm hinzufügen klicken. +
+ 3. Auf Hinzufügen klicken. +

+{% endblock %} diff --git a/app/templates/app/offline.html b/app/templates/app/offline.html new file mode 100644 index 0000000..e30bd56 --- /dev/null +++ b/app/templates/app/offline.html @@ -0,0 +1 @@ +

OFFLINE PAGE

\ No newline at end of file diff --git a/app/urls.py b/app/urls.py new file mode 100644 index 0000000..9256222 --- /dev/null +++ b/app/urls.py @@ -0,0 +1,10 @@ +from django.urls import path +from django.views.generic import TemplateView +from . import views + +urlpatterns = [ + path("", views.home), + path("home/", views.home), + path('offline/', TemplateView.as_view(template_name="offline.html")), + path("install/", views.install) +] diff --git a/app/views.py b/app/views.py index 91ea44a..efa43d2 100644 --- a/app/views.py +++ b/app/views.py @@ -1,3 +1,11 @@ -from django.shortcuts import render +from django.shortcuts import render, HttpResponse, redirect # Create your views here. +def index(request): + return render(request, "app/base.html") + +def install(request): + return render(request, "app/install.html") + +def home(request): + return render(request, "app/home.html") \ No newline at end of file diff --git a/piomint/pwa_settings.py b/piomint/pwa_settings.py new file mode 100644 index 0000000..ea58a45 --- /dev/null +++ b/piomint/pwa_settings.py @@ -0,0 +1,34 @@ +import os + +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +PWA_APP_NAME = 'PIOMINT' +PWA_APP_DESCRIPTION = "PioneerMinistryTime" +PWA_APP_THEME_COLOR = '#9FEDD7' +PWA_APP_BACKGROUND_COLOR = '#EDEAE5' +PWA_APP_DISPLAY = 'standalone' +PWA_APP_SCOPE = '/' +PWA_APP_ORIENTATION = 'any' +PWA_APP_START_URL = '/app/' +PWA_APP_STATUS_BAR_COLOR = 'black-translucent' +PWA_SERVICE_WORKER_PATH = os.path.join(BASE_DIR, 'app/static/app/js', 'serviceworker.js') +PWA_APP_ICONS = [ + { + 'src': '/static/app/images/appleicon.png', + 'sizes': '160x160' + } +] +PWA_APP_ICONS_APPLE = [ + { + 'src': '/static/app/images/appleicon.png', + 'sizes': '160x160' + } +] +PWA_APP_SPLASH_SCREEN = [ + { + 'src': '/static/app/images/splashscreen.png', + 'media': '(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)' + } +] +PWA_APP_DIR = 'ltr' +PWA_APP_LANG = 'de' \ No newline at end of file diff --git a/piomint/settings.py b/piomint/settings.py index 7e384c6..dd384f4 100644 --- a/piomint/settings.py +++ b/piomint/settings.py @@ -11,6 +11,8 @@ https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path +from .pwa_settings import * + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -38,6 +40,9 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', + # DjangoFrameworkApps - Custom + 'pwa', + # MyApps 'doc', 'app', diff --git a/piomint/urls.py b/piomint/urls.py index 5043b68..4412ab8 100644 --- a/piomint/urls.py +++ b/piomint/urls.py @@ -15,8 +15,16 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include urlpatterns = [ + # ADMIN PAGE path('admin/', admin.site.urls), + + # INDEX ROUTING + path('', include(("web.urls", "web"), namespace="web")), + path('', include('pwa.urls')), + + # SUB-PATHS + path('app/', include(("app.urls", "app"), namespace="app")), ] diff --git a/web/urls.py b/web/urls.py new file mode 100644 index 0000000..39e710d --- /dev/null +++ b/web/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path("", views.index) +] diff --git a/web/views.py b/web/views.py index 91ea44a..0b3f67b 100644 --- a/web/views.py +++ b/web/views.py @@ -1,3 +1,12 @@ -from django.shortcuts import render +from django.shortcuts import render, HttpResponse # Create your views here. +def index(request): + return HttpResponse(''' +

INDEX WEB

+
+ Installieren +
+
+ App Öffnen + ''') \ No newline at end of file