From 3034d17c061460613f61d3f3832e32f8186a7485 Mon Sep 17 00:00:00 2001 From: Leigh Morresi <275001+dgtlmoon@users.noreply.github.com> Date: Tue, 2 Feb 2021 23:26:16 +0100 Subject: [PATCH] Adding new [Scrub All Version History] button under [settings] (But keep your URL list) --- backend/backend.py | 29 ++++++++++++++++++++++ backend/templates/scrub.html | 43 +++++++++++++++++++++++++++++++++ backend/templates/settings.html | 4 ++- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 backend/templates/scrub.html diff --git a/backend/backend.py b/backend/backend.py index 248c58b7..fb4d1db5 100644 --- a/backend/backend.py +++ b/backend/backend.py @@ -117,6 +117,35 @@ def main_page(): messages = [] return output +@app.route("/scrub", methods=['GET', 'POST']) +def scrub_page(): + from pathlib import Path + + global messages + + if request.method == 'POST': + confirmtext = request.form.get('confirmtext') + + if confirmtext == 'scrub': + + for txt_file_path in Path('/datastore').rglob('*.txt'): + os.unlink(txt_file_path) + + for uuid, watch in datastore.data['watching'].items(): + watch['last_checked'] = 0 + watch['last_changed'] = 0 + watch['previous_md5'] = None + watch['history'] = {} + + datastore.needs_write = True + messages.append({'class': 'ok', 'message': 'Cleaned all version history.'}) + else: + messages.append({'class': 'error', 'message': 'Wrong confirm text.'}) + + return redirect(url_for('main_page')) + + return render_template("scrub.html") + @app.route("/edit", methods=['GET', 'POST']) def edit_page(): diff --git a/backend/templates/scrub.html b/backend/templates/scrub.html new file mode 100644 index 00000000..12a140ba --- /dev/null +++ b/backend/templates/scrub.html @@ -0,0 +1,43 @@ +{% extends 'base.html' %} + +{% block content %} +
+ + +
+
+
+ This will remove all version snapshots/data, but keep your list of URLs.
+ You may like to use the BACKUP link first.
+ + Type in the word scrub to confirm that you understand! +
+ +
+ +
+
+
+ +
+ + +
+ + +
+ +
+
+
+ Cancel +
+ + +
+
+ + +
+ +{% endblock %} diff --git a/backend/templates/settings.html b/backend/templates/settings.html index c6b2e665..8e1e6967 100644 --- a/backend/templates/settings.html +++ b/backend/templates/settings.html @@ -14,13 +14,15 @@ +

- Cancel + Back + Reset all version data