Enable django.contrib.sites rather than using a custom lemoncurry-specific setting for the site name
This commit is contained in:
parent
7429d43280
commit
c354830653
5 changed files with 12 additions and 15 deletions
|
@ -64,6 +64,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
'django.contrib.humanize',
|
'django.contrib.humanize',
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.sites',
|
||||||
'django.contrib.sitemaps',
|
'django.contrib.sitemaps',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
@ -95,6 +96,7 @@ MIDDLEWARE = [
|
||||||
'django_otp.middleware.OTPMiddleware',
|
'django_otp.middleware.OTPMiddleware',
|
||||||
'django_agent_trust.middleware.AgentMiddleware',
|
'django_agent_trust.middleware.AgentMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
|
'django.contrib.sites.middleware.CurrentSiteMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -198,22 +200,18 @@ COMPRESS_PRECOMPILERS = (
|
||||||
MEDIA_URL = STATIC_URL + 'media/'
|
MEDIA_URL = STATIC_URL + 'media/'
|
||||||
MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media')
|
MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media')
|
||||||
|
|
||||||
|
# django-contrib-sites
|
||||||
# Settings specific to lemoncurry
|
# https://docs.djangoproject.com/en/dev/ref/contrib/sites/
|
||||||
LEMONCURRY_SITE_NAME = '00dani.me'
|
SITE_ID = 1
|
||||||
|
|
||||||
# django-agent-trust
|
# django-agent-trust
|
||||||
# https://pythonhosted.org/django-agent-trust/
|
# https://pythonhosted.org/django-agent-trust/
|
||||||
AGENT_COOKIE_SECURE = True
|
AGENT_COOKIE_SECURE = True
|
||||||
|
|
||||||
# django-otp
|
|
||||||
# https://django-otp-official.readthedocs.io/en/latest/overview.html
|
|
||||||
OTP_TOTP_ISSUER = LEMONCURRY_SITE_NAME
|
|
||||||
|
|
||||||
# django-meta
|
# django-meta
|
||||||
# https://django-meta.readthedocs.io/en/latest/settings.html
|
# https://django-meta.readthedocs.io/en/latest/settings.html
|
||||||
META_SITE_PROTOCOL = 'https'
|
META_SITE_PROTOCOL = 'https'
|
||||||
META_SITE_NAME = LEMONCURRY_SITE_NAME
|
META_USE_SITES = True
|
||||||
META_USE_OG_PROPERTIES = True
|
META_USE_OG_PROPERTIES = True
|
||||||
META_USE_TWITTER_PROPERTIES = True
|
META_USE_TWITTER_PROPERTIES = True
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
from django import template
|
from django import template
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.contrib.sites.models import Site
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from ..utils import load_package_json, origin, uri
|
from ..utils import load_package_json, origin, uri
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ def request_uri(request):
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def site_name():
|
def site_name():
|
||||||
return settings.LEMONCURRY_SITE_NAME
|
return Site.objects.get_current().name
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('lemoncurry/tags/nav.html')
|
@register.inclusion_tag('lemoncurry/tags/nav.html')
|
||||||
|
|
|
@ -15,7 +15,7 @@ def load_package_json():
|
||||||
|
|
||||||
|
|
||||||
def origin(request):
|
def origin(request):
|
||||||
return '{0}://{1}'.format(request.scheme, request.META['HTTP_HOST'])
|
return '{0}://{1}'.format(request.scheme, request.site.domain)
|
||||||
|
|
||||||
|
|
||||||
def uri(request):
|
def uri(request):
|
||||||
|
|
|
@ -19,7 +19,7 @@ def add_links(request, dest):
|
||||||
def host_meta(request):
|
def host_meta(request):
|
||||||
h = XRD()
|
h = XRD()
|
||||||
h.attributes.append(Attribute('xmlns:hm', 'http://host-meta.net/ns/1.0'))
|
h.attributes.append(Attribute('xmlns:hm', 'http://host-meta.net/ns/1.0'))
|
||||||
h.elements.append(Element('hm:Host', request.META['HTTP_HOST']))
|
h.elements.append(Element('hm:Host', request.site.domain))
|
||||||
add_links(request, h.links)
|
add_links(request, h.links)
|
||||||
return h
|
return h
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
from django.conf import settings
|
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from favicon.models import FaviconImg
|
from favicon.models import FaviconImg
|
||||||
|
@ -10,12 +9,11 @@ from textwrap import shorten
|
||||||
|
|
||||||
def manifest(request):
|
def manifest(request):
|
||||||
base = utils.origin(request)
|
base = utils.origin(request)
|
||||||
name = settings.LEMONCURRY_SITE_NAME
|
|
||||||
start_url = reverse('home:index') + '?utm_source=homescreen'
|
start_url = reverse('home:index') + '?utm_source=homescreen'
|
||||||
|
|
||||||
app = {
|
app = {
|
||||||
'name': name,
|
'name': request.site.name,
|
||||||
'short_name': shorten(name, width=20, placeholder=''),
|
'short_name': shorten(request.site.name, width=20, placeholder=''),
|
||||||
|
|
||||||
'display': 'browser',
|
'display': 'browser',
|
||||||
'start_url': urljoin(base, start_url),
|
'start_url': urljoin(base, start_url),
|
||||||
|
|
Loading…
Reference in a new issue