Adds an option for formatter display name.
git-svn-id: http://svn.redmine.org/redmine/trunk@12450 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
0fabbd281e
commit
0dc98aabe6
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
<p><%= setting_select :protocol, [['HTTP', 'http'], ['HTTPS', 'https']] %></p>
|
<p><%= setting_select :protocol, [['HTTP', 'http'], ['HTTPS', 'https']] %></p>
|
||||||
|
|
||||||
<p><%= setting_select :text_formatting, Redmine::WikiFormatting.format_names.collect{|name| [name, name.to_s]}, :blank => :label_none %></p>
|
<p><%= setting_select :text_formatting, Redmine::WikiFormatting.formats_for_select, :blank => :label_none %></p>
|
||||||
|
|
||||||
<p><%= setting_check_box :cache_formatted_text %></p>
|
<p><%= setting_check_box :cache_formatted_text %></p>
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,14 @@ module Redmine
|
||||||
yield self
|
yield self
|
||||||
end
|
end
|
||||||
|
|
||||||
def register(name, formatter, helper)
|
def register(name, formatter, helper, options={})
|
||||||
raise ArgumentError, "format name '#{name}' is already taken" if @@formatters[name.to_s]
|
name = name.to_s
|
||||||
@@formatters[name.to_s] = {:formatter => formatter, :helper => helper}
|
raise ArgumentError, "format name '#{name}' is already taken" if @@formatters[name]
|
||||||
|
@@formatters[name] = {
|
||||||
|
:formatter => formatter,
|
||||||
|
:helper => helper,
|
||||||
|
:label => options[:label] || name.humanize
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def formatter
|
def formatter
|
||||||
|
@ -51,6 +56,10 @@ module Redmine
|
||||||
@@formatters.keys.map
|
@@formatters.keys.map
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def formats_for_select
|
||||||
|
@@formatters.map {|name, options| [options[:label], name]}
|
||||||
|
end
|
||||||
|
|
||||||
def to_html(format, text, options = {})
|
def to_html(format, text, options = {})
|
||||||
text = if Setting.cache_formatted_text? && text.size > 2.kilobyte && cache_store && cache_key = cache_key_for(format, text, options[:object], options[:attribute])
|
text = if Setting.cache_formatted_text? && text.size > 2.kilobyte && cache_store && cache_key = cache_key_for(format, text, options[:object], options[:attribute])
|
||||||
# Text retrieved from the cache store may be frozen
|
# Text retrieved from the cache store may be frozen
|
||||||
|
|
|
@ -30,6 +30,10 @@ class Redmine::WikiFormattingTest < ActiveSupport::TestCase
|
||||||
assert_equal Redmine::WikiFormatting::NullFormatter::Helper, Redmine::WikiFormatting.helper_for('')
|
assert_equal Redmine::WikiFormatting::NullFormatter::Helper, Redmine::WikiFormatting.helper_for('')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_formats_for_select
|
||||||
|
assert_include ['Textile', 'textile'], Redmine::WikiFormatting.formats_for_select
|
||||||
|
end
|
||||||
|
|
||||||
def test_should_link_urls_and_email_addresses
|
def test_should_link_urls_and_email_addresses
|
||||||
raw = <<-DIFF
|
raw = <<-DIFF
|
||||||
This is a sample *text* with a link: http://www.redmine.org
|
This is a sample *text* with a link: http://www.redmine.org
|
||||||
|
|
Loading…
Reference in New Issue