diff --git a/CHANGELOG.md b/CHANGELOG.md index fdb286a..109e235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,14 +6,16 @@ ## 1.0.0 +### Added - Unit tests - - Add Oritentation on manifest.json - - Add tox - - Add Coverage + - Option `Oritentation` on manifest.json + - tox.ini + - Coverage ## 1.0.1 + ### Added - Add django 2 requirement - Use templateviews instead of own implementations - Add content_types @@ -22,5 +24,22 @@ - Add default_config in `__init__.py` - Add basic serviceworker - Add default offline page and default icons + ### Changed - Updated the unit tests + + ## 1.0.2 + + ### Fixed + - Fix tox.ini to install pypandoc + ### Added + - The support to splash screen for iOS Meta tags `apple-touch-startup-image` + - Meta tag `mobile-web-app-capable` + - Meta tag `application-name` + - Meta tag `msapplication-TileColor` and `msapplication-TileImage` for win8 + - Meta tag `rel="icon"` with default icon + - Images for splash screen + - Include the new images to `serviceworker.js` + ### Changed + - Update `CHANGELOG.md` + - Update `README.md` \ No newline at end of file diff --git a/README.md b/README.md index 73543db..d55aec4 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,9 @@ INSTALLED_APPS = [ ] ``` -Configure your app name, description, and icons in settings.py: +Configure your app name, description, icons and splash screen images in settings.py: ```python + PWA_APP_NAME = 'My App' PWA_APP_DESCRIPTION = "My app description" PWA_APP_THEME_COLOR = '#0A0302' @@ -51,12 +52,18 @@ PWA_APP_ICONS = [ 'sizes': '160x160' } ] +PWA_APP_SPLASH_SCREEN = [ + { + 'src': '/static/images/icons/splash-640x1136.png', + 'media': '(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)' + } +] PWA_APP_DIR = 'ltr' PWA_APP_LANG = 'en-US' ``` -All settings are optional, and the app will work fine with its internal defaults. Highly recommend setting at least `PWA_APP_NAME` and `PWA_APP_DESCRIPTION`. +All settings are optional, and the app will work fine with its internal defaults. Highly recommend setting at least `PWA_APP_NAME`, `PWA_APP_DESCRIPTION`, `PWA_APP_ICONS` and `PWA_APP_SPLASH_SCREEN`. Add the progressive web app URLs to urls.py: ```python @@ -109,6 +116,16 @@ var filesToCache = [ '/images/icons/icon-192x192.png', '/images/icons/icon-384x384.png', '/images/icons/icon-512x512.png', + '/static/images/icons/splash-640x1136.png', + '/static/images/icons/splash-750x1334.png', + '/static/images/icons/splash-1242x2208.png', + '/static/images/icons/splash-1125x2436.png', + '/static/images/icons/splash-828x1792.png', + '/static/images/icons/splash-1242x2688.png', + '/static/images/icons/splash-1536x2048.png', + '/static/images/icons/splash-1668x2224.png', + '/static/images/icons/splash-1668x2388.png', + '/static/images/icons/splash-2048x2732.png' ]; // Cache on install @@ -152,7 +169,7 @@ self.addEventListener("fetch", event => { Adding Your Own Service Worker ===== -By default, the service worker implemented by this app is empty. To add service worker functionality, you'll want to create a `serviceworker.js` or similarly named template in a template directory, and then point at it using the PWA_SERVICE_WORKER_PATH variable (PWA_APP_FETCH_URL is passed through). +To add service worker functionality, you'll want to create a `serviceworker.js` or similarly named template in a template directory, and then point at it using the PWA_SERVICE_WORKER_PATH variable (PWA_APP_FETCH_URL is passed through). ```python PWA_SERVICE_WORKER_PATH = 'my_app/serviceworker.js' diff --git a/pwa/app_settings.py b/pwa/app_settings.py index 55ce81c..05aed1a 100644 --- a/pwa/app_settings.py +++ b/pwa/app_settings.py @@ -18,37 +18,80 @@ PWA_APP_FETCH_URL = getattr(settings, 'PWA_APP_FETCH_URL', '/') PWA_APP_ICONS = getattr(settings, 'PWA_APP_ICONS', [ { 'src': '/static/images/icons/icon-72x72.png', - 'sizes': '72x72' + 'size': '72x72' }, { 'src': '/static/images/icons/icon-96x96.png', - 'sizes': '96x96' + 'size': '96x96' }, { 'src': '/static/images/icons/icon-128x128.png', - 'sizes': '128x128' + 'size': '128x128' }, { 'src': '/static/images/icons/icon-144x144.png', - 'sizes': '144x144' + 'size': '144x144' }, { 'src': '/static/images/icons/icon-152x152.png', - 'sizes': '152x152' + 'size': '152x152' }, { 'src': '/static/images/icons/icon-192x192.png', - 'sizes': '192x192' + 'size': '192x192' }, { 'src': '/static/images/icons/icon-384x384.png', - 'sizes': '384x384' + 'size': '384x384' }, { 'src': '/static/images/icons/icon-512x512.png', - 'sizes': '512x512' + 'size': '512x512' } ]) +PWA_APP_SPLASH_SCREEN = getattr(settings, 'PWA_APP_SPLASH_SCREEN', [ + { + 'src': '/static/images/icons/splash-640x1136.png', + 'media': '(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)' + }, + { + 'src': '/static/images/icons/splash-750x1334.png', + 'media': '(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2)' + }, + { + 'src': '/static/images/icons/splash-1242x2208.png', + 'media': '(device-width: 621px) and (device-height: 1104px) and (-webkit-device-pixel-ratio: 3)' + }, + { + 'src': '/static/images/icons/splash-1125x2436.png', + 'media': '(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3)' + }, + { + 'src': '/static/images/icons/splash-828x1792.png', + 'media': '(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2)' + }, + { + 'src': '/static/images/icons/splash-1242x2688.png', + 'media': '(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3)' + }, + { + 'src': '/static/images/icons/splash-1536x2048.png', + 'media': '(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2)' + }, + { + 'src': '/static/images/icons/splash-1668x2224.png', + 'media': '(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2)' + }, + { + 'src': '/static/images/icons/splash-1668x2388.png', + 'media': '(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2)' + }, + { + 'src': '/static/images/icons/splash-2048x2732.png', + 'media': '(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2)' + } + +]) PWA_APP_DIR = getattr(settings, 'PWA_APP_DIR', 'auto') PWA_APP_LANG = getattr(settings, 'PWA_APP_LANG', 'en-US') diff --git a/pwa/static/images/icons/splash-1125x2436.png b/pwa/static/images/icons/splash-1125x2436.png new file mode 100644 index 0000000..05b019a Binary files /dev/null and b/pwa/static/images/icons/splash-1125x2436.png differ diff --git a/pwa/static/images/icons/splash-1242x2208.png b/pwa/static/images/icons/splash-1242x2208.png new file mode 100644 index 0000000..127202e Binary files /dev/null and b/pwa/static/images/icons/splash-1242x2208.png differ diff --git a/pwa/static/images/icons/splash-1242x2688.png b/pwa/static/images/icons/splash-1242x2688.png new file mode 100644 index 0000000..dec52b6 Binary files /dev/null and b/pwa/static/images/icons/splash-1242x2688.png differ diff --git a/pwa/static/images/icons/splash-1536x2048.png b/pwa/static/images/icons/splash-1536x2048.png new file mode 100644 index 0000000..2008c75 Binary files /dev/null and b/pwa/static/images/icons/splash-1536x2048.png differ diff --git a/pwa/static/images/icons/splash-1668x2224.png b/pwa/static/images/icons/splash-1668x2224.png new file mode 100644 index 0000000..7fac072 Binary files /dev/null and b/pwa/static/images/icons/splash-1668x2224.png differ diff --git a/pwa/static/images/icons/splash-1668x2388.png b/pwa/static/images/icons/splash-1668x2388.png new file mode 100644 index 0000000..f39d2ce Binary files /dev/null and b/pwa/static/images/icons/splash-1668x2388.png differ diff --git a/pwa/static/images/icons/splash-2048x2732.png b/pwa/static/images/icons/splash-2048x2732.png new file mode 100644 index 0000000..0fc4578 Binary files /dev/null and b/pwa/static/images/icons/splash-2048x2732.png differ diff --git a/pwa/static/images/icons/splash-640x1136.png b/pwa/static/images/icons/splash-640x1136.png new file mode 100644 index 0000000..73a34ad Binary files /dev/null and b/pwa/static/images/icons/splash-640x1136.png differ diff --git a/pwa/static/images/icons/splash-750x1334.png b/pwa/static/images/icons/splash-750x1334.png new file mode 100644 index 0000000..a38e09d Binary files /dev/null and b/pwa/static/images/icons/splash-750x1334.png differ diff --git a/pwa/static/images/icons/splash-828x1792.png b/pwa/static/images/icons/splash-828x1792.png new file mode 100644 index 0000000..f6de06c Binary files /dev/null and b/pwa/static/images/icons/splash-828x1792.png differ diff --git a/pwa/templates/pwa.html b/pwa/templates/pwa.html index e4a4ab2..b148acc 100644 --- a/pwa/templates/pwa.html +++ b/pwa/templates/pwa.html @@ -1,27 +1,48 @@ - -{% for icon in PWA_APP_ICONS %} - -{% endfor %} + + + + + + + +{% for icon in PWA_APP_ICONS %} + +{% endfor %} + + +{% for splash in PWA_APP_SPLASH_SCREEN%} + +{% endfor %} + + + + +{% with PWA_APP_ICONS|last as icon %} + + + + +{% endwith %} diff --git a/pwa/templates/serviceworker.js b/pwa/templates/serviceworker.js index 77bf066..7f31ad8 100644 --- a/pwa/templates/serviceworker.js +++ b/pwa/templates/serviceworker.js @@ -12,6 +12,16 @@ var filesToCache = [ '/static/images/icons/icon-192x192.png', '/static/images/icons/icon-384x384.png', '/static/images/icons/icon-512x512.png', + '/static/images/icons/splash-640x1136.png', + '/static/images/icons/splash-750x1334.png', + '/static/images/icons/splash-1242x2208.png', + '/static/images/icons/splash-1125x2436.png', + '/static/images/icons/splash-828x1792.png', + '/static/images/icons/splash-1242x2688.png', + '/static/images/icons/splash-1536x2048.png', + '/static/images/icons/splash-1668x2224.png', + '/static/images/icons/splash-1668x2388.png', + '/static/images/icons/splash-2048x2732.png' ]; // Cache on install diff --git a/pwa/views.py b/pwa/views.py index 205df3d..37f1b3e 100644 --- a/pwa/views.py +++ b/pwa/views.py @@ -24,4 +24,4 @@ class Manifest(TemplateView): class OfflineView(TemplateView): - template_name = "offline.html" \ No newline at end of file + template_name = "offline.html" diff --git a/setup.py b/setup.py index 174f14a..9e5f59e 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ install_requirements = [ setup( name='django-pwa', - version='1.0.1', + version='1.0.2', packages=find_packages(), install_requires=install_requirements, include_package_data=True, diff --git a/tests/test_template_tag_meta.py b/tests/test_template_tag_meta.py index 2339bd8..909bd5b 100644 --- a/tests/test_template_tag_meta.py +++ b/tests/test_template_tag_meta.py @@ -23,10 +23,25 @@ class CreateMetaTemplateTagTest(TestCase): '', '', '', + '', '', '', '', - '' + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '' ] for text in tags: with self.subTest(): @@ -40,9 +55,9 @@ class CreateMetaTemplateTagTest(TestCase): "navigator.serviceWorker.register('/serviceworker.js', {", "scope: '.'", "}).then(function (registration) {", - "console.log('django-progressive-web-app: ServiceWorker registration successful with scope: ', registration.scope);", + "console.log('django-pwa: ServiceWorker registration successful with scope: ', registration.scope);", "}, function (err) {", - "console.log('django-progressive-web-app: ServiceWorker registration failed: ', err);", + "console.log('django-pwa: ServiceWorker registration failed: ', err);", "});", "" ] diff --git a/tox.ini b/tox.ini index 4c81c99..ad204aa 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,22 @@ [tox] envlist = + py35-django{20} + py35-django{21} py36-django{20} py36-django{21} + py37-django{20} + py37-django{21} [testenv] commands = python runtests.py setenv = DJANGO_SETTINGS_MODULE=tests.settings PYTHONPATH={toxinidir} -basepython = py36: python3.6 +basepython = + py35: python3.5 + py36: python3.6 + py37: python3.7 deps = django20: Django==2.0 - django21: Django==2.1 \ No newline at end of file + django21: Django==2.1 + pypandoc==1.3.3 \ No newline at end of file