annotate app/helpers/.svn/text-base/wiki_helper.rb.svn-base @ 45:65d9e2cabaa3 luisf

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