comparison app/helpers/.svn/text-base/wiki_helper.rb.svn-base @ 245:051f544170fe

* Update to SVN trunk revision 4993
author Chris Cannam
date Thu, 03 Mar 2011 11:42:28 +0000
parents 94944d00e43c
children cbce1fd3b1b7
comparison
equal deleted inserted replaced
244:8972b600f4fb 245:051f544170fe
1 # redMine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
27 s << "<option #{attrs}>#{indent}#{h page.pretty_title}</option>\n" + 27 s << "<option #{attrs}>#{indent}#{h page.pretty_title}</option>\n" +
28 wiki_page_options_for_select(pages, selected, page, level + 1) 28 wiki_page_options_for_select(pages, selected, page, level + 1)
29 end 29 end
30 s 30 s
31 end 31 end
32
33 def html_diff(wdiff)
34 words = wdiff.words.collect{|word| h(word)}
35 words_add = 0
36 words_del = 0
37 dels = 0
38 del_off = 0
39 wdiff.diff.diffs.each do |diff|
40 add_at = nil
41 add_to = nil
42 del_at = nil
43 deleted = ""
44 diff.each do |change|
45 pos = change[1]
46 if change[0] == "+"
47 add_at = pos + dels unless add_at
48 add_to = pos + dels
49 words_add += 1
50 else
51 del_at = pos unless del_at
52 deleted << ' ' + h(change[2])
53 words_del += 1
54 end
55 end
56 if add_at
57 words[add_at] = '<span class="diff_in">' + words[add_at]
58 words[add_to] = words[add_to] + '</span>'
59 end
60 if del_at
61 words.insert del_at - del_off + dels + words_add, '<span class="diff_out">' + deleted + '</span>'
62 dels += 1
63 del_off += words_del
64 words_del = 0
65 end
66 end
67 simple_format_without_paragraph(words.join(' '))
68 end
69 end 32 end