Some work around diff viewing

pull/419/head
dgtlmoon 3 years ago
parent ddd7b2772d
commit 7a66b69158

@ -695,7 +695,7 @@ def changedetection_app(config=None, datastore_o=None):
@app.route("/diff/<string:uuid>", methods=['GET']) @app.route("/diff/<string:uuid>", methods=['GET'])
@login_required @login_required
def diff_history_page(uuid): def diff_history_page(uuid):
from changedetectionio import content_fetcher
# More for testing, possible to return the first/only # More for testing, possible to return the first/only
if uuid == 'first': if uuid == 'first':
uuid = list(datastore.data['watching'].keys()).pop() uuid = list(datastore.data['watching'].keys()).pop()
@ -734,7 +734,13 @@ def changedetection_app(config=None, datastore_o=None):
with open(previous_file, 'r') as f: with open(previous_file, 'r') as f:
previous_version_file_contents = f.read() previous_version_file_contents = f.read()
output = render_template("diff.html", watch_a=watch, if ('content-type' in watch and content_fetcher.supported_binary_type(watch['content-type'])):
template = "diff-image.html"
else:
template = "diff.html"
output = render_template(template,
watch_a=watch,
newest=newest_version_file_contents, newest=newest_version_file_contents,
previous=previous_version_file_contents, previous=previous_version_file_contents,
extra_stylesheets=extra_stylesheets, extra_stylesheets=extra_stylesheets,
@ -751,6 +757,7 @@ def changedetection_app(config=None, datastore_o=None):
@app.route("/preview/<string:uuid>", methods=['GET']) @app.route("/preview/<string:uuid>", methods=['GET'])
@login_required @login_required
def preview_page(uuid): def preview_page(uuid):
from changedetectionio import content_fetcher
# More for testing, possible to return the first/only # More for testing, possible to return the first/only
if uuid == 'first': if uuid == 'first':
@ -765,14 +772,25 @@ def changedetection_app(config=None, datastore_o=None):
return redirect(url_for('index')) return redirect(url_for('index'))
newest = list(watch['history'].keys())[-1] newest = list(watch['history'].keys())[-1]
with open(watch['history'][newest], 'r') as f: fname = watch['history'][newest]
content = f.readlines()
if ('content-type' in watch and content_fetcher.supported_binary_type(watch['content-type'])):
template = "preview-image.html"
content = fname
else:
template = "preview.html"
try:
with open(fname, 'r') as f:
content = f.read()
except:
content = "Cant read {}".format(fname)
output = render_template("preview.html", output = render_template("preview.html",
content=content, content=content,
extra_stylesheets=extra_stylesheets, extra_stylesheets=extra_stylesheets,
current_diff_url=watch['url'], current_diff_url=watch['url'],
uuid=uuid) uuid=uuid,
watch=watch)
return output return output
@app.route("/settings/notification-logs", methods=['GET']) @app.route("/settings/notification-logs", methods=['GET'])

@ -0,0 +1,33 @@
{% extends 'base.html' %}
{% block content %}
<div id="settings">
<h1>Differences</h1>
<form class="pure-form " action="" method="GET">
<fieldset>
{% if versions|length >= 1 %}
<label for="diff-version">Compare newest (<span id="current-v-date"></span>) with</label>
<select id="diff-version" name="previous_version">
{% for version in versions %}
<option value="{{version}}" {% if version== current_previous_version %} selected="" {% endif %}>
{{version}}
</option>
{% endfor %}
</select>
<button type="submit" class="pure-button pure-button-primary">Go</button>
{% endif %}
</fieldset>
</form>
</div>
<div id="diff-ui">
</div>
<script type="text/javascript" src="{{url_for('static_content', group='js', filename='diff.js')}}"></script>
{% endblock %}

@ -0,0 +1,13 @@
{% extends 'base.html' %}
{% block content %}
<div id="settings">
<h1>Current</h1>
</div>
<div id="diff-ui">
image goes here
</div>
{% endblock %}

@ -11,7 +11,7 @@
<tbody> <tbody>
<tr> <tr>
<td id="diff-col"> <td id="diff-col">
<span id="result">{% for row in content %}{{row}}{% endfor %}</span> <span id="result">{{content}}</span>
</td> </td>
</tr> </tr>
</tbody> </tbody>

Loading…
Cancel
Save