diff --git a/var/www/modules/showpaste/Flask_showpaste.py b/var/www/modules/showpaste/Flask_showpaste.py index 0967f76f..eedfda17 100644 --- a/var/www/modules/showpaste/Flask_showpaste.py +++ b/var/www/modules/showpaste/Flask_showpaste.py @@ -7,7 +7,8 @@ import redis import json import flask -from flask import Flask, render_template, jsonify, request, Blueprint +from flask import Flask, render_template, jsonify, request, Blueprint, make_response +import difflib import Paste @@ -113,5 +114,21 @@ def getmoredata(): to_return = p_content[max_preview_modal-1:] return to_return +@showsavedpastes.route("/showDiff/") +def showDiff(): + s1 = request.args.get('s1', '') + s2 = request.args.get('s2', '') + p1 = Paste.Paste(s1) + p2 = Paste.Paste(s2) + maxLengthLine1 = p1.get_lines_info()[1] + maxLengthLine2 = p2.get_lines_info()[1] + if maxLengthLine1 > 100000 or maxLengthLine2 > 100000: + return "Can't make the difference as the lines are too long." + htmlD = difflib.HtmlDiff() + lines1 = p1.get_p_content().decode('utf8', 'ignore').splitlines() + lines2 = p2.get_p_content().decode('utf8', 'ignore').splitlines() + the_html = htmlD.make_file(lines1, lines2) + return the_html + # ========= REGISTRATION ========= app.register_blueprint(showsavedpastes) diff --git a/var/www/modules/showpaste/templates/show_saved_paste.html b/var/www/modules/showpaste/templates/show_saved_paste.html index d58b243f..d1d89dd7 100644 --- a/var/www/modules/showpaste/templates/show_saved_paste.html +++ b/var/www/modules/showpaste/templates/show_saved_paste.html @@ -15,14 +15,14 @@ - +
Hash type | Paste info | Date | -Path | +Path | +Action | Similarity: {{ simil_list[i] }}% | {{ date_list[i] }} | {{ dup_path }} | +{% set i = i + 1 %} {% endfor %} @@ -82,7 +84,7 @@ |
---|