Better handling of absolute URLs with domain + scheme

This commit is contained in:
Joachim 2021-06-19 11:54:19 +02:00
parent d862be0564
commit 6607c8b185
2 changed files with 6 additions and 9 deletions

View file

@ -11,9 +11,6 @@ def site_settings(request): # pylint: disable=unused-argument
return { return {
"site": models.SiteSettings.objects.get(), "site": models.SiteSettings.objects.get(),
"active_announcements": models.Announcement.active_announcements(), "active_announcements": models.Announcement.active_announcements(),
"static_url": settings.STATIC_URL,
"media_url": settings.MEDIA_URL,
"static_path": settings.STATIC_PATH,
"media_path": settings.MEDIA_PATH, "media_path": settings.MEDIA_PATH,
"preview_images_enabled": settings.ENABLE_PREVIEW_IMAGES, "preview_images_enabled": settings.ENABLE_PREVIEW_IMAGES,
"request_protocol": request_protocol, "request_protocol": request_protocol,

View file

@ -1,12 +1,12 @@
{% if preview_images_enabled is True %} {% if preview_images_enabled is True %}
{% if image %} {% if image %}
<meta name="twitter:image" content="{{ request.scheme }}://{{ media_path }}{{ image }}"> <meta name="twitter:image" content="{{ media_path }}{{ image }}">
<meta name="og:image" content="{{ request.scheme }}://{{ media_path }}{{ image }}"> <meta name="og:image" content="{{ media_path }}{{ image }}">
{% else %} {% else %}
<meta name="twitter:image" content="{{ request.scheme }}://{{ media_path }}{{ site.preview_image }}"> <meta name="twitter:image" content="{{ media_path }}{{ site.preview_image }}">
<meta name="og:image" content="{{ request.scheme }}://{{ media_path }}{{ site.preview_image }}"> <meta name="og:image" content="{{ media_path }}{{ site.preview_image }}">
{% endif %} {% endif %}
{% else %} {% else %}
<meta name="twitter:image" content="{{ request.scheme }}://{% if site.logo %}{{ media_path }}{{ site.logo }}{% else %}{{ static_path }}/images/logo.png{% endif %}"> <meta name="twitter:image" content="{% if site.logo %}{{ media_path }}{{ site.logo }}{% else %}{% static "images/logo.png" %}{% endif %}">
<meta name="og:image" content="{{ request.scheme }}://{% if site.logo %}{{ media_path }}{{ site.logo }}{% else %}{{ static_path }}/images/logo.png{% endif %}"> <meta name="og:image" content="{% if site.logo %}{{ media_path }}{{ site.logo }}{% else %}{% static "images/logo.png" %}{% endif %}">
{% endif %} {% endif %}