|
|
@ -340,8 +340,6 @@ def changedetection_app(config=None, datastore_o=None):
|
|
|
|
if len(dates) < 2:
|
|
|
|
if len(dates) < 2:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
prev_fname = watch.history[dates[-2]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not watch.viewed:
|
|
|
|
if not watch.viewed:
|
|
|
|
# Re #239 - GUID needs to be individual for each event
|
|
|
|
# Re #239 - GUID needs to be individual for each event
|
|
|
|
# @todo In the future make this a configurable link back (see work on BASE_URL https://github.com/dgtlmoon/changedetection.io/pull/228)
|
|
|
|
# @todo In the future make this a configurable link back (see work on BASE_URL https://github.com/dgtlmoon/changedetection.io/pull/228)
|
|
|
@ -362,9 +360,12 @@ def changedetection_app(config=None, datastore_o=None):
|
|
|
|
|
|
|
|
|
|
|
|
watch_title = watch.get('title') if watch.get('title') else watch.get('url')
|
|
|
|
watch_title = watch.get('title') if watch.get('title') else watch.get('url')
|
|
|
|
fe.title(title=watch_title)
|
|
|
|
fe.title(title=watch_title)
|
|
|
|
latest_fname = watch.history[dates[-1]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
html_diff = diff.render_diff(prev_fname, latest_fname, include_equal=False, line_feed_sep="<br>")
|
|
|
|
html_diff = diff.render_diff(previous_version_file_contents=watch.get_history_snapshot(dates[-2]),
|
|
|
|
|
|
|
|
newest_version_file_contents=watch.get_history_snapshot(dates[-1]),
|
|
|
|
|
|
|
|
include_equal=False,
|
|
|
|
|
|
|
|
line_feed_sep="<br>")
|
|
|
|
|
|
|
|
|
|
|
|
fe.content(content="<html><body><h4>{}</h4>{}</body></html>".format(watch_title, html_diff),
|
|
|
|
fe.content(content="<html><body><h4>{}</h4>{}</body></html>".format(watch_title, html_diff),
|
|
|
|
type='CDATA')
|
|
|
|
type='CDATA')
|
|
|
|
|
|
|
|
|
|
|
@ -847,28 +848,22 @@ def changedetection_app(config=None, datastore_o=None):
|
|
|
|
# Save the current newest history as the most recently viewed
|
|
|
|
# Save the current newest history as the most recently viewed
|
|
|
|
datastore.set_last_viewed(uuid, time.time())
|
|
|
|
datastore.set_last_viewed(uuid, time.time())
|
|
|
|
|
|
|
|
|
|
|
|
newest_file = history[dates[-1]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Read as binary and force decode as UTF-8
|
|
|
|
# Read as binary and force decode as UTF-8
|
|
|
|
# Windows may fail decode in python if we just use 'r' mode (chardet decode exception)
|
|
|
|
# Windows may fail decode in python if we just use 'r' mode (chardet decode exception)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
with open(newest_file, 'r', encoding='utf-8', errors='ignore') as f:
|
|
|
|
newest_version_file_contents = watch.get_history_snapshot(dates[-1])
|
|
|
|
newest_version_file_contents = f.read()
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
newest_version_file_contents = "Unable to read {}.\n".format(newest_file)
|
|
|
|
newest_version_file_contents = "Unable to read {}.\n".format(dates[-1])
|
|
|
|
|
|
|
|
|
|
|
|
previous_version = request.args.get('previous_version')
|
|
|
|
previous_version = request.args.get('previous_version')
|
|
|
|
try:
|
|
|
|
previous_timestamp = dates[-2]
|
|
|
|
previous_file = history[previous_version]
|
|
|
|
if previous_version:
|
|
|
|
except KeyError:
|
|
|
|
previous_timestamp = previous_version
|
|
|
|
# Not present, use a default value, the second one in the sorted list.
|
|
|
|
|
|
|
|
previous_file = history[dates[-2]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
with open(previous_file, 'r', encoding='utf-8', errors='ignore') as f:
|
|
|
|
previous_version_file_contents = watch.get_history_snapshot(previous_timestamp)
|
|
|
|
previous_version_file_contents = f.read()
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
previous_version_file_contents = "Unable to read {}.\n".format(previous_file)
|
|
|
|
previous_version_file_contents = "Unable to read {}.\n".format(previous_timestamp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screenshot_url = watch.get_screenshot()
|
|
|
|
screenshot_url = watch.get_screenshot()
|
|
|
@ -948,21 +943,19 @@ def changedetection_app(config=None, datastore_o=None):
|
|
|
|
return output
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
|
|
|
timestamp = list(watch.history.keys())[-1]
|
|
|
|
timestamp = list(watch.history.keys())[-1]
|
|
|
|
filename = watch.history[timestamp]
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
with open(filename, 'r', encoding='utf-8', errors='ignore') as f:
|
|
|
|
tmp = watch.get_history_snapshot(timestamp).splitlines()
|
|
|
|
tmp = f.readlines()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get what needs to be highlighted
|
|
|
|
# Get what needs to be highlighted
|
|
|
|
ignore_rules = watch.get('ignore_text', []) + datastore.data['settings']['application']['global_ignore_text']
|
|
|
|
ignore_rules = watch.get('ignore_text', []) + datastore.data['settings']['application']['global_ignore_text']
|
|
|
|
|
|
|
|
|
|
|
|
# .readlines will keep the \n, but we will parse it here again, in the future tidy this up
|
|
|
|
# .readlines will keep the \n, but we will parse it here again, in the future tidy this up
|
|
|
|
ignored_line_numbers = html_tools.strip_ignore_text(content="".join(tmp),
|
|
|
|
ignored_line_numbers = html_tools.strip_ignore_text(content="\n".join(tmp),
|
|
|
|
wordlist=ignore_rules,
|
|
|
|
wordlist=ignore_rules,
|
|
|
|
mode='line numbers'
|
|
|
|
mode='line numbers'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
trigger_line_numbers = html_tools.strip_ignore_text(content="".join(tmp),
|
|
|
|
trigger_line_numbers = html_tools.strip_ignore_text(content="\n".join(tmp),
|
|
|
|
wordlist=watch['trigger_text'],
|
|
|
|
wordlist=watch['trigger_text'],
|
|
|
|
mode='line numbers'
|
|
|
|
mode='line numbers'
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -978,7 +971,7 @@ def changedetection_app(config=None, datastore_o=None):
|
|
|
|
content.append({'line': l, 'classes': ' '.join(classes)})
|
|
|
|
content.append({'line': l, 'classes': ' '.join(classes)})
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
content.append({'line': "File doesnt exist or unable to read file {}".format(filename), 'classes': ''})
|
|
|
|
content.append({'line': f"File doesnt exist or unable to read timestamp {timestamp}", 'classes': ''})
|
|
|
|
|
|
|
|
|
|
|
|
output = render_template("preview.html",
|
|
|
|
output = render_template("preview.html",
|
|
|
|
content=content,
|
|
|
|
content=content,
|
|
|
|