diff options
author | James Taylor <user234683@users.noreply.github.com> | 2020-12-17 12:27:38 -0800 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2020-12-18 23:00:33 -0500 |
commit | cf7aa4189386a4d4ffd8eb2cc80992fe1603f0c1 (patch) | |
tree | 74c06387e9eddc6287500a1a0aa92fe84a793cd0 /youtube/templates/common_elements.html | |
parent | e27650b457dc64b3a3990c1eadd7d8cb0789ba1d (diff) | |
download | yt-local-cf7aa4189386a4d4ffd8eb2cc80992fe1603f0c1.tar.lz yt-local-cf7aa4189386a4d4ffd8eb2cc80992fe1603f0c1.tar.xz yt-local-cf7aa4189386a4d4ffd8eb2cc80992fe1603f0c1.zip |
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>
Diffstat (limited to 'youtube/templates/common_elements.html')
-rw-r--r-- | youtube/templates/common_elements.html | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/youtube/templates/common_elements.html b/youtube/templates/common_elements.html index fcd4125..9ccafeb 100644 --- a/youtube/templates/common_elements.html +++ b/youtube/templates/common_elements.html @@ -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) %} |