##// END OF EJS Templates
Fixes wiki diff escaping....
Jean-Philippe Lang -
r2694:aa07e8505ee3
parent child
Show More
@@ -1,69 +1,69
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 module WikiHelper
19 19
20 20 def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0)
21 21 s = ''
22 22 pages.select {|p| p.parent == parent}.each do |page|
23 23 attrs = "value='#{page.id}'"
24 24 attrs << " selected='selected'" if selected == page
25 25 indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : nil
26 26
27 27 s << "<option value='#{page.id}'>#{indent}#{h page.pretty_title}</option>\n" +
28 28 wiki_page_options_for_select(pages, selected, page, level + 1)
29 29 end
30 30 s
31 31 end
32 32
33 33 def html_diff(wdiff)
34 34 words = wdiff.words.collect{|word| h(word)}
35 35 words_add = 0
36 36 words_del = 0
37 37 dels = 0
38 38 del_off = 0
39 39 wdiff.diff.diffs.each do |diff|
40 40 add_at = nil
41 41 add_to = nil
42 42 del_at = nil
43 43 deleted = ""
44 44 diff.each do |change|
45 45 pos = change[1]
46 46 if change[0] == "+"
47 47 add_at = pos + dels unless add_at
48 48 add_to = pos + dels
49 49 words_add += 1
50 50 else
51 51 del_at = pos unless del_at
52 deleted << ' ' + change[2]
52 deleted << ' ' + h(change[2])
53 53 words_del += 1
54 54 end
55 55 end
56 56 if add_at
57 57 words[add_at] = '<span class="diff_in">' + words[add_at]
58 58 words[add_to] = words[add_to] + '</span>'
59 59 end
60 60 if del_at
61 61 words.insert del_at - del_off + dels + words_add, '<span class="diff_out">' + deleted + '</span>'
62 62 dels += 1
63 63 del_off += words_del
64 64 words_del = 0
65 65 end
66 66 end
67 67 simple_format_without_paragraph(words.join(' '))
68 68 end
69 69 end
General Comments 0
You need to be logged in to leave comments. Login now