From f9e6f1dde3208dc78986c1a6dcc0c64b411e23c1 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Fri, 15 Dec 2017 11:55:29 +1100 Subject: [PATCH] Display the pagination on the home page at least - gotta do the same thing on other feed pages as well but this one is working nicely :) --- home/views.py | 18 +++++++++++ lemoncurry/static/lemoncurry/css/layout.styl | 34 ++++++++++++++++++-- lemoncurry/templates/lemoncurry/layout.html | 33 +++++++++++++++++++ 3 files changed, 82 insertions(+), 3 deletions(-) diff --git a/home/views.py b/home/views.py index 1d23f5c..7304dbd 100644 --- a/home/views.py +++ b/home/views.py @@ -24,6 +24,24 @@ def index(request, page): return redirect('home:index', permanent=True) entries = paginator.page(page or 1) + class Page: + def __init__(self, i): + self.i = i + + @property + def url(self): + return reverse('home:index', kwargs={'page': self.i}) + + @property + def current(self): + return self.i == entries.number + + entries.pages = tuple(Page(i) for i in paginator.page_range) + if entries.has_previous(): + entries.prev = Page(entries.previous_page_number()) + if entries.has_next(): + entries.next = Page(entries.next_page_number()) + return { 'user': user, 'entries': entries, diff --git a/lemoncurry/static/lemoncurry/css/layout.styl b/lemoncurry/static/lemoncurry/css/layout.styl index 5c51ac4..683bad2 100644 --- a/lemoncurry/static/lemoncurry/css/layout.styl +++ b/lemoncurry/static/lemoncurry/css/layout.styl @@ -1,3 +1,8 @@ +$sm = 576px +$md = 768px +$lg = 992px +$xl = 1200px + html background-color $base00 @@ -60,13 +65,36 @@ body > footer display flex justify-content space-evenly + align-items center margin 1rem margin-top 0 text-align center - > p - margin-right 1rem + > p, nav + margin 0 .5rem &:last-child - margin-right 0 + margin 0 + + flex-wrap wrap + > nav + order -1 + margin-bottom 1rem + width 100% + @media (min-width $md) + flex-wrap nowrap + > nav + order 0 + margin-bottom 0 + width unset + +ul.pagination + margin 0 + justify-content center + li.page-item + a.page-link + @extends a + .page-link + background-color $base02 + border 1px solid rgba(0,0,0,.125) .card background-color $base02 diff --git a/lemoncurry/templates/lemoncurry/layout.html b/lemoncurry/templates/lemoncurry/layout.html index 8fe6618..4d0eb80 100644 --- a/lemoncurry/templates/lemoncurry/layout.html +++ b/lemoncurry/templates/lemoncurry/layout.html @@ -66,6 +66,39 @@