diff --git a/backend/backend.py b/backend/backend.py index 88e18968..79b2dd07 100644 --- a/backend/backend.py +++ b/backend/backend.py @@ -187,18 +187,28 @@ def diff_history_page(uuid): dates = list(watch['history'].keys()) dates = [int(i) for i in dates] dates.sort(reverse=True) + dates = [str(i) for i in dates] + left_file_contents = right_file_contents = "" l_file = watch['history'][str(dates[-1])] with open(l_file, 'r') as f: left_file_contents = f.read() - r_file = watch['history'][str(dates[-2])] + previous_version = request.args.get('previous_version') + try: + r_file = watch['history'][str(previous_version)] + except KeyError: + # Not present, use a default value + r_file = watch['history'][str(dates[-2])] + with open(r_file, 'r') as f: right_file_contents = f.read() + #print (dates, l_file, r_file) output = render_template("diff.html", watch_a=watch, messages=messages, left=left_file_contents, - right=right_file_contents, extra_stylesheets=extra_stylesheets) + right=right_file_contents, extra_stylesheets=extra_stylesheets, versions=dates[:-1], + current_previous_version=str(previous_version)) return output @app.route("/favicon.ico", methods=['GET']) diff --git a/backend/static/css/diff.css b/backend/static/css/diff.css index 74b19883..491581d1 100644 --- a/backend/static/css/diff.css +++ b/backend/static/css/diff.css @@ -32,12 +32,17 @@ ins { } #settings { - - - line-height: 2em; + background: rgba(0,0,0,.05); + padding: 1em; + border-radius: 10px; + margin-bottom: 1em; + color: #fff; + font-size: 80%; } #settings label { margin-left: 1em; + display: inline-block; + font-weight: normal; } .source { @@ -53,7 +58,7 @@ ins { } #diff-ui { -background: #fff; + background: #fff; padding: 2em; margin: 1em; border-radius: 5px; diff --git a/backend/templates/diff.html b/backend/templates/diff.html index f5b8ad8f..9c9232db 100644 --- a/backend/templates/diff.html +++ b/backend/templates/diff.html @@ -2,34 +2,58 @@ {% block content %} -
+
+

Differences

+
+
+ + + + + + + {% if versions|length >= 1 %} + + + + {% endif %} +
+
Removed text Inserted Text - -
-

Diff

- - -
+
+ - +
-

+                
             
-Diff algorithm from the amazing github.com/kpdecker/jsdiff + Diff algorithm from the amazing github.com/kpdecker/jsdiff +
+ + {% endblock %} \ No newline at end of file