mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 18:11:09 +00:00
Expose static & media paths
This commit is contained in:
parent
7ea3153026
commit
e362c82495
5 changed files with 18 additions and 10 deletions
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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/)" % (
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
{% block title %}{{ book|book_title }}{% endblock %}
|
||||
|
||||
{% block opengraph_images %}
|
||||
<meta name="twitter:image" content="{{ site_path }}/images/{{ book.preview_image }}">
|
||||
<meta name="og:image" content="{{ site_path }}/images/{{ book.preview_image }}">
|
||||
<meta name="twitter:image" content="{{ media_path }}{{ book.preview_image }}">
|
||||
<meta name="og:image" content="{{ media_path }}{{ book.preview_image }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<link rel="stylesheet" href="/static/css/vendor/icons.css">
|
||||
<link rel="stylesheet" href="/static/css/bookwyrm.css">
|
||||
|
||||
<link rel="shortcut icon" type="image/x-icon" href="{% if site.favicon %}/images/{{ site.favicon }}{% else %}/static/images/favicon.ico{% endif %}">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="{% if site.favicon %}{{ media_url }}{{ site.favicon }}{% else %}/static/images/favicon.ico{% endif %}">
|
||||
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="{% if title %}{{ title }} | {% endif %}{{ site.name }}">
|
||||
|
@ -17,8 +17,8 @@
|
|||
<meta name="og:description" content="{{ site.instance_tagline }}">
|
||||
|
||||
{% block opengraph_images %}
|
||||
<meta name="twitter:image" content="{{ site_path }}/images/{{ site.preview_image }}">
|
||||
<meta name="og:image" content="{{ site_path }}/images/{{ site.preview_image }}">
|
||||
<meta name="twitter:image" content="{{ media_path }}{{ site.preview_image }}">
|
||||
<meta name="og:image" content="{{ media_path }}{{ site.preview_image }}">
|
||||
{% endblock %}
|
||||
<meta name="twitter:image:alt" content="BookWyrm Logo">
|
||||
</head>
|
||||
|
@ -27,7 +27,7 @@
|
|||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item" href="/">
|
||||
<img class="image logo" src="{% if site.logo_small %}/images/{{ site.logo_small }}{% else %}/static/images/logo-small.png{% endif %}" alt="Home page">
|
||||
<img class="image logo" src="{% if site.logo_small %}{{ media_url }}{{ site.logo_small }}{% else %}/static/images/logo-small.png{% endif %}" alt="Home page">
|
||||
</a>
|
||||
<form class="navbar-item column" action="/search/">
|
||||
<div class="field has-addons">
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
{% block title %}{{ user.display_name }}{% endblock %}
|
||||
|
||||
{% block opengraph_images %}
|
||||
<meta name="twitter:image" content="{{ site_path }}/images/{{ user.preview_image }}">
|
||||
<meta name="og:image" content="{{ site_path }}/images/{{ user.preview_image }}">
|
||||
<meta name="twitter:image" content="{{ media_path }}{{ user.preview_image }}">
|
||||
<meta name="og:image" content="{{ media_path }}{{ user.preview_image }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
Loading…
Reference in a new issue