From d32640d8927edd64e0e14090d4611065ed5f0604 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 10 Oct 2024 13:12:23 +0200 Subject: [PATCH] highlight ignore lines --- .../processors/text_json_diff/__init__.py | 15 +++++++++++++-- changedetectionio/static/js/watch-settings.js | 7 ++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/changedetectionio/processors/text_json_diff/__init__.py b/changedetectionio/processors/text_json_diff/__init__.py index ed0746f2..6a5efad9 100644 --- a/changedetectionio/processors/text_json_diff/__init__.py +++ b/changedetectionio/processors/text_json_diff/__init__.py @@ -46,6 +46,9 @@ def prepare_filter_prevew(datastore, watch_uuid): text_after_filter = '' text_before_filter = '' + trigger_line_numbers = [] + ignore_line_numbers = [] + tmp_watch = deepcopy(datastore.data['watching'].get(watch_uuid)) if tmp_watch and tmp_watch.history and os.path.isdir(tmp_watch.watch_data_dir): @@ -84,9 +87,7 @@ def prepare_filter_prevew(datastore, watch_uuid): text_after_filter = future1.result() text_before_filter = future2.result() - trigger_line_numbers = [] try: - trigger_line_numbers = html_tools.strip_ignore_text(content=text_after_filter, wordlist=tmp_watch['trigger_text'], mode='line numbers' @@ -94,6 +95,15 @@ def prepare_filter_prevew(datastore, watch_uuid): except Exception as e: text_before_filter = f"Error: {str(e)}" + try: + text_to_ignore = tmp_watch.get('ignore_text', []) + datastore.data['settings']['application'].get('global_ignore_text', []) + ignore_line_numbers = html_tools.strip_ignore_text(content=text_after_filter, + wordlist=text_to_ignore, + mode='line numbers' + ) + except Exception as e: + text_before_filter = f"Error: {str(e)}" + logger.trace(f"Parsed in {time.time() - now:.3f}s") return jsonify( @@ -102,6 +112,7 @@ def prepare_filter_prevew(datastore, watch_uuid): 'before_filter': text_before_filter.decode('utf-8') if isinstance(text_before_filter, bytes) else text_before_filter, 'duration': time.time() - now, 'trigger_line_numbers': trigger_line_numbers, + 'ignore_line_numbers': ignore_line_numbers, } ) diff --git a/changedetectionio/static/js/watch-settings.js b/changedetectionio/static/js/watch-settings.js index f3360dbe..93842c51 100644 --- a/changedetectionio/static/js/watch-settings.js +++ b/changedetectionio/static/js/watch-settings.js @@ -43,7 +43,12 @@ function request_textpreview_update() { 'color': '#ee0000', 'lines': data['trigger_line_numbers'] } - ]); + ]).highlightLines([ + { + 'color': '#757575', + 'lines': data['ignore_line_numbers'] + } + ]) }).fail(function (error) { if (error.statusText === 'abort') { console.log('Request was aborted due to a new request being fired.');