From 7ffcf79421750501c55401a6386e90bbcc013938 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 7 May 2020 14:38:11 +0100 Subject: [PATCH] Specify content image through context --- static/src/scss/content.scss | 19 +++++++++++++++++++ static/src/scss/index.scss | 15 --------------- templates/about.html | 2 -- templates/blog/index.html | 2 -- templates/content.html | 8 +++++--- website/blog/views.py | 6 ++++++ website/common/views.py | 6 ++++++ 7 files changed, 36 insertions(+), 22 deletions(-) diff --git a/static/src/scss/content.scss b/static/src/scss/content.scss index 730dde4..c1fc550 100644 --- a/static/src/scss/content.scss +++ b/static/src/scss/content.scss @@ -22,3 +22,22 @@ h1.page-title { font-size: 4rem; margin-top: 1rem; } + +.header-image-spacer { + height: 1rem; +} + +.header-image { + height: calc(40vh - #{$navbar-height}); + + @media #{$medium-and-down} { + height: calc(60vh - #{$navbar-height}); + } + + // Fix darkreader weirdness + .parallax { + position: initial; + width: 100%; + height: 100%; + } +} diff --git a/static/src/scss/index.scss b/static/src/scss/index.scss index 5a64419..f800b3b 100644 --- a/static/src/scss/index.scss +++ b/static/src/scss/index.scss @@ -28,21 +28,6 @@ footer.page-footer { } } -.header-image { - height: calc(40vh - #{$navbar-height}); - - @media #{$medium-and-down} { - height: calc(60vh - #{$navbar-height}); - } - - // Fix darkreader weirdness - .parallax { - position: initial; - width: 100%; - height: 100%; - } -} - nav { a.sidenav-trigger { padding: 0 5px; diff --git a/templates/about.html b/templates/about.html index 2991c5b..7fdddb9 100644 --- a/templates/about.html +++ b/templates/about.html @@ -4,8 +4,6 @@ {% block title %}About{% endblock %} -{% block headerimage %}{% static "img/header.jpg" %}{% endblock %} - {% block content %}

diff --git a/templates/blog/index.html b/templates/blog/index.html index cf83b27..80b7931 100644 --- a/templates/blog/index.html +++ b/templates/blog/index.html @@ -4,8 +4,6 @@ {% block title %}Blog{% endblock %} -{% block headerimage %}{% static "img/header.jpg" %}{% endblock %} - {% block content %} {% endblock%} diff --git a/templates/content.html b/templates/content.html index ae17b4b..fa89ef0 100644 --- a/templates/content.html +++ b/templates/content.html @@ -1,11 +1,13 @@ {% extends "base.html" %} {% block main %} - {% block headerimagewrapper %} + {% if header_image %}
-
+
- {% endblock %} + {% else %} +
+ {% endif %}

{% block title %}{% endblock %}

diff --git a/website/blog/views.py b/website/blog/views.py index fffe0a4..0c670e6 100644 --- a/website/blog/views.py +++ b/website/blog/views.py @@ -1,5 +1,11 @@ +from django.templatetags.static import static from django.views.generic import TemplateView class BlogListView(TemplateView): template_name = "blog/index.html" + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["header_image"] = static("img/header.jpg") + return context diff --git a/website/common/views.py b/website/common/views.py index 155177b..96842cf 100644 --- a/website/common/views.py +++ b/website/common/views.py @@ -1,3 +1,4 @@ +from django.templatetags.static import static from django.views.generic import TemplateView @@ -7,3 +8,8 @@ class HomepageView(TemplateView): class AboutView(TemplateView): template_name = "about.html" + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["header_image"] = static("img/header.jpg") + return context