7 Commits

Author SHA1 Message Date
11ea32ef6e Update 'pwa/urls.py'
Fix for Django 4.0
2022-05-06 19:14:40 +02: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
6 changed files with 16 additions and 11 deletions

View File

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

View File

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

View File

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

View File

@@ -19,6 +19,10 @@ class ManifestTest(TestCase):
"""GET /manifest.json Should return status code 200""" """GET /manifest.json Should return status code 200"""
self.assertEqual(self.response.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): def test_template(self):
"""Must have the template manifest.json""" """Must have the template manifest.json"""
self.assertTemplateUsed(self.response, 'manifest.json') self.assertTemplateUsed(self.response, 'manifest.json')

View File

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