include latest post on homepage
authorFrédéric Péters <fpeters@0d.be>
Sun, 29 Dec 2019 21:05:52 +0000 (22:05 +0100)
committerFrédéric Péters <fpeters@0d.be>
Mon, 30 Dec 2019 08:35:51 +0000 (09:35 +0100)
chloro/phyll/static/css/style.scss
chloro/phyll/templates/phyll/home.html
chloro/phyll/views.py

index c784925..cc3b224 100644 (file)
@@ -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 {
index 987a446..b39a3ec 100644 (file)
@@ -3,10 +3,18 @@
 {% block content-class %}home{% endblock %}
 
 {% block body %}
-<div>
+<nav>
 <a href="tag/radio/">Radio <span>(Panik &amp; ailleurs)</span></a>
 <a href="tag/code/">Logiciel libre <span>(Debian, GNOME &amp; ce qui passe)</span></a>
 <a class="divers" href="tag/divers/"><span>(Totalement)</span> divers</a>
 <a class="vrac" href="archives/"><span>(tout)</span> En vrac</a>
+</nav>
+
+<div class="latest">
+<h2><a href="{{ latest.get_absolute_url }}">{{ latest.title }}</a></h2>
+<div class="meta">{{ latest.creation_timestamp|date:"j E Y, H:i"|lower }}</div>
+<div class="post">
+{{ latest.text|safe }}
+</div>
 </div>
 {% endblock %}
index 78d2fec..6f0f0f7 100644 (file)
@@ -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