diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index 67d2f0be..11c8cb81 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -124,6 +124,15 @@ def _jinja2_filter_datetimestamp(timestamp, format="%Y-%m-%d %H:%M:%S"): return timeago.format(timestamp, time.time()) + +@app.template_filter('pagination_slice') +def _jinja2_filter_pagination_slice(arr, skip): + per_page = datastore.data['settings']['application'].get('pager_size', 50) + if per_page: + return arr[skip:skip + per_page] + + return arr + @app.template_filter('format_seconds_ago') def _jinja2_filter_seconds_precise(timestamp): if timestamp == False: @@ -432,7 +441,11 @@ def changedetection_app(config=None, datastore_o=None): form = forms.quickWatchForm(request.form) page = request.args.get(get_page_parameter(), type=int, default=1) total_count = len(sorted_watches) - pagination = Pagination(page=page, total=total_count, per_page=int(os.getenv('pagination_per_page', 50)), css_framework = "semantic") + + pagination = Pagination(page=page, + total=total_count, + per_page=datastore.data['settings']['application'].get('pager_size', 50), css_framework="semantic") + output = render_template( "watch-overview.html", diff --git a/changedetectionio/forms.py b/changedetectionio/forms.py index 55566a01..1cca60cf 100644 --- a/changedetectionio/forms.py +++ b/changedetectionio/forms.py @@ -481,6 +481,10 @@ class globalSettingsApplicationForm(commonSettingsForm): global_subtractive_selectors = StringListField('Remove elements', [ValidateCSSJSONXPATHInput(allow_xpath=False, allow_json=False)]) ignore_whitespace = BooleanField('Ignore whitespace') password = SaltyPasswordField() + pager_size = IntegerField('Pager size', + render_kw={"style": "width: 5em;"}, + validators=[validators.NumberRange(min=0, + message="Should be atleast zero (disabled)")]) removepassword_button = SubmitField('Remove password', render_kw={"class": "pure-button pure-button-primary"}) render_anchor_tag_content = BooleanField('Render anchor tag content', default=False) shared_diff_access = BooleanField('Allow access to view diff page when password is enabled', default=False, validators=[validators.Optional()]) diff --git a/changedetectionio/model/App.py b/changedetectionio/model/App.py index 54580b3d..29d3e49b 100644 --- a/changedetectionio/model/App.py +++ b/changedetectionio/model/App.py @@ -23,25 +23,26 @@ class model(dict): 'workers': int(getenv("DEFAULT_SETTINGS_REQUESTS_WORKERS", "10")), # Number of threads, lower is better for slow connections }, 'application': { + # Custom notification content 'api_access_token_enabled': True, - 'password': False, 'base_url' : None, - 'extract_title_as_title': False, 'empty_pages_are_a_change': False, + 'extract_title_as_title': False, 'fetch_backend': getenv("DEFAULT_FETCH_BACKEND", "html_requests"), 'filter_failure_notification_threshold_attempts': _FILTER_FAILURE_THRESHOLD_ATTEMPTS_DEFAULT, 'global_ignore_text': [], # List of text to ignore when calculating the comparison checksum 'global_subtractive_selectors': [], 'ignore_whitespace': True, - 'render_anchor_tag_content': False, - 'notification_urls': [], # Apprise URL list - # Custom notification content - 'notification_title': default_notification_title, 'notification_body': default_notification_body, 'notification_format': default_notification_format, + 'notification_title': default_notification_title, + 'notification_urls': [], # Apprise URL list + 'pager_size': 50, + 'password': False, + 'render_anchor_tag_content': False, 'schema_version' : 0, 'shared_diff_access': False, - 'webdriver_delay': None # Extra delay in seconds before extracting text + 'webdriver_delay': None , # Extra delay in seconds before extracting text } } } diff --git a/changedetectionio/templates/settings.html b/changedetectionio/templates/settings.html index 138e683d..078d4fab 100644 --- a/changedetectionio/templates/settings.html +++ b/changedetectionio/templates/settings.html @@ -70,6 +70,10 @@ read more here. +
+ {{ render_field(form.application.form.pager_size) }} + Number of items per page in the watch overview list, 0 to disable. +
{{ render_checkbox_field(form.application.form.extract_title_as_title) }} diff --git a/changedetectionio/templates/watch-overview.html b/changedetectionio/templates/watch-overview.html index 111ea8a0..fe61f626 100644 --- a/changedetectionio/templates/watch-overview.html +++ b/changedetectionio/templates/watch-overview.html @@ -79,7 +79,7 @@ No website watches configured, please add a URL in the box above, or import a list. {% endif %} - {% for watch in (watches|sort(attribute=sort_attribute, reverse=sort_order == 'asc'))[pagination.skip:pagination.skip+pagination.per_page] %} + {% for watch in (watches|sort(attribute=sort_attribute, reverse=sort_order == 'asc'))|pagination_slice(skip=pagination.skip) %}