Update manifest.json with extra properties, set theme colour properly as a <meta> as well

This commit is contained in:
Danielle McLean 2017-10-28 15:05:54 +11:00
parent b172d9f139
commit 7429d43280
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
4 changed files with 33 additions and 8 deletions

View file

@ -1,17 +1,27 @@
from django.conf import settings
from django.http import JsonResponse
from django.urls import reverse
from favicon.models import FaviconImg
from lemoncurry import utils
from lemoncurry.theme import theme
from lemoncurry.theme import color
from urllib.parse import urljoin
from textwrap import shorten
def manifest(request):
origin = utils.origin(request)
base = utils.origin(request)
name = settings.LEMONCURRY_SITE_NAME
start_url = reverse('home:index') + '?utm_source=homescreen'
app = {
'name': settings.LEMONCURRY_SITE_NAME,
'background_color': '#' + theme['base00'],
'theme_color': '#' + theme['base02'],
'name': name,
'short_name': shorten(name, width=20, placeholder=''),
'display': 'browser',
'start_url': urljoin(base, start_url),
'background_color': color(0),
'theme_color': color(2),
}
rels = ('shortcut icon', 'apple-touch-icon')
@ -21,8 +31,8 @@ def manifest(request):
).order_by('size')
app['icons'] = [{
'type': 'image/png',
'size': '{0}x{0}'.format(icon.size),
'src': urljoin(origin, icon.faviconImage.url),
'sizes': '{0}x{0}'.format(icon.size),
'src': urljoin(base, icon.faviconImage.url),
} for icon in icons]
return JsonResponse(app, content_type='application/manifest+json')