18 Commits

Author SHA1 Message Date
dependabot[bot]
41946af69d Bump urllib3 from 1.25.7 to 1.26.5
Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.25.7 to 1.26.5.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/1.25.7...1.26.5)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-01 22:58:39 +00:00
Silvio Leite
0ff60e7afa chore(setup): Include the python 3.8 to classifiers 2020-07-01 19:37:01 -03:00
Silvio Leite
e38a9307eb chore(setup): Update the version, add the tox test to python 3.8 and update the dev dependencies 2020-07-01 19:35:49 -03:00
Silvio Leite
257f2f2922 feat(tests): Add manifest content type test 2020-07-01 19:03:52 -03:00
Vivien
a410a6575a Returns correct content_type 2020-06-26 09:33:58 -03:00
Silvio Leite
5f50788bf4 Merge pull request #45 from stacks13/patch-1
Escape wildcard in paths
2020-06-24 10:35:42 -03:00
Sahil Nirkhe
991a6ee8c2 Escape wildcard in paths
Both serviceworker.js and manifest.json load even if the '.' character is replaced by any other character. This regex fix will prevent that.
2020-06-22 21:57:09 +05:30
Silvio Leite
0d4488a0c5 chore(setup): Update version 2020-05-30 18:15:07 -03:00
Silvio Leite
8e39aebe17 feat(status_bar): Make status bar style configurable 2020-05-30 18:00:17 -03:00
Silvio Leite
43a8131e8e chore(version): new version on setup 2020-02-03 14:20:55 -03:00
Silvio Luis
61cdbf6727 Merge pull request #35 from Natureshadow/patch-1
Fix URL inclusion
2020-02-03 14:12:03 -03:00
Dominik George
67cf917a08 Fix URL inclusion
Closes #34.
2020-01-26 20:49:26 +01:00
Silvio Leite
63139af3f3 feat(version): Update the version on setup 2020-01-23 07:38:48 -03:00
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
13 changed files with 83 additions and 47 deletions

View File

@@ -58,4 +58,10 @@
### Added
- Updated manifest.json by adding scope 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

48
Pipfile.lock generated
View File

