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