channel: include first and last pages when sorting by new
Last page as a substitute for sorting by oldest since sorting by oldest doesn't allow arbitrary page numbers Signed-off-by: Jesús <heckyel@hyperbola.info>
This commit is contained in:
parent
e27650b457
commit
cf7aa41893
@ -107,7 +107,7 @@
|
||||
<footer class="pagination-container">
|
||||
{% if current_tab == 'videos' %}
|
||||
<nav class="pagination-list">
|
||||
{{ common_elements.page_buttons(number_of_pages, channel_url + '/' + current_tab, parameters_dictionary) }}
|
||||
{{ common_elements.page_buttons(number_of_pages, channel_url + '/' + current_tab, parameters_dictionary, include_ends=(current_sort.__str__() == '3')) }}
|
||||
</nav>
|
||||
{% elif current_tab == 'search' %}
|
||||
<nav class="next-previous-button-row">
|
||||
|
@ -66,7 +66,7 @@
|
||||
</article>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro page_buttons(estimated_pages, url, parameters_dictionary) %}
|
||||
{% macro page_buttons(estimated_pages, url, parameters_dictionary, include_ends=false) %}
|
||||
{% set current_page = parameters_dictionary.get('page', 1)|int %}
|
||||
{% set parameters_dictionary = parameters_dictionary.to_dict() %}
|
||||
{% if current_page is le(5) %}
|
||||
@ -77,17 +77,26 @@
|
||||
{% set page_end = [current_page + 4, estimated_pages]|min %}
|
||||
{% endif %}
|
||||
|
||||
{% if include_ends and page_start is gt(1) %}
|
||||
{% set _ = parameters_dictionary.__setitem__('page', 1) %}
|
||||
<a class="page-link first-page-button" href="{{ url + '?' + parameters_dictionary|urlencode }}">{{ 1 }}</a>
|
||||
{% endif %}
|
||||
|
||||
{% for page in range(page_start, page_end+1) %}
|
||||
{% if page == current_page %}
|
||||
<div class="page-link is-current">{{ page }}</div>
|
||||
{% else %}
|
||||
{# IMPORTANT: Jinja SUCKS #}
|
||||
{# https://stackoverflow.com/questions/36886650/how-to-add-a-new-entry-into-a-dictionary-object-while-using-jinja2 #}
|
||||
{% set _ = parameters_dictionary.__setitem__('page', page) %}
|
||||
<a class="page-link" href="{{ url + '?' + parameters_dictionary|urlencode }}">{{ page }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if include_ends and page_end is lt(estimated_pages) %}
|
||||
{% set _ = parameters_dictionary.__setitem__('page', estimated_pages) %}
|
||||
<a class="page-link last-page-button" href="{{ url + '?' + parameters_dictionary|urlencode }}">{{ estimated_pages }}</a>
|
||||
{% endif %}
|
||||
|
||||
{% endmacro %}
|
||||
|
||||
{% macro next_previous_buttons(is_last_page, url, parameters_dictionary) %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user