2
0

view_diff_data.py 1.4 KB

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