view_diff_data.py 1.2 KB

123456789101112131415161718192021222324252627282930
  1. from .tool.func import *
  2. def view_diff_data_2(conn, name):
  3. curs = conn.cursor()
  4. first = flask.request.args.get('first', '1')
  5. second = flask.request.args.get('second', '1')
  6. curs.execute("select data from history where id = ? and title = ?", [first, name])
  7. first_raw_data = curs.fetchall()
  8. if first_raw_data:
  9. curs.execute("select data from history where id = ? and title = ?", [second, name])
  10. second_raw_data = curs.fetchall()
  11. if second_raw_data:
  12. first_data = html.escape(first_raw_data[0][0])
  13. second_data = html.escape(second_raw_data[0][0])
  14. if first == second:
  15. result = '-'
  16. else:
  17. diff_data = difflib.SequenceMatcher(None, first_data, second_data)
  18. result = re.sub('\r', '', diff(diff_data))
  19. return easy_minify(flask.render_template(skin_check(),
  20. imp = [name, wiki_set(), custom(), other2([' (' + load_lang('compare') + ')', 0])],
  21. data = '<pre>' + result + '</pre>',
  22. menu = [['history/' + url_pas(name), load_lang('return')]]
  23. ))
  24. return redirect('/history/' + url_pas(name))