forked from mirrors/bookwyrm
Fix issue with protocol
This commit is contained in:
parent
e214d8b879
commit
f848dcd756
5 changed files with 12 additions and 12 deletions
|
@ -1,16 +1,18 @@
|
||||||
""" customize the info available in context for rendering templates """
|
""" customize the info available in context for rendering templates """
|
||||||
from bookwyrm import models
|
from bookwyrm import models
|
||||||
from bookwyrm.settings import SITE_PATH, STATIC_URL, STATIC_PATH, MEDIA_URL, MEDIA_PATH
|
from bookwyrm.settings import STATIC_URL, STATIC_PATH, MEDIA_URL, MEDIA_PATH
|
||||||
|
|
||||||
|
|
||||||
def site_settings(request): # pylint: disable=unused-argument
|
def site_settings(request): # pylint: disable=unused-argument
|
||||||
"""include the custom info about the site"""
|
"""include the custom info about the site"""
|
||||||
|
request_protocol = "https://" if request.is_secure() else "http://"
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"site": models.SiteSettings.objects.get(),
|
"site": models.SiteSettings.objects.get(),
|
||||||
"active_announcements": models.Announcement.active_announcements(),
|
"active_announcements": models.Announcement.active_announcements(),
|
||||||
"site_path": SITE_PATH,
|
|
||||||
"static_url": STATIC_URL,
|
"static_url": STATIC_URL,
|
||||||
"media_url": MEDIA_URL,
|
"media_url": MEDIA_URL,
|
||||||
"static_path": STATIC_PATH,
|
"static_path": STATIC_PATH,
|
||||||
"media_path": MEDIA_PATH,
|
"media_path": MEDIA_PATH,
|
||||||
|
"request_protocol": request_protocol,
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,14 +182,12 @@ USE_TZ = True
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
||||||
|
|
||||||
SITE_PATH = "https://%s" % DOMAIN
|
|
||||||
|
|
||||||
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
|
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
STATIC_URL = "/static/"
|
STATIC_URL = "/static/"
|
||||||
STATIC_PATH = "%s/%s" % (SITE_PATH, env("STATIC_ROOT", "static"))
|
STATIC_PATH = "%s/%s" % (DOMAIN, env("STATIC_ROOT", "static"))
|
||||||
STATIC_ROOT = os.path.join(BASE_DIR, env("STATIC_ROOT", "static"))
|
STATIC_ROOT = os.path.join(BASE_DIR, env("STATIC_ROOT", "static"))
|
||||||
MEDIA_URL = "/images/"
|
MEDIA_URL = "/images/"
|
||||||
MEDIA_PATH = "%s/%s" % (SITE_PATH, env("MEDIA_ROOT", "images"))
|
MEDIA_PATH = "%s/%s" % (DOMAIN, env("MEDIA_ROOT", "images"))
|
||||||
MEDIA_ROOT = os.path.join(BASE_DIR, env("MEDIA_ROOT", "images"))
|
MEDIA_ROOT = os.path.join(BASE_DIR, env("MEDIA_ROOT", "images"))
|
||||||
|
|
||||||
USER_AGENT = "%s (BookWyrm/%s; +https://%s/)" % (
|
USER_AGENT = "%s (BookWyrm/%s; +https://%s/)" % (
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
{% block title %}{{ book|book_title }}{% endblock %}
|
{% block title %}{{ book|book_title }}{% endblock %}
|
||||||
|
|
||||||
{% block opengraph_images %}
|
{% block opengraph_images %}
|
||||||
<meta name="twitter:image" content="{{ media_path }}{{ book.preview_image }}">
|
<meta name="twitter:image" content="{{ request_protocol }}{{ media_path }}{{ book.preview_image }}">
|
||||||
<meta name="og:image" content="{{ media_path }}{{ book.preview_image }}">
|
<meta name="og:image" content="{{ request_protocol }}{{ media_path }}{{ book.preview_image }}">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
<meta name="og:description" content="{{ site.instance_tagline }}">
|
<meta name="og:description" content="{{ site.instance_tagline }}">
|
||||||
|
|
||||||
{% block opengraph_images %}
|
{% block opengraph_images %}
|
||||||
<meta name="twitter:image" content="{{ media_path }}{{ site.preview_image }}">
|
<meta name="twitter:image" content="{{ request.protocol }}{{ media_path }}{{ site.preview_image }}">
|
||||||
<meta name="og:image" content="{{ media_path }}{{ site.preview_image }}">
|
<meta name="og:image" content="{{ request.protocol }}{{ media_path }}{{ site.preview_image }}">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<meta name="twitter:image:alt" content="BookWyrm Logo">
|
<meta name="twitter:image:alt" content="BookWyrm Logo">
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
{% block title %}{{ user.display_name }}{% endblock %}
|
{% block title %}{{ user.display_name }}{% endblock %}
|
||||||
|
|
||||||
{% block opengraph_images %}
|
{% block opengraph_images %}
|
||||||
<meta name="twitter:image" content="{{ media_path }}{{ user.preview_image }}">
|
<meta name="twitter:image" content="{{ request_protocol }}{{ media_path }}{{ user.preview_image }}">
|
||||||
<meta name="og:image" content="{{ media_path }}{{ user.preview_image }}">
|
<meta name="og:image" content="{{ request_protocol }}{{ media_path }}{{ user.preview_image }}">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
Loading…
Reference in a new issue