diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-11-18 16:25:00 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-11-18 16:25:00 +0000 |
commit | 6fc245327ce5bb4bb75f1378424635e347dfcd02 (patch) | |
tree | fd9d00eab0e444da2f6ecb58842cb973c37540a5 /lib/redmine/wiki_formatting.rb | |
parent | b38dc9a301c3ab0fafc5dd824ad57059ec58fc91 (diff) | |
download | redmine-6fc245327ce5bb4bb75f1378424635e347dfcd02.tar.gz redmine-6fc245327ce5bb4bb75f1378424635e347dfcd02.zip |
Wiki: allows single section edit (#2222).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7829 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/wiki_formatting.rb')
-rw-r--r-- | lib/redmine/wiki_formatting.rb | 38 |
1 files changed, 7 insertions, 31 deletions
diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 0635aad8b..2f25fe0e6 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -17,6 +17,8 @@ module Redmine module WikiFormatting + class StaleSectionError < Exception; end + @@formatters = {} class << self @@ -29,6 +31,10 @@ module Redmine @@formatters[name.to_s] = {:formatter => formatter, :helper => helper} end + def formatter + formatter_for(Setting.text_formatting) + end + def formatter_for(name) entry = @@formatters[name.to_s] (entry && entry[:formatter]) || Redmine::WikiFormatting::NullFormatter::Formatter @@ -43,7 +49,7 @@ module Redmine @@formatters.keys.map end - def to_html(format, text, options = {}, &block) + def to_html(format, text, options = {}) text = if Setting.cache_formatted_text? && text.size > 2.kilobyte && cache_store && cache_key = cache_key_for(format, options[:object], options[:attribute]) # Text retrieved from the cache store may be frozen # We need to dup it so we can do in-place substitutions with gsub! @@ -53,9 +59,6 @@ module Redmine else formatter_for(format).new(text).to_html end - if block_given? - execute_macros(text, block) - end text end @@ -70,33 +73,6 @@ module Redmine def cache_store ActionController::Base.cache_store end - - MACROS_RE = / - (!)? # escaping - ( - \{\{ # opening tag - ([\w]+) # macro name - (\(([^\}]*)\))? # optional arguments - \}\} # closing tag - ) - /x unless const_defined?(:MACROS_RE) - - # Macros substitution - def execute_macros(text, macros_runner) - text.gsub!(MACROS_RE) do - esc, all, macro = $1, $2, $3.downcase - args = ($5 || '').split(',').each(&:strip) - if esc.nil? - begin - macros_runner.call(macro, args) - rescue => e - "<div class=\"flash error\">Error executing the <strong>#{macro}</strong> macro (#{e})</div>" - end || all - else - all - end - end - end end # Default formatter module |