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/model/Watch.py b/changedetectionio/model/Watch.py index 50f792b0..c5e27d54 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -83,6 +83,13 @@ class model(dict): return False + @property + def label(self): + # Used for sorting + if self['title']: + return self['title'] + return self['url'] + @property def last_changed(self): # last_changed will be the newest snapshot, but when we have just one snapshot, it should be 0 diff --git a/changedetectionio/store.py b/changedetectionio/store.py index afcc9cb6..1f2ae453 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -529,3 +529,13 @@ class ChangeDetectionStore: def update_3(self): # see https://github.com/dgtlmoon/changedetection.io/pull/835 return + + # `last_changed` not needed, we pull that information from the history.txt index + def update_4(self): + for uuid, watch in self.data['watching'].items(): + try: + # Remove it from the struct + del(watch['last_changed']) + except: + continue + return \ No newline at end of file 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 493bf65d..e514e0a7 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 %} @@ -32,22 +33,31 @@ {% endfor %} + {% 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) %} +
- - - + {% set link_order = "asc" if sort_order else "desc" %} + + + + {% set sorted_watches = watches|sort(attribute=sort_attribute, reverse=sort_order) %} + {% for watch in sorted_watches %} - {% for watch in watches|sort(attribute='last_changed', reverse=True) %} + {# WIP for pagination, disabled for now + {% if not ( loop.index >= 3 and loop.index <=4) %}{% continue %}{% endif %} --> + #} RSS Feed + {# WIP for pagination, disabled for now + {{ pagination(sorted_watches,3, pagination_page) }} + #} + {% endblock %}
# Last CheckedLast ChangedWebsiteLast CheckedLast Changed