From 0fc394d0d3287c234a88941327505e25710f36d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 29 Dec 2019 22:05:52 +0100 Subject: [PATCH] include latest post on homepage --- chloro/phyll/static/css/style.scss | 18 ++++++++++++++++-- chloro/phyll/templates/phyll/home.html | 10 +++++++++- chloro/phyll/views.py | 5 +++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/chloro/phyll/static/css/style.scss b/chloro/phyll/static/css/style.scss index c784925..cc3b224 100644 --- a/chloro/phyll/static/css/style.scss +++ b/chloro/phyll/static/css/style.scss @@ -64,7 +64,7 @@ main { } .home { - a { + nav a { text-transform: uppercase; display: inline-block; text-decoration: none; @@ -76,7 +76,7 @@ main { span { font-size: 30%; } - margin-bottom: 2rem; + margin-bottom: 1rem; &.divers { width: 49%; } @@ -86,6 +86,20 @@ main { float: right; } } + .latest { + margin-top: 2em; + h2 { + margin: 0; + font-size: 400%; + font-weight: bold; + text-transform: uppercase; + } + .meta { + padding-top: 0.5rem; + padding-left: 0.5rem; + color: lighten($text-color, 40%); + } + } } .post { diff --git a/chloro/phyll/templates/phyll/home.html b/chloro/phyll/templates/phyll/home.html index 987a446..b39a3ec 100644 --- a/chloro/phyll/templates/phyll/home.html +++ b/chloro/phyll/templates/phyll/home.html @@ -3,10 +3,18 @@ {% block content-class %}home{% endblock %} {% block body %} -
+ + +
+

{{ latest.title }}

+
{{ latest.creation_timestamp|date:"j E Y, H:i"|lower }}
+
+{{ latest.text|safe }} +
{% endblock %} diff --git a/chloro/phyll/views.py b/chloro/phyll/views.py index 78d2fec..6f0f0f7 100644 --- a/chloro/phyll/views.py +++ b/chloro/phyll/views.py @@ -65,6 +65,11 @@ class NoteDeleteView(DeleteView): class HomeView(TemplateView): template_name = 'phyll/home.html' + def get_context_data(self, **kwargs): + context = super(HomeView, self).get_context_data(**kwargs) + context['latest'] = Note.objects.filter(published=True).latest('creation_timestamp') + return context + class ArchivesView(ListView): model = Note -- 2.39.2