5 Commits

Author SHA1 Message Date
Silvio Luis
3c36673a21 Merge pull request #32 from Natureshadow/reverse-urls
Allow view names in settings and mounting at subdirectory
2020-01-23 07:36:01 -03:00
Silvio Luis
82f1abb342 Merge pull request #31 from hansegucker/master
Extend support for apple devices
2020-01-23 07:25:48 -03:00
Dominik George
83fa72fcac Update changelog 2020-01-19 10:06:26 +01:00
Dominik George
4f641bc79a Fix PWA if app is not mounted in root of webserver
Uses the same method as Django itself (e.g. in LOGIN_URL).
2020-01-19 10:01:08 +01:00
Jonathan Weth
447aa7c06d Extend support for apple devices
Add option to specify special icons for apple devices because icons on
apple devices are tailored to size differently
2020-01-04 12:47:28 +01:00
4 changed files with 33 additions and 9 deletions

View File

@@ -59,3 +59,9 @@
- Updated manifest.json by adding scope parameter. - Updated manifest.json by adding scope parameter.
- Updated serviceworker.js add scope dynamic parameter - Updated serviceworker.js add scope dynamic parameter
## 1.0.7
### Fixed
- Fix PWA if app is not mounted in root of webserver
### Added
- Allow use of view names in PWA_APP_SCOPE, PWA_START_URL, PWA_APP_FETCH_URL and PWA_APP_ROOT

View File

@@ -60,6 +60,12 @@ PWA_APP_ICONS = [
'sizes': '160x160' 'sizes': '160x160'
} }
] ]
PWA_APP_ICONS_APPLE = [
{
'src': '/static/images/my_apple_icon.png',
'sizes': '160x160'
}
]
PWA_APP_SPLASH_SCREEN = [ PWA_APP_SPLASH_SCREEN = [
{ {
'src': '/static/images/icons/splash-640x1136.png', 'src': '/static/images/icons/splash-640x1136.png',

View File

@@ -1,7 +1,12 @@
""" Settings required by django-app. """ """ Settings required by django-app. """
from django.conf import settings from django.conf import settings
from django.shortcuts import resolve_url
from django.urls import get_script_prefix
import os import os
# Get script prefix for apps not mounted under /
_PWA_SCRIPT_PREFIX = get_script_prefix()
# Path to the service worker implementation. Default implementation is empty. # Path to the service worker implementation. Default implementation is empty.
PWA_SERVICE_WORKER_PATH = getattr(settings, 'PWA_SERVICE_WORKER_PATH', PWA_SERVICE_WORKER_PATH = getattr(settings, 'PWA_SERVICE_WORKER_PATH',
os.path.join(os.path.abspath(os.path.dirname(__file__)), 'templates', os.path.join(os.path.abspath(os.path.dirname(__file__)), 'templates',
@@ -9,15 +14,15 @@ PWA_SERVICE_WORKER_PATH = getattr(settings, 'PWA_SERVICE_WORKER_PATH',
# App parameters to include in manifest.json and appropriate meta tags # App parameters to include in manifest.json and appropriate meta tags
PWA_APP_NAME = getattr(settings, 'PWA_APP_NAME', 'MyApp') PWA_APP_NAME = getattr(settings, 'PWA_APP_NAME', 'MyApp')
PWA_APP_DESCRIPTION = getattr(settings, 'PWA_APP_DESCRIPTION', 'My Progressive Web App') PWA_APP_DESCRIPTION = getattr(settings, 'PWA_APP_DESCRIPTION', 'My Progressive Web App')
PWA_APP_ROOT_URL = getattr(settings, 'PWA_APP_ROOT_URL', '/') PWA_APP_ROOT_URL = resolve_url(getattr(settings, 'PWA_APP_ROOT_URL', _PWA_SCRIPT_PREFIX))
PWA_APP_THEME_COLOR = getattr(settings, 'PWA_APP_THEME_COLOR', '#000') PWA_APP_THEME_COLOR = getattr(settings, 'PWA_APP_THEME_COLOR', '#000')
PWA_APP_BACKGROUND_COLOR = getattr(settings, 'PWA_APP_BACKGROUND_COLOR', '#fff') PWA_APP_BACKGROUND_COLOR = getattr(settings, 'PWA_APP_BACKGROUND_COLOR', '#fff')
PWA_APP_DISPLAY = getattr(settings, 'PWA_APP_DISPLAY', 'standalone') PWA_APP_DISPLAY = getattr(settings, 'PWA_APP_DISPLAY', 'standalone')
PWA_APP_SCOPE = getattr(settings, 'PWA_APP_SCOPE', '/') PWA_APP_SCOPE = resolve_url(getattr(settings, 'PWA_APP_SCOPE', _PWA_SCRIPT_PREFIX))
PWA_APP_DEBUG_MODE = getattr(settings, 'PWA_APP_DEBUG_MODE', True) PWA_APP_DEBUG_MODE = getattr(settings, 'PWA_APP_DEBUG_MODE', True)
PWA_APP_ORIENTATION = getattr(settings, 'PWA_APP_ORIENTATION', 'any') PWA_APP_ORIENTATION = getattr(settings, 'PWA_APP_ORIENTATION', 'any')
PWA_APP_START_URL = getattr(settings, 'PWA_APP_START_URL', '/') PWA_APP_START_URL = resolve_url(getattr(settings, 'PWA_APP_START_URL', _PWA_SCRIPT_PREFIX))
PWA_APP_FETCH_URL = getattr(settings, 'PWA_APP_FETCH_URL', '/') PWA_APP_FETCH_URL = resolve_url(getattr(settings, 'PWA_APP_FETCH_URL', _PWA_SCRIPT_PREFIX))
PWA_APP_ICONS = getattr(settings, 'PWA_APP_ICONS', [ PWA_APP_ICONS = getattr(settings, 'PWA_APP_ICONS', [
{ {
'src': '/static/images/icons/icon-72x72.png', 'src': '/static/images/icons/icon-72x72.png',

View File

@@ -13,12 +13,19 @@
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="{{ PWA_APP_NAME }}"> <meta name="apple-mobile-web-app-title" content="{{ PWA_APP_NAME }}">
<meta name="apple-mobile-web-app-status-bar-style" content="default"> <meta name="apple-mobile-web-app-status-bar-style" content="default">
{% for icon in PWA_APP_ICONS %}
<link rel="apple-touch-icon" href="{{ icon.src }}" sizes="{{ icon.size }}"> {% if PWA_APP_ICONS_APPLE %}
{% endfor %} {% for icon in PWA_APP_ICONS_APPLE %}
<link rel="apple-touch-icon" href="{{ icon.src }}" sizes="{{ icon.size }}">
{% endfor %}
{% else %}
{% for icon in PWA_APP_ICONS %}
<link rel="apple-touch-icon" href="{{ icon.src }}" sizes="{{ icon.size }}">
{% endfor %}
{% endif %}
{% for splash in PWA_APP_SPLASH_SCREEN%} {% for splash in PWA_APP_SPLASH_SCREEN %}
<link href="{{ splash.src }}" media="{{ splash.media }}" rel="apple-touch-startup-image"/> <link href="{{ splash.src }}" media="{{ splash.media }}" rel="apple-touch-startup-image"/>
{% endfor %} {% endfor %}