@@ -17,31 +17,31 @@
"develop": {
"certifi": {
"hashes": [
"sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3",
"sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f"
"sha256:2bbf76fd432960138b3ef6dda3dde0544f27cbf8546c458e60baf371917ba9ee",
"sha256:50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8"
],
"version": "==2019.11.28"
"version": "==2021.5.30"
},
"chardet": {
"hashes": [
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
"sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
"sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa",
"sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"
],
"version": "==3.0.4"
"version": "==4.0.0"
},
"idna": {
"hashes": [
"sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407",
"sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c"
"sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6",
"sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"
],
"version": "==2.8"
"version": "==2.10"
},
"pkginfo": {
"hashes": [
"sha256:7424f2c8511c186cd5424bbf31045b77435b37a8d604990b79d4e70d741148bb",
"sha256:a6d9e40ca61ad3ebd0b72fbadd4fba16e4c0e4df0428c041e01e06eb6ee71f32"
"sha256:029a70cb45c6171c329dfc890cde0879f8c52d6f3922794796e06f577bb03db4",
"sha256:9fdbea6495622e022cc72c2e5e1b735218e4ffb2a2a69cde2694a6c1f16afb75"
],
"version": "==1.5.0.1"
"version": "==1.7.0"
},
"pypandoc": {
"hashes": [
@@ -52,10 +52,10 @@
},
"requests": {
"hashes": [
"sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4",
"sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31"
"sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804",
"sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e"
],
"version": "==2.22.0"
"version": "==2.25.1"
},
"requests-toolbelt": {
"hashes": [
@@ -66,10 +66,10 @@
},
"tqdm": {
"hashes": [
"sha256:895796ea8df435b6f502bf122f2b2034a3d48e6d8ff52175606ac1051b0e3e12",
"sha256:e405d16c98fcf30725d0c9d493ed07302a18846b5452de5253030ccd18996f87"
"sha256:736524215c690621b06fc89d0310a49822d75e599fcd0feb7cc742b98d692493",
"sha256:cd5791b5d7c3f2f1819efc81d36eb719a38e0906a7380365c556779f585ea042"
],
"version": "==4.40.1"
"version": "==4.61.0"
},
"twine": {
"hashes": [
@@ -81,18 +81,18 @@
},
"urllib3": {
"hashes": [
"sha256:a8a318824cc77d1fd4b2bec2ded92646630d7fe8619497b142c84a9e6f5a7293",
"sha256:f3c5fd51747d450d4dcf6f923c81f78f811aab8205fda64b0aba34a4e48b0745"
"sha256:753a0374df26658f99d826cfe40394a686d05985786d946fbe4165b5148f5a7c",
"sha256:a7acd0977125325f516bda9735fa7142b909a8d01e8b2e4c8108d0984e6e0098"
],
"index": "pypi",
"version": "==1.25.7"
"version": "==1.26.5"
},
"wheel": {
"hashes": [
"sha256:10c9da68765315ed98850f8e048347c3eb06dd81822dc2ab1d4fde9dc9702646",
"sha256:f4da1763d3becf2e2cd92a14a7c920f0f00eca30fdde9ea992c836685b9faf28"
"sha256:78b5b185f0e5763c26ca1e324373aadd49182ca90e825f7853f4b2509215dc0e",
"sha256:e11eefd162658ea59a60a0f6c7d493a7190ea4b9a85e335b33489d9f17e0245e"
],
"version": "==0.33.6"
"version": "==0.36.2"
}
}
}

View File

@@ -54,12 +54,19 @@ PWA_APP_DISPLAY = 'standalone'
PWA_APP_SCOPE = '/'
PWA_APP_ORIENTATION = 'any'
PWA_APP_START_URL = '/'
PWA_APP_STATUS_BAR_COLOR = 'default'
PWA_APP_ICONS = [
{
'src': '/static/images/my_app_icon.png',
'sizes': '160x160'
}
]
PWA_APP_ICONS_APPLE = [
{
'src': '/static/images/my_apple_icon.png',
'sizes': '160x160'
}
]
PWA_APP_SPLASH_SCREEN = [
{
'src': '/static/images/icons/splash-640x1136.png',

View File

@@ -1,7 +1,16 @@
""" Settings required by django-app. """
from django.conf import settings
from django.shortcuts import resolve_url
from django.urls import get_script_prefix
from django.utils.functional import lazy
import os
# Lazy-evaluate URLs so including pwa.urls in root urlconf works
resolve_url = lazy(resolve_url, str)
# Get script prefix for apps not mounted under /
_PWA_SCRIPT_PREFIX = get_script_prefix()
# Path to the service worker implementation. Default implementation is empty.
PWA_SERVICE_WORKER_PATH = getattr(settings, 'PWA_SERVICE_WORKER_PATH',
os.path.join(os.path.abspath(os.path.dirname(__file__)), 'templates',
@@ -9,15 +18,16 @@ PWA_SERVICE_WORKER_PATH = getattr(settings, 'PWA_SERVICE_WORKER_PATH',
# App parameters to include in manifest.json and appropriate meta tags
PWA_APP_NAME = getattr(settings, 'PWA_APP_NAME', 'MyApp')
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_BACKGROUND_COLOR = getattr(settings, 'PWA_APP_BACKGROUND_COLOR', '#fff')
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_ORIENTATION = getattr(settings, 'PWA_APP_ORIENTATION', 'any')
PWA_APP_START_URL = getattr(settings, 'PWA_APP_START_URL', '/')
PWA_APP_FETCH_URL = getattr(settings, 'PWA_APP_FETCH_URL', '/')
PWA_APP_START_URL = resolve_url(getattr(settings, 'PWA_APP_START_URL', _PWA_SCRIPT_PREFIX))
PWA_APP_FETCH_URL = resolve_url(getattr(settings, 'PWA_APP_FETCH_URL', _PWA_SCRIPT_PREFIX))
PWA_APP_STATUS_BAR_COLOR = getattr(settings, 'PWA_APP_STATUS_BAR_COLOR', 'default')
PWA_APP_ICONS = getattr(settings, 'PWA_APP_ICONS', [
{
'src': '/static/images/icons/icon-72x72.png',
@@ -97,5 +107,3 @@ PWA_APP_SPLASH_SCREEN = getattr(settings, 'PWA_APP_SPLASH_SCREEN', [
])
PWA_APP_DIR = getattr(settings, 'PWA_APP_DIR', 'auto')
PWA_APP_LANG = getattr(settings, 'PWA_APP_LANG', 'en-US')

View File

@@ -9,6 +9,7 @@
"orientation": {{ PWA_APP_ORIENTATION|js }},
"background_color": {{ PWA_APP_BACKGROUND_COLOR|js }},
"theme_color": {{ PWA_APP_THEME_COLOR|js }},
"status_bar": {{ PWA_APP_STATUS_BAR_COLOR|js }},
"icons": {{ PWA_APP_ICONS|js }},
"dir": {{ PWA_APP_DIR|js }},
"lang": {{ PWA_APP_LANG|js }}

View File

@@ -12,13 +12,20 @@
<!-- Add to homescreen for Safari on iOS -->
<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-status-bar-style" content="default">
{% for icon in PWA_APP_ICONS %}
<link rel="apple-touch-icon" href="{{ icon.src }}" sizes="{{ icon.size }}">
{% endfor %}
<meta name="apple-mobile-web-app-status-bar-style" content="{{ PWA_APP_STATUS_BAR_COLOR }}">
{% if PWA_APP_ICONS_APPLE %}
{% 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"/>
{% endfor %}

View File

@@ -4,7 +4,7 @@ from .views import manifest, service_worker, offline
# Serve up serviceworker.js and manifest.json at the root
urlpatterns = [
url('^serviceworker.js$', service_worker, name='serviceworker'),
url('^manifest.json$', manifest, name='manifest'),
url(r'^serviceworker\.js$', service_worker, name='serviceworker'),
url(r'^manifest\.json$', manifest, name='manifest'),
url('^offline/$', offline, name='offline')
]

View File

@@ -14,7 +14,7 @@ def manifest(request):
setting_name: getattr(app_settings, setting_name)
for setting_name in dir(app_settings)
if setting_name.startswith('PWA_')
})
}, content_type='application/json')
def offline(request):

View File

@@ -1,2 +1,2 @@
pypandoc==1.3.3
tox==3.2.1
pypandoc==1.5
tox==3.16.1

View File

@@ -4,9 +4,7 @@ from setuptools import find_packages, setup
short_description = 'A Django app to include a manifest.json and Service Worker instance to enable progressive web ' \
'app behavior '
# noinspection PyBroadException
try:
# noinspection PyPackageRequirements
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
@@ -22,7 +20,7 @@ install_requirements = [
setup(
name='django-pwa',
version='1.0.6',
version='1.0.10',
packages=find_packages(),
install_requires=install_requirements,
include_package_data=True,
@@ -52,6 +50,7 @@ setup(
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],

View File

@@ -19,7 +19,8 @@ class AppSettingsTest(TestCase):
'PWA_APP_FETCH_URL',
'PWA_APP_ICONS',
'PWA_APP_DIR',
'PWA_APP_LANG'
'PWA_APP_LANG',
'PWA_APP_STATUS_BAR_COLOR'
]
for attr in attributes:
with self.subTest():

View File

@@ -19,6 +19,10 @@ class ManifestTest(TestCase):
"""GET /manifest.json Should return status code 200"""
self.assertEqual(self.response.status_code, 200)
def test_content_type_json(self):
"""The content type Must be JSON"""
self.assertEqual(self.response['content-type'], 'application/json')
def test_template(self):
"""Must have the template manifest.json"""
self.assertTemplateUsed(self.response, 'manifest.json')
@@ -37,7 +41,8 @@ class ManifestTest(TestCase):
'"orientation":',
'"icons":',
'"dir":',
'"lang":'
'"lang":',
'"status_bar":'
]
for expected in contents:
with self.subTest():

View File

@@ -6,6 +6,7 @@ envlist =
py37-django{20}
py37-django{21}
py37-django{30}
py38-django{30}
[testenv]
commands = python runtests.py
@@ -16,6 +17,7 @@ basepython =
py35: python3.5
py36: python3.6
py37: python3.7
py38: python3.8
deps =
django18: django==1.8
django19: django==1.9
@@ -25,4 +27,4 @@ deps =
django21: Django==2.1
django30: Django==3.0
pypandoc==1.3.3
pypandoc==1.5