From e362c8249563c2c2c371b1136481c6b4c8b1a970 Mon Sep 17 00:00:00 2001 From: Joachim Date: Wed, 26 May 2021 17:54:59 +0200 Subject: [PATCH] Expose static & media paths --- bookwyrm/context_processors.py | 8 ++++++-- bookwyrm/settings.py | 4 ++++ bookwyrm/templates/book/book.html | 4 ++-- bookwyrm/templates/layout.html | 8 ++++---- bookwyrm/templates/user/layout.html | 4 ++-- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/bookwyrm/context_processors.py b/bookwyrm/context_processors.py index 29775a0b5..dcdf615d5 100644 --- a/bookwyrm/context_processors.py +++ b/bookwyrm/context_processors.py @@ -1,6 +1,6 @@ """ customize the info available in context for rendering templates """ from bookwyrm import models -from bookwyrm.settings import DOMAIN +from bookwyrm.settings import SITE_PATH, STATIC_URL, STATIC_PATH, MEDIA_URL, MEDIA_PATH def site_settings(request): # pylint: disable=unused-argument @@ -8,5 +8,9 @@ def site_settings(request): # pylint: disable=unused-argument return { "site": models.SiteSettings.objects.get(), "active_announcements": models.Announcement.active_announcements(), - "site_path": "https://%s" % DOMAIN, + "site_path": SITE_PATH, + "static_url": STATIC_URL, + "media_url": MEDIA_URL, + "static_path": STATIC_PATH, + "media_path": MEDIA_PATH, } diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index 86ad5c035..47553c65f 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -182,10 +182,14 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.2/howto/static-files/ +SITE_PATH = "https://%s" % DOMAIN + PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC_URL = "/static/" +STATIC_PATH = "%s/%s" % (SITE_PATH, env("STATIC_ROOT", "static")) STATIC_ROOT = os.path.join(BASE_DIR, env("STATIC_ROOT", "static")) MEDIA_URL = "/images/" +MEDIA_PATH = "%s/%s" % (SITE_PATH, env("MEDIA_ROOT", "images")) MEDIA_ROOT = os.path.join(BASE_DIR, env("MEDIA_ROOT", "images")) USER_AGENT = "%s (BookWyrm/%s; +https://%s/)" % ( diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 02409b389..7b47e32b6 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -4,8 +4,8 @@ {% block title %}{{ book|book_title }}{% endblock %} {% block opengraph_images %} - - + + {% endblock %} {% block content %} diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index 47bd434e2..625a224e6 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -8,7 +8,7 @@ - + @@ -17,8 +17,8 @@ {% block opengraph_images %} - - + + {% endblock %} @@ -27,7 +27,7 @@