From 186f88f13ec1005b02465c053088e230f69bb244 Mon Sep 17 00:00:00 2001 From: SamuelmdLow Date: Wed, 18 Sep 2024 06:39:39 +0000 Subject: [PATCH] Create landing midsection template and update timeline template so it can be used for more types of pages --- article/templatetags/articletags.py | 6 +- home/blocks.py | 1 + .../section/objects/section_landing.html | 59 +++++++++++++++++++ .../section/objects/section_timeline.html | 10 +++- .../src/styles/modules/_homepage.scss | 47 +++++++++++++++ 5 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 section/templates/section/objects/section_landing.html diff --git a/article/templatetags/articletags.py b/article/templatetags/articletags.py index 5e2eab6cd..b083f9204 100644 --- a/article/templatetags/articletags.py +++ b/article/templatetags/articletags.py @@ -85,10 +85,14 @@ def get_id(value): def group_by_date(value): groups = [] for article in value: + if hasattr(article, 'article.explicit_published_at'): + article.pubTime = article.explicit_published_at + else: + article.pubTime = article.first_published_at if len(groups) < 1: groups.append([article]) else: - if display_pubdate(groups[-1][-1].explicit_published_at) == display_pubdate(article.explicit_published_at): + if display_pubdate(groups[-1][-1].pubTime) == display_pubdate(article.pubTime): groups[-1].append(article) else: groups.append([article]) diff --git a/home/blocks.py b/home/blocks.py index e0bc6757d..8ad16b586 100644 --- a/home/blocks.py +++ b/home/blocks.py @@ -133,6 +133,7 @@ class MidStreamListTemplates(blocks.ChoiceBlock): choices=[ ('section/objects/section_bulleted.html', 'Default'), ('section/objects/section_timeline.html', 'Timeline'), + ('section/objects/section_landing.html', 'Landing'), ] class SectionBlock(AbstractArticleList): diff --git a/section/templates/section/objects/section_landing.html b/section/templates/section/objects/section_landing.html new file mode 100644 index 000000000..899a9430f --- /dev/null +++ b/section/templates/section/objects/section_landing.html @@ -0,0 +1,59 @@ +{% load humanize %} +{% load cache %} +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} +{% load video_filters %} +{% load articletags %} + +
+
+ {% if articles.0 %} + {% with article=articles.0 %} +
+ {% if article.featured_media.first or article.featured_media %} + {% if article.featured_media.first.image or article.featured_media%} +
+ +
+ {% elif article.featured_media.first.video %} +
+
+ +
+
+ {% endif %} + {% endif %} +
+ +
+
+ {% endwith %} + {% endif %} + + +
+ +
\ No newline at end of file diff --git a/section/templates/section/objects/section_timeline.html b/section/templates/section/objects/section_timeline.html index 68e5c8289..5fdda0005 100644 --- a/section/templates/section/objects/section_timeline.html +++ b/section/templates/section/objects/section_timeline.html @@ -11,12 +11,16 @@

{{title}}

{% if articles.0 %} {% with article=articles.0 %}
- {% if article.featured_media.first %} - {% if article.featured_media.first.image %} + {% if article.featured_media.first or article.featured_media %} + {% if article.featured_media.first.image or article.featured_media%}
- {% image article.featured_media.first.image fill-340x238-c100 format-webp %} + {% if article.featured_media.first.image %} + {% image article.featured_media.first.image fill-340x238-c100 format-webp %} + {% else %} + {% image article.featured_media fill-340x238-c100 format-webp %} + {% endif %} {% if label %} {% if article|get_label %} diff --git a/ubyssey/static_src/src/styles/modules/_homepage.scss b/ubyssey/static_src/src/styles/modules/_homepage.scss index 33f66a06e..a3072d5e1 100644 --- a/ubyssey/static_src/src/styles/modules/_homepage.scss +++ b/ubyssey/static_src/src/styles/modules/_homepage.scss @@ -402,6 +402,43 @@ html.hairlines { } } +.c-homepage__section__landing { + padding: 1em 0; + margin: 2em auto; + border-top: 2px solid; + border-bottom: 2px solid; + border-color: var(--section-colour); + .c-homepage__section__landing-flex { + display: flex; + .article--landing { + .o-article__left { + padding: 1em 0; + } + } + ul { + height: fit-content; + margin: auto 0; + padding-bottom: 5%; + li { + margin: 1em 0; + .o-article__headline { + border-bottom: 0.2em solid; + border-color: var(--section-colour); + } + } + } + } +} + +@media($bp-larger-than-phablet) { + .c-homepage__section__landing-flex { + margin-inline: 1em; + .article--landing { + max-width: 600px; + padding-right: 2em; + } + } +} @media($bp-smaller-than-phablet) { .c-homepage__section__timeline { max-width: none; @@ -428,6 +465,16 @@ html.hairlines { } } } + + .c-homepage__section__landing-flex { + flex-direction: column; + h3, p { + margin-inline: 1em; + } + ul { + width: fit-content; + } + } } [color-css-theme="light"] {