aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/templates/common_elements.html
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2019-12-23 14:39:59 -0800
committerJames Taylor <user234683@users.noreply.github.com>2019-12-23 14:39:59 -0800
commit777ed756dcfd01845451937fb38559ee57ec44e9 (patch)
treedebc2f6db7a6d0b5021e2f3480a6067397a71581 /youtube/templates/common_elements.html
parentc56fc56fa66242ae75a5b8f3e9c697f0f23c253a (diff)
downloadyt-local-777ed756dcfd01845451937fb38559ee57ec44e9.tar.lz
yt-local-777ed756dcfd01845451937fb38559ee57ec44e9.tar.xz
yt-local-777ed756dcfd01845451937fb38559ee57ec44e9.zip
Channel: Change search results to use next and previous page buttons
Because youtube doesn't give the number of search results, so previous behavior would give an error if a page number out of range was selected.
Diffstat (limited to 'youtube/templates/common_elements.html')
-rw-r--r--youtube/templates/common_elements.html15
1 files changed, 15 insertions, 0 deletions
diff --git a/youtube/templates/common_elements.html b/youtube/templates/common_elements.html
index 7914c08..8ee0a3c 100644
--- a/youtube/templates/common_elements.html
+++ b/youtube/templates/common_elements.html
@@ -90,3 +90,18 @@
{% endfor %}
{% endmacro %}
+
+{% macro next_previous_buttons(is_last_page, url, parameters_dictionary) %}
+ {% set current_page = parameters_dictionary.get('page', 1)|int %}
+ {% set parameters_dictionary = parameters_dictionary.to_dict() %}
+
+ {% if current_page != 1 %}
+ {% set _ = parameters_dictionary.__setitem__('page', current_page - 1) %}
+ <a class="page-button previous-page" href="{{ url + '?' + parameters_dictionary|urlencode }}">Previous page</a>
+ {% endif %}
+
+ {% if not is_last_page %}
+ {% set _ = parameters_dictionary.__setitem__('page', current_page + 1) %}
+ <a class="page-button next-page" href="{{ url + '?' + parameters_dictionary|urlencode }}">Next page</a>
+ {% endif %}
+{% endmacro %}