Re #92 - Re-use existing [preview] function for viewing current (#97)

pull/99/head
dgtlmoon 4 years ago committed by GitHub
parent 53b9640ac5
commit 8bcc277310
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -584,6 +584,7 @@ def changedetection_app(config=None, datastore_o=None):
previous=previous_version_file_contents, previous=previous_version_file_contents,
extra_stylesheets=extra_stylesheets, extra_stylesheets=extra_stylesheets,
versions=dates[1:], versions=dates[1:],
uuid=uuid,
newest_version_timestamp=dates[0], newest_version_timestamp=dates[0],
current_previous_version=str(previous_version), current_previous_version=str(previous_version),
current_diff_url=watch['url']) current_diff_url=watch['url'])
@ -606,11 +607,15 @@ def changedetection_app(config=None, datastore_o=None):
flash("No history found for the specified link, bad link?", "error") flash("No history found for the specified link, bad link?", "error")
return redirect(url_for('index')) return redirect(url_for('index'))
print(watch) newest = list(watch['history'].keys())[-1]
with open(list(watch['history'].values())[-1], 'r') as f: with open(watch['history'][newest], 'r') as f:
content = f.readlines() content = f.readlines()
output = render_template("preview.html", content=content, extra_stylesheets=extra_stylesheets) output = render_template("preview.html",
content=content,
extra_stylesheets=extra_stylesheets,
current_diff_url=watch['url'],
uuid=uuid)
return output return output

@ -33,6 +33,7 @@
<ul class="pure-menu-list"> <ul class="pure-menu-list">
{% if current_user.is_authenticated or not has_password %} {% if current_user.is_authenticated or not has_password %}
{% if not current_diff_url %}
<li class="pure-menu-item"> <li class="pure-menu-item">
<a href="/backup" class="pure-menu-link">BACKUP</a> <a href="/backup" class="pure-menu-link">BACKUP</a>
</li> </li>
@ -42,6 +43,11 @@
<li class="pure-menu-item"> <li class="pure-menu-item">
<a href="/settings" class="pure-menu-link">SETTINGS</a> <a href="/settings" class="pure-menu-link">SETTINGS</a>
</li> </li>
{% else %}
<li class="pure-menu-item">
<a href="{{ url_for('edit_page', uuid=uuid) }}" class="pure-menu-link">EDIT</a>
</li>
{% endif %}
{% else %} {% else %}
<li class="pure-menu-item"> <li class="pure-menu-item">
<a class="pure-menu-link" href="https://github.com/dgtlmoon/changedetection.io">Website Change Detection and Notification.</a> <a class="pure-menu-link" href="https://github.com/dgtlmoon/changedetection.io">Website Change Detection and Notification.</a>

@ -30,6 +30,7 @@
</form> </form>
<del>Removed text</del> <del>Removed text</del>
<ins>Inserted Text</ins> <ins>Inserted Text</ins>
<a href="{{ url_for('preview_page', uuid=uuid) }}">Show current snapshot</a>
</div> </div>
<div id="diff-jump"> <div id="diff-jump">

Loading…
Cancel
Save