Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added PWA screenshots and shortcut support #79

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ STATICFILES_DIRS = [
]
```

Configure your app name, description, icons and splash screen images in settings.py:
Configure your app name, description, icons, splash screen images, screenshots and shortcuts in settings.py:
```python

PWA_APP_NAME = 'My App'
Expand Down Expand Up @@ -75,12 +75,27 @@ PWA_APP_SPLASH_SCREEN = [
]
PWA_APP_DIR = 'ltr'
PWA_APP_LANG = 'en-US'
PWA_APP_SHORTCUTS = [
{
'name': 'Shortcut',
'url': '/target',
'description': 'Shortcut to a page in my application'
}
]
PWA_APP_SCREENSHOTS = [
{
'src': '/static/images/icons/splash-750x1334.png',
'sizes': '750x1334',
"type": "image/png"
}
]

```
#### Show console.log
Set the `PWA_APP_DEBUG_MODE = False` to disable the the `console.log` on browser.

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`.
In order to not use one of the internal defaults, a setting can be set to an empty string or list, whichever one is applicable.

Add the progressive web app URLs to urls.py:
```python
Expand Down Expand Up @@ -109,10 +124,10 @@ Troubleshooting
While running the Django test server:

1. Verify that `/manifest.json` is being served
1. Verify that `/serviceworker.js` is being served
1. Verify that `/offline` is being served
1. Use the Application tab in the Chrome Developer Tools to verify the progressive web app is configured correctly.
1. Use the "Add to homescreen" link on the Application Tab to verify you can add the app successfully.
2. Verify that `/serviceworker.js` is being served
3. Verify that `/offline` is being served
4. Use the Application tab in the Chrome Developer Tools to verify the progressive web app is configured correctly.
5. Use the "Add to homescreen" link on the Application Tab to verify you can add the app successfully.


The Service Worker
Expand Down
14 changes: 14 additions & 0 deletions pwa/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,17 @@
])
PWA_APP_DIR = getattr(settings, 'PWA_APP_DIR', 'auto')
PWA_APP_LANG = getattr(settings, 'PWA_APP_LANG', 'en-US')
PWA_APP_SCREENSHOTS = getattr(settings, 'PWA_APP_SCREENSHOTS', [
{
'src': '/static/images/icons/splash-750x1334.png',
'sizes': '750x1334',
"type": "image/png"
}
])
PWA_APP_SHORTCUTS = getattr(settings, "PWA_APP_SHORTCUTS", [
hartungstenio marked this conversation as resolved.
Show resolved Hide resolved
{
'name': 'Home',
'url': '/',
'description': 'Startpage of the application'
}
])
4 changes: 3 additions & 1 deletion pwa/templates/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
"status_bar": {{ PWA_APP_STATUS_BAR_COLOR|js }},
"icons": {{ PWA_APP_ICONS|js }},
"dir": {{ PWA_APP_DIR|js }},
"lang": {{ PWA_APP_LANG|js }}
"lang": {{ PWA_APP_LANG|js }},
"screenshots" : {{PWA_APP_SCREENSHOTS|js }},
"shortcuts" : {{PWA_APP_SHORTCUTS|js }}
}
4 changes: 3 additions & 1 deletion tests/test_settings_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def test_has_defined(self):
'PWA_APP_ICONS',
'PWA_APP_DIR',
'PWA_APP_LANG',
'PWA_APP_STATUS_BAR_COLOR'
'PWA_APP_STATUS_BAR_COLOR',
'PWA_APP_SCREENSHOTS',
'PWA_APP_SHORTCUTS'
]
for attr in attributes:
with self.subTest():
Expand Down
6 changes: 4 additions & 2 deletions tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_template(self):
self.assertTemplateUsed(self.response, 'manifest.json')

def test_manifest_contains(self):
"""Must be the attributes to manitesf.json"""
"""Must be the attributes to manifest.json"""
contents = [
'"name":',
'"short_name":',
Expand All @@ -42,7 +42,9 @@ def test_manifest_contains(self):
'"icons":',
'"dir":',
'"lang":',
'"status_bar":'
'"status_bar":',
'"screenshots" :',
'"shortcuts" :'
]
for expected in contents:
with self.subTest():
Expand Down