Exemplo n.º 1
0
 def get(self, note_id):
     template_values = {}
     if len(note_id) < 8:
         raise tornado.web.HTTPError(404)
     note_id = decode(note_id)
     notes = self.db.query(
             "select title,note,rev_num,rev_user_name as name,rev_user_domain as domain"
             ", revdate from fd_NoteHistory where note_id = %s and rev_status = 0"
             " order by rev_num desc", note_id)
     if not notes:
         raise tornado.web.HTTPError(404)
     for i in range(len(notes)):
         next_note = {}
         if i == len(notes)-1:
             next_note['title'] = ''
             next_note['note'] = ''
         else:
             next_note['title'] = notes[i+1].title
             next_note['note'] = notes[i+1].note
         notes[i].title = textdiff(xhtml_escape(next_note['title']), xhtml_escape(notes[i].title))
         note1 = self.br(linkify(next_note['note'], extra_params="target='_blank' rel='nofollow'"))
         note2 = self.br(linkify(notes[i].note, extra_params="target='_blank' rel='nofollow'"))
         notes[i].note = self.at(textdiff(note1, note2))
         notes[i]['rev'] = 0
         if i == 0:
             notes[i]['rev'] = 1
     template_values['notes'] = notes
     self.render("notehistory.html", template_values=template_values)
Exemplo n.º 2
0
 def test_delteandinsert(self):
     result = '<span class="delete">a</span><span class="insert">b</span>'
     self.assertEqual(result, textdiff("a","b"))
Exemplo n.º 3
0
 def test_diff(self):
     result = '<span class="delete">再</span><span class="insert">在</span>回<span class="delete">首</span><span class="insert">手</span>'
     self.assertEqual(result, textdiff(u"再回首",u"在回手"))
Exemplo n.º 4
0
 def test_delete(self):
     result = 'thi<span class="delete">s</span> time'
     self.assertEqual(result, textdiff(u"this time",u"thi time"))