Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Render manifest.json as template

Marcin Gębala8dbb013c3b31
diff --git a/saleor/core/urls.py b/saleor/core/urls.py
index 52a165708d..9ab14087c2 100644
--- a/saleor/core/urls.py
+++ b/saleor/core/urls.py
@@ -12,6 +12,5 @@ urlpatterns = [
url(r'^impersonate/stop/$', views.stop_impersonate,
name='impersonate-stop'),
url(r'^404', views.handle_404, name='handle-404'),
- url(r'^manifest\.json$', TemplateView.as_view(
- template_name='manifest.json', content_type='application/json')),
+ url(r'^manifest\.json$', views.manifest, name='manifest'),
]
diff --git a/saleor/core/views.py b/saleor/core/views.py
index 35f5c216c8..8c7e91ec5c 100644
--- a/saleor/core/views.py
+++ b/saleor/core/views.py
@@ -5,10 +5,10 @@ from django.contrib import messages
from django.utils.translation import pgettext_lazy
from impersonate.views import impersonate as orig_impersonate, stop_impersonate
-from .utils.schema import get_webpage_schema
from ..dashboard.views import staff_member_required
from ..product.utils import products_with_availability, products_for_homepage
from ..userprofile.models import User
+from .utils.schema import get_webpage_schema
def home(request):
@@ -44,3 +44,13 @@ def offline(request):
def handle_404(request):
return TemplateResponse(request, '404.html', status=404)
+
+
+def manifest(request):
+ site = request.site
+ ctx = {
+ 'description': site.settings.description,
+ 'name': site.name,
+ 'short_name': site.name}
+ return TemplateResponse(
+ request, 'manifest.json', ctx, content_type='application/json')
diff --git a/templates/base.html b/templates/base.html
index 4de97cdfe1..ab2c34d079 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -28,7 +28,7 @@
<meta property="og:image" content="{% static "images/block1.png" %}">
{% endblock meta_tags %}
- <link rel="manifest" href="/manifest.json"/>
+ <link rel="manifest" href="{% url "manifest" %}" />
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
diff --git a/templates/manifest.json b/templates/manifest.json
index f082385db1..4c7adec8c2 100644
--- a/templates/manifest.json
+++ b/templates/manifest.json
@@ -1,63 +1,61 @@
+{% load webpack_static from webpack_loader %}
{
"lang": "en",
"dir": "ltr",
- "name": "Saleor demo shop",
- "description": "Saleor is best storefront engine evar",
- "short_name": "Saleor Demo",
+ "name": "{{ name }}",
+ "description": "{{ description }}",
+ "short_name": "{{ short_name }}",
"icons": [
{
- "src": "/static/assets/favicons/android-chrome-36x36.png",
+ "src": "{% webpack_static "favicons/android-chrome-36x36.png" %}",
"sizes": "36x36",
"type": "image/png"
},
{
- "src": "/static/assets/favicons/android-chrome-48x48.png",
+ "src": "{% webpack_static "favicons/android-chrome-48x48.png" %}",
"sizes": "48x48",
"type": "image/png"
},
{
- "src": "/static/assets/favicons/android-chrome-72x72.png",
+ "src": "{% webpack_static "favicons/android-chrome-72x72.png" %}",
"sizes": "72x72",
"type": "image/png"
},
{
- "src": "/static/assets/favicons/android-chrome-96x96.png",
+ "src": "{% webpack_static "favicons/android-chrome-96x96.png" %}",
"sizes": "96x96",
"type": "image/png"
},
{
- "src": "/static/assets/favicons/android-chrome-144x144.png",
+ "src": "{% webpack_static "favicons/android-chrome-144x144.png" %}",
"sizes": "144x144",
"type": "image/png"
},
{
- "src": "/static/assets/favicons/android-chrome-192x192.png",
+ "src": "{% webpack_static "favicons/android-chrome-192x192.png" %}",
"sizes": "192x192",
"type": "image/png"
},
{
- "src": "/static/assets/favicons/android-chrome-256x256.png",
+ "src": "{% webpack_static "favicons/android-chrome-256x256.png" %}",
"sizes": "256x256",
"type": "image/png"
},
{
- "src": "/static/assets/favicons/android-chrome-384x384.png",
+ "src": "{% webpack_static "favicons/android-chrome-384x384.png" %}",
"sizes": "384x384",
"type": "image/png"
},
{
- "src": "/static/assets/favicons/android-chrome-512x512.png",
+ "src": "{% webpack_static "favicons/android-chrome-512x512.png" %}",
"sizes": "512x512",
"type": "image/png"
}
],
"scope": "/",
- "start_url": "/",
+ "start_url": "{% url 'home' %}",
"display": "fullscreen",
"orientation": "portrait",
"theme_color": "#333333",
- "background_color": "#ffffff",
- "serviceworker": {
- "src": "/service_worker.js"
- }
-}
+ "background_color": "#ffffff"
+}
\ No newline at end of file