Update manifest.json with extra properties, set theme colour properly as a <meta> as well
This commit is contained in:
parent
b172d9f139
commit
7429d43280
4 changed files with 33 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
||||||
{% load compress favtags lemoncurry_tags meta static %}<!doctype html>
|
{% load compress favtags lemoncurry_tags meta static theme_colour %}<!doctype html>
|
||||||
<html lang="en" class="{% block html_class %}{% endblock %}">
|
<html lang="en" class="{% block html_class %}{% endblock %}">
|
||||||
<head{% meta_namespaces %}>{% site_name as site_name %}{% request_uri request as uri %}{% request_origin request as origin %}
|
<head{% meta_namespaces %}>{% site_name as site_name %}{% request_uri request as uri %}{% request_origin request as origin %}
|
||||||
<base href="{{ origin }}" />
|
<base href="{{ origin }}" />
|
||||||
|
@ -9,7 +9,9 @@
|
||||||
|
|
||||||
<link rel="hub" href="{% get_push_hub %}" />
|
<link rel="hub" href="{% get_push_hub %}" />
|
||||||
<link rel="self" href="{{ uri }}" />
|
<link rel="self" href="{{ uri }}" />
|
||||||
|
|
||||||
<link rel="manifest" href="{% url 'wellknowns:manifest' %}" />
|
<link rel="manifest" href="{% url 'wellknowns:manifest' %}" />
|
||||||
|
<meta name="theme-color" content="{% theme_colour 2 %}" />
|
||||||
|
|
||||||
<meta property="og:url" content="{{ uri }}" />
|
<meta property="og:url" content="{{ uri }}" />
|
||||||
<meta property="og:title" content="{% firstof title site_name %}" />
|
<meta property="og:title" content="{% firstof title site_name %}" />
|
||||||
|
|
9
lemoncurry/templatetags/theme_colour.py
Normal file
9
lemoncurry/templatetags/theme_colour.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
from django import template
|
||||||
|
from ..theme import color
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def theme_colour(i):
|
||||||
|
return color(i)
|
|
@ -9,3 +9,7 @@ path = join(
|
||||||
)
|
)
|
||||||
with open(path, 'r') as f:
|
with open(path, 'r') as f:
|
||||||
theme = safe_load(f)
|
theme = safe_load(f)
|
||||||
|
|
||||||
|
|
||||||
|
def color(i):
|
||||||
|
return '#' + theme['base0' + format(i, '1X')]
|
||||||
|
|
|
@ -1,17 +1,27 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
|
from django.urls import reverse
|
||||||
from favicon.models import FaviconImg
|
from favicon.models import FaviconImg
|
||||||
from lemoncurry import utils
|
from lemoncurry import utils
|
||||||
from lemoncurry.theme import theme
|
from lemoncurry.theme import color
|
||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
|
from textwrap import shorten
|
||||||
|
|
||||||
|
|
||||||
def manifest(request):
|
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 = {
|
app = {
|
||||||
'name': settings.LEMONCURRY_SITE_NAME,
|
'name': name,
|
||||||
'background_color': '#' + theme['base00'],
|
'short_name': shorten(name, width=20, placeholder=''),
|
||||||
'theme_color': '#' + theme['base02'],
|
|
||||||
|
'display': 'browser',
|
||||||
|
'start_url': urljoin(base, start_url),
|
||||||
|
|
||||||
|
'background_color': color(0),
|
||||||
|
'theme_color': color(2),
|
||||||
}
|
}
|
||||||
|
|
||||||
rels = ('shortcut icon', 'apple-touch-icon')
|
rels = ('shortcut icon', 'apple-touch-icon')
|
||||||
|
@ -21,8 +31,8 @@ def manifest(request):
|
||||||
).order_by('size')
|
).order_by('size')
|
||||||
app['icons'] = [{
|
app['icons'] = [{
|
||||||
'type': 'image/png',
|
'type': 'image/png',
|
||||||
'size': '{0}x{0}'.format(icon.size),
|
'sizes': '{0}x{0}'.format(icon.size),
|
||||||
'src': urljoin(origin, icon.faviconImage.url),
|
'src': urljoin(base, icon.faviconImage.url),
|
||||||
} for icon in icons]
|
} for icon in icons]
|
||||||
|
|
||||||
return JsonResponse(app, content_type='application/manifest+json')
|
return JsonResponse(app, content_type='application/manifest+json')
|
||||||
|
|
Loading…
Reference in a new issue