From b77582a167a76beba7985a114360909201002109 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Tue, 16 Aug 2022 10:04:17 +0200 Subject: [PATCH] WIP --- changedetectionio/__init__.py | 2 +- changedetectionio/templates/_pagination.jinja | 7 +++++++ changedetectionio/templates/watch-overview.html | 9 ++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 changedetectionio/templates/_pagination.jinja diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index d503a1fb..07558d8a 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -76,7 +76,7 @@ app.config['LOGIN_DISABLED'] = False # Disables caching of the templates app.config['TEMPLATES_AUTO_RELOAD'] = True - +app.jinja_env.add_extension('jinja2.ext.loopcontrols') csrf = CSRFProtect() csrf.init_app(app) diff --git a/changedetectionio/templates/_pagination.jinja b/changedetectionio/templates/_pagination.jinja new file mode 100644 index 00000000..0dce3d8e --- /dev/null +++ b/changedetectionio/templates/_pagination.jinja @@ -0,0 +1,7 @@ +{% macro pagination(sorted_watches, total_per_page, current_page) %} + {{ sorted_watches|length }} + + {% for row in sorted_watches|batch(total_per_page, ' ') %} + {{ loop.index}} + {% endfor %} +{% endmacro %} diff --git a/changedetectionio/templates/watch-overview.html b/changedetectionio/templates/watch-overview.html index e71911ef..ef382867 100644 --- a/changedetectionio/templates/watch-overview.html +++ b/changedetectionio/templates/watch-overview.html @@ -1,6 +1,7 @@ {% extends 'base.html' %} {% block content %} {% from '_helpers.jinja' import render_simple_field, render_field %} +{% from '_pagination.jinja' import pagination %} @@ -34,6 +35,7 @@ {% set sort_order = request.args.get('order', 'desc') == 'desc' %} {% set sort_attribute = request.args.get('sort', 'last_changed') %} + {% set pagination_page = request.args.get('page', 0) %}
@@ -50,7 +52,11 @@ - {% for watch in watches|sort(attribute=sort_attribute, reverse=sort_order) %} + {% set sorted_watches = watches|sort(attribute=sort_attribute, reverse=sort_order) %} + {% for watch in sorted_watches %} + + {% if not ( loop.index >= 3 and loop.index <=4) %}{% continue %}{% endif %} + RSS Feed + {{ pagination(sorted_watches,3, pagination_page) }} {% endblock %}