mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Expose first and last page of pagination via template
Undos the changes done the code and solve the problem by just changing the appropriate template.
This commit is contained in:
parent
3e26c76e8a
commit
c073c566e1
3 changed files with 5 additions and 29 deletions
|
|
@ -137,24 +137,18 @@ Variable Description
|
|||
====================== ===================================================
|
||||
articles_paginator A paginator object for the list of articles
|
||||
articles_page The current page of articles
|
||||
articles_first_page The first page of articles
|
||||
articles_previous_page The previous page of articles (``None`` if page does
|
||||
not exist)
|
||||
articles_next_page The next page of articles (``None`` if page does
|
||||
not exist)
|
||||
articles_last_page The first page of articles
|
||||
dates_paginator A paginator object for the article list, ordered by
|
||||
date, ascending.
|
||||
dates_page The current page of articles, ordered by date,
|
||||
ascending.
|
||||
dates_first_page The first page of articles, ordered by date,
|
||||
ascending.
|
||||
dates_previous_page The previous page of articles, ordered by date,
|
||||
ascending (``None`` if page does not exist)
|
||||
dates_next_page The next page of articles, ordered by date,
|
||||
ascending (``None`` if page does not exist)
|
||||
dates_last_page The last page of articles, ordered by date,
|
||||
ascending.
|
||||
page_name 'index' -- useful for pagination links
|
||||
====================== ===================================================
|
||||
|
||||
|
|
@ -176,24 +170,18 @@ dates Articles by this author, but ordered by date,
|
|||
ascending
|
||||
articles_paginator A paginator object for the list of articles
|
||||
articles_page The current page of articles
|
||||
articles_first_page The first page of articles
|
||||
articles_previous_page The previous page of articles (``None`` if page does
|
||||
not exist)
|
||||
articles_next_page The next page of articles (``None`` if page does
|
||||
not exist)
|
||||
articles_last_page The first page of articles
|
||||
dates_paginator A paginator object for the article list, ordered by
|
||||
date, ascending.
|
||||
dates_page The current page of articles, ordered by date,
|
||||
ascending.
|
||||
dates_first_page The first page of articles, ordered by date,
|
||||
ascending.
|
||||
dates_previous_page The previous page of articles, ordered by date,
|
||||
ascending (``None`` if page does not exist)
|
||||
dates_next_page The next page of articles, ordered by date,
|
||||
ascending (``None`` if page does not exist)
|
||||
dates_last_page The last page of articles, ordered by date,
|
||||
ascending.
|
||||
page_name AUTHOR_URL where everything after `{slug}` is
|
||||
removed -- useful for pagination links
|
||||
====================== ===================================================
|
||||
|
|
@ -216,24 +204,18 @@ dates Articles for this category, but ordered by date,
|
|||
ascending
|
||||
articles_paginator A paginator object for the list of articles
|
||||
articles_page The current page of articles
|
||||
articles_first_page The first page of articles
|
||||
articles_previous_page The previous page of articles (``None`` if page does
|
||||
not exist)
|
||||
articles_next_page The next page of articles (``None`` if page does
|
||||
not exist)
|
||||
articles_last_page The first page of articles
|
||||
dates_paginator A paginator object for the list of articles,
|
||||
ordered by date, ascending
|
||||
dates_page The current page of articles, ordered by date,
|
||||
ascending
|
||||
dates_first_page The first page of articles, ordered by date,
|
||||
ascending.
|
||||
dates_previous_page The previous page of articles, ordered by date,
|
||||
ascending (``None`` if page does not exist)
|
||||
dates_next_page The next page of articles, ordered by date,
|
||||
ascending (``None`` if page does not exist)
|
||||
dates_last_page The last page of articles, ordered by date,
|
||||
ascending.
|
||||
page_name CATEGORY_URL where everything after `{slug}` is
|
||||
removed -- useful for pagination links
|
||||
====================== ===================================================
|
||||
|
|
@ -311,24 +293,18 @@ dates Articles related to this tag, but ordered by date,
|
|||
ascending
|
||||
articles_paginator A paginator object for the list of articles
|
||||
articles_page The current page of articles
|
||||
articles_first_page The first page of articles
|
||||
articles_previous_page The previous page of articles (``None`` if page does
|
||||
not exist)
|
||||
articles_next_page The next page of articles (``None`` if page does
|
||||
not exist)
|
||||
articles_last_page The first page of articles
|
||||
dates_paginator A paginator object for the list of articles,
|
||||
ordered by date, ascending
|
||||
dates_page The current page of articles, ordered by date,
|
||||
ascending
|
||||
dates_first_page The first page of articles, ordered by date,
|
||||
ascending.
|
||||
dates_previous_page The previous page of articles, ordered by date,
|
||||
ascending (``None`` if page does not exist)
|
||||
dates_next_page The next page of articles, ordered by date,
|
||||
ascending (``None`` if page does not exist)
|
||||
dates_last_page The last page of articles, ordered by date,
|
||||
ascending.
|
||||
page_name TAG_URL where everything after `{slug}` is removed
|
||||
-- useful for pagination links
|
||||
====================== ===================================================
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
{% if DEFAULT_PAGINATION %}
|
||||
{% set first_page = articles_paginator.page(1) %}
|
||||
{% set last_page = articles_paginator.page(articles_paginator.num_pages) %}
|
||||
<p class="paginator">
|
||||
{% if articles_page.has_previous() %}
|
||||
<a href="{{ SITEURL }}/{{ first_page.url }}">⇇</a>
|
||||
<a href="{{ SITEURL }}/{{ articles_previous_page.url }}">«</a>
|
||||
{% endif %}
|
||||
Page {{ articles_page.number }} / {{ articles_paginator.num_pages }}
|
||||
{% if articles_page.has_next() %}
|
||||
<a href="{{ SITEURL }}/{{ articles_next_page.url }}">»</a>
|
||||
<a href="{{ SITEURL }}/{{ last_page.url }}">⇉</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -248,20 +248,16 @@ class Writer(object):
|
|||
paginated_kwargs = kwargs.copy()
|
||||
for key in paginators.keys():
|
||||
paginator = paginators[key]
|
||||
first_page = paginator.page(1)
|
||||
previous_page = paginator.page(page_num) \
|
||||
if page_num > 0 else None
|
||||
page = paginator.page(page_num + 1)
|
||||
next_page = paginator.page(page_num + 2) \
|
||||
if page_num + 1 < paginator.num_pages else None
|
||||
last_page = paginator.page(paginator.num_pages)
|
||||
paginated_kwargs.update(
|
||||
{'%s_paginator' % key: paginator,
|
||||
'%s_page' % key: page,
|
||||
'%s_first_page' % key: first_page,
|
||||
'%s_previous_page' % key: previous_page,
|
||||
'%s_next_page' % key: next_page,
|
||||
'%s_last_page' % key: last_page})
|
||||
'%s_next_page' % key: next_page})
|
||||
|
||||
localcontext = _get_localcontext(
|
||||
context, page.save_as, paginated_kwargs, relative_urls)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue