Merge pull request #15 from loleg/news-prelaunch

Pagination and tweaks
This commit is contained in:
khashashin 2017-09-05 13:48:57 +02:00 committed by GitHub
commit ffe49a7f1e
8 changed files with 67 additions and 25 deletions

View File

@ -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:

View File

@ -19,12 +19,32 @@
</div>
</section>
<!-- Page body -->
<section id="news" class="feedpage-body">
<div class="container">
<!-- Pagination -->
<center>
<ul class="pagination">
{% if feedentries.has_previous %}
<li><a href="?page={{ feedentries.previous_page_number }}" title="Previous">
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span></a></li>
{% endif %}
{% for page_num in feedentries.paginator.page_range %}
<li {% if page_num == feedentries.number %}class="active"{% endif %}>
<a href="?page={{ page_num }}">{{ page_num }}</a></li>
{% endfor %}
{% if feedentries.has_next %}
<li><a href="?page={{ feedentries.next_page_number }}" title="Next">
<span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span></a></li>
{% endif %}
</ul>
</center>
<div class="row">
{% for entry in feedentries %}
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="col-md-4 col-sm-6 col-xs-12 news-entry">
{% if entry.visual %}
<div class="panel panel-default">
<img src="{{ entry.visual }}">
@ -34,14 +54,13 @@
<div class="panel-body">
<h3><span>{{ entry.title|striptags|truncatewords_html:10 }}</span></h3>
<p>
<em><small><span>{{ entry.author }}</span></small></em><br><br>
{{ entry.content|striptags|truncatewords_html:25 }}
{{ entry.content|striptags|truncatewords_html:25 }}
<em><span>{{ entry.author }}</span></em>
</p>
</div>
<a href="{{ entry.link }}" target="_blank" class="fill"></a>
</div>
</div>
<!-- {{ entry.raw }} -->
{% empty %}
<!-- No news today -->
{% endfor %}

View File

@ -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

View File

@ -13,6 +13,8 @@
<!-- Banner (articles) -->
{% include 'banner.html' %}
<div class="home_page">
<!-- News -->
{% include 'news.html' %}
@ -28,4 +30,6 @@
<!-- Infoblocks -->
{% include 'infos.html' %}
</div>
{% endblock %}

View File

@ -20,7 +20,7 @@
{{ entry.body|striptags|truncatewords_html:40 }}
{% endif %}
</p>
<a href="{% pageurl entry %}" class="btn btn-default btn-xs"> ... </a>
<a href="{% pageurl entry %}" class="btn btn-default btn-xs"> 🡆 </a>
</div>
<a href="{% pageurl entry %}" class="fill"></a>
</div>
@ -28,7 +28,7 @@
{% empty %}
<!-- No blogs today -->
{% endfor %}
<h4 class="partner-news"><a href="/aktuelles/">Partner news</a></h4>
<!-- <h4 class="partner-news"><a href="/aktuelles/">Partner news</a></h4> -->
{% for entry in newsentries %}
<!-- News entry {{ entry.id }} -->
<div class="col-md-4 col-sm-6 col-xs-12 news-entry">
@ -41,10 +41,12 @@
<div class="panel-body">
<h3><span>{{ entry.title|striptags|truncatewords_html:10 }}</span></h3>
<p>
<em><small><span>{{ entry.author }}</span></small></em>
{{ entry.content|striptags|truncatewords_html:25 }}
<em><span>{{ entry.author }}</span></em>
</p>
</div>
<a href="{{ entry.link }}" target="_blank" class="fill"></a>
<a href="/aktuelles/" class="fill"></a>
<!-- <a href="{{ entry.link }}" target="_blank" class="fill"></a> -->
</div>
</div>
{% empty %}

View File

@ -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;

View File

@ -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);

View File

@ -18,11 +18,11 @@ $(document).ready(function() {
nextArrow: '<span class="arrow right glyphicon glyphicon-chevron-right" aria-hidden="true">Next</span>',
});
// 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);
// });
});