include direct links to latest posts on homepage
authorFrédéric Péters <fpeters@0d.be>
Sat, 22 Feb 2020 18:51:28 +0000 (19:51 +0100)
committerFrédéric Péters <fpeters@0d.be>
Sat, 22 Feb 2020 19:00:34 +0000 (20:00 +0100)
chloro/phyll/static/css/style.scss
chloro/phyll/templates/phyll/home.html
chloro/phyll/views.py

index 63526ef..bce2e84 100644 (file)
@@ -154,5 +154,20 @@ main {
                        font-size: 60%;
                }
        }
                        font-size: 60%;
                }
        }
+}
 
 
+.older.post-list {
+       margin: 5em 0 2em 0;
+       padding: 1em 0;
+       border-top: 0.1em dotted $link-color;
+       border-bottom: 0.1em dotted $link-color;
+       line-height: 200%;
+       li {
+               display: inline;
+               a {
+                       padding-top: 0;
+                       display: inline;
+                       font-size: 120%;
+               }
+       }
 }
 }
index 42eb410..4688d5f 100644 (file)
@@ -4,6 +4,7 @@
 
 {% block body %}
 
 
 {% block body %}
 
+{% with posts.0 as latest %}
 <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="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>
 {{ latest.text|safe }}
 </div>
 </div>
 {{ latest.text|safe }}
 </div>
 </div>
+{% endwith %}
+
+<div class="older post-list">
+<ul>
+{% for post in posts|slice:"1:" %}
+<li><a href="{{ post.get_absolute_url }}">{{ post.title }}&nbsp;<span>{{ post.creation_timestamp|date:"Y/m/d" }}</span></a></li>
+{% endfor %}
+<li><a href="/archives/">...</a></li>
+</ul>
+</div>
 
 <nav>
 <a href="tag/radio/">Radio <span>(Panik &amp; ailleurs)</span></a>
 
 <nav>
 <a href="tag/radio/">Radio <span>(Panik &amp; ailleurs)</span></a>
index 6c8fdab..84b40e7 100644 (file)
@@ -67,7 +67,7 @@ class HomeView(TemplateView):
 
     def get_context_data(self, **kwargs):
         context = super(HomeView, self).get_context_data(**kwargs)
 
     def get_context_data(self, **kwargs):
         context = super(HomeView, self).get_context_data(**kwargs)
-        context['latest'] = Note.objects.filter(published=True).latest('creation_timestamp')
+        context['posts'] = Note.objects.filter(published=True).order_by('-creation_timestamp')[:5]
         return context
 
 
         return context