aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--youtube/templates/channel.html2
-rw-r--r--youtube/templates/common_elements.html13
2 files changed, 12 insertions, 3 deletions
diff --git a/youtube/templates/channel.html b/youtube/templates/channel.html
index 7ac36d4..780b651 100644
--- a/youtube/templates/channel.html
+++ b/youtube/templates/channel.html
@@ -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">
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) %}