diff --git a/feedler/models/models.py b/feedler/models/models.py index 83e9240..3b77c6c 100644 --- a/feedler/models/models.py +++ b/feedler/models/models.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- from django.db import models +from django.utils import translation +from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from wagtail.wagtailcore.models import Page, Orderable from wagtail.wagtailadmin.edit_handlers import FieldPanel from wagtail.wagtailcore.fields import RichTextField -from django.utils import translation - class Stream(models.Model): title = models.CharField(max_length=255) ident = models.CharField(max_length=255) @@ -70,13 +70,21 @@ class FeedPage(Page): elif curlang in ['fr']: entries = entries.exclude(lang='de') # Order by most recent date first - entries = entries.order_by('-published') - return entries[:10] + return entries.order_by('-published')[:72] def get_context(self, request): # Update template context context = super(FeedPage, self).get_context(request) - context['feedentries'] = self.feedentries + + # Wrap with pagination + paginator = Paginator(self.feedentries, 9) + page = request.GET.get('page') + try: + feedentries = paginator.page(page) + except (PageNotAnInteger, EmptyPage): + feedentries = paginator.page(1) + + context['feedentries'] = feedentries return context class Meta: diff --git a/feedler/templates/feedler/feed_page.html b/feedler/templates/feedler/feed_page.html index df5c33e..34ed625 100644 --- a/feedler/templates/feedler/feed_page.html +++ b/feedler/templates/feedler/feed_page.html @@ -19,12 +19,32 @@ +
+ + +
+
    + {% if feedentries.has_previous %} +
  • +
  • + {% endif %} + {% for page_num in feedentries.paginator.page_range %} +
  • + {{ page_num }}
  • + {% endfor %} + {% if feedentries.has_next %} +
  • +
  • + {% endif %} +
+
+
{% for entry in feedentries %} -
+
{% if entry.visual %}
@@ -34,14 +54,13 @@

{{ entry.title|striptags|truncatewords_html:10 }}

- {{ entry.author }}

- {{ entry.content|striptags|truncatewords_html:25 }} + {{ entry.content|striptags|truncatewords_html:25 }} + {{ entry.author }}

- {% empty %} {% endfor %} diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index 5354862..6fd1eb1 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -239,7 +239,7 @@ class HomePage(Page): entries = entries.exclude(lang='fr') elif curlang in ['fr']: entries = entries.exclude(lang='de') - return entries[:6] + return entries[:3] def get_context(self, request): # Update template context diff --git a/publichealth/home/templates/home/home_page.html b/publichealth/home/templates/home/home_page.html index 4c5e3ff..df0d537 100644 --- a/publichealth/home/templates/home/home_page.html +++ b/publichealth/home/templates/home/home_page.html @@ -13,6 +13,8 @@ {% include 'banner.html' %} +
+ {% include 'news.html' %} @@ -28,4 +30,6 @@ {% include 'infos.html' %} +
+ {% endblock %} diff --git a/publichealth/home/templates/news.html b/publichealth/home/templates/news.html index e31f305..c4fe148 100644 --- a/publichealth/home/templates/news.html +++ b/publichealth/home/templates/news.html @@ -20,7 +20,7 @@ {{ entry.body|striptags|truncatewords_html:40 }} {% endif %}

- ... + 🡆
@@ -28,7 +28,7 @@ {% empty %} {% endfor %} -

Partner news

+ {% for entry in newsentries %}
@@ -41,10 +41,12 @@

{{ entry.title|striptags|truncatewords_html:10 }}

- {{ entry.author }} + {{ entry.content|striptags|truncatewords_html:25 }} + {{ entry.author }}

- + +
{% empty %} diff --git a/publichealth/static/css/modules/_banner.scss b/publichealth/static/css/modules/_banner.scss index 38b279a..19f4f20 100644 --- a/publichealth/static/css/modules/_banner.scss +++ b/publichealth/static/css/modules/_banner.scss @@ -80,8 +80,11 @@ } } - - +/* Home page banner background */ +body.template-frontpage { + background: $gray-lighter; + .home_page section:nth-child(even) { background: white; } +} /* Page header */ $banner-height: 700px; diff --git a/publichealth/static/css/modules/_news.scss b/publichealth/static/css/modules/_news.scss index 418cec4..0fd3bd7 100644 --- a/publichealth/static/css/modules/_news.scss +++ b/publichealth/static/css/modules/_news.scss @@ -46,6 +46,12 @@ margin: 10px 0 0 15px; text-align: center; } + em { + display: block; + font-size: 95%; + margin: 0.5em 0; + font-weight: 500; + } } // expand link over the thumbnail @@ -77,15 +83,15 @@ } .news-entry { - height: 8em; + // height: 8em; .panel { background: none; box-shadow: none; border: none; } .panel-body { - height: 50%; - background-color: #f0f0f0; + // height: 50%; + background-color: #ffffff; border-radius: 4px; border-top: 3px solid $brand-primary; // border: 2px solid rgba(38, 67, 169, 0.8); diff --git a/publichealth/static/js/main.js b/publichealth/static/js/main.js index 3c51033..982e842 100644 --- a/publichealth/static/js/main.js +++ b/publichealth/static/js/main.js @@ -18,11 +18,11 @@ $(document).ready(function() { nextArrow: '', }); - // Formatting of live news - $('.feedpage-body .panel').each(function() { - var hue = Math.floor(Math.random() * 360); - var pastel = 'hsl(' + hue + ', 100%, 87.5%)'; - $(this).css('border-top', '3px solid ' + pastel); - }); + // Pastel colors on live news + // $('.feedpage-body .panel').each(function() { + // var hue = Math.floor(Math.random() * 360); + // var pastel = 'hsl(' + hue + ', 100%, 87.5%)'; + // $(this).css('border-top', '3px solid ' + pastel); + // }); });