git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.7-stable@2174 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/0.7.4
<% form_remote_tag(:url => {}, :html => { :id => "journal-#{@journal.id}-form" }) do %> | <% form_remote_tag(:url => {}, :html => { :id => "journal-#{@journal.id}-form" }) do %> | ||||
<%= text_area_tag :notes, @journal.notes, :class => 'wiki-edit', | |||||
:rows => (@journal.notes.blank? ? 10 : [[10, @journal.notes.length / 50].max, 100].min) %> | |||||
<%= text_area_tag :notes, h(@journal.notes), :class => 'wiki-edit', | |||||
:rows => (@journal.notes.blank? ? 10 : [[10, @journal.notes.length / 50].max, 100].min) %> | |||||
<p><%= submit_tag l(:button_save) %> | <p><%= submit_tag l(:button_save) %> | ||||
<%= link_to l(:button_cancel), '#', :onclick => "Element.remove('journal-#{@journal.id}-form'); " + | <%= link_to l(:button_cancel), '#', :onclick => "Element.remove('journal-#{@journal.id}-form'); " + | ||||
"Element.show('journal-#{@journal.id}-notes'); return false;" %></p> | "Element.show('journal-#{@journal.id}-notes'); return false;" %></p> |
# | # | ||||
# Flexible HTML escaping | # Flexible HTML escaping | ||||
# | # | ||||
def htmlesc( str, mode ) | |||||
def htmlesc( str, mode=:Quotes ) | |||||
if str | |||||
str.gsub!( '&', '&' ) | str.gsub!( '&', '&' ) | ||||
str.gsub!( '"', '"' ) if mode != :NoQuotes | str.gsub!( '"', '"' ) if mode != :NoQuotes | ||||
str.gsub!( "'", ''' ) if mode == :Quotes | str.gsub!( "'", ''' ) if mode == :Quotes | ||||
str.gsub!( '<', '<') | str.gsub!( '<', '<') | ||||
str.gsub!( '>', '>') | str.gsub!( '>', '>') | ||||
end | |||||
str | |||||
end | end | ||||
# Search and replace for Textile glyphs (quotes, dashes, other symbols) | # Search and replace for Textile glyphs (quotes, dashes, other symbols) | ||||
def inline_textile_image( text ) | def inline_textile_image( text ) | ||||
text.gsub!( IMAGE_RE ) do |m| | text.gsub!( IMAGE_RE ) do |m| | ||||
stln,algn,atts,url,title,href,href_a1,href_a2 = $~[1..8] | stln,algn,atts,url,title,href,href_a1,href_a2 = $~[1..8] | ||||
htmlesc title | |||||
atts = pba( atts ) | atts = pba( atts ) | ||||
atts = " src=\"#{ url }\"#{ atts }" | atts = " src=\"#{ url }\"#{ atts }" | ||||
atts << " title=\"#{ title }\"" if title | atts << " title=\"#{ title }\"" if title |
'floating !>http://foo.bar/image.jpg!' => 'floating <div style="float:right"><img src="http://foo.bar/image.jpg" alt="" /></div>', | 'floating !>http://foo.bar/image.jpg!' => 'floating <div style="float:right"><img src="http://foo.bar/image.jpg" alt="" /></div>', | ||||
'with class !(some-class)http://foo.bar/image.jpg!' => 'with class <img src="http://foo.bar/image.jpg" class="some-class" alt="" />', | 'with class !(some-class)http://foo.bar/image.jpg!' => 'with class <img src="http://foo.bar/image.jpg" class="some-class" alt="" />', | ||||
'with style !{width:100px;height100px}http://foo.bar/image.jpg!' => 'with style <img src="http://foo.bar/image.jpg" style="width:100px;height100px;" alt="" />', | 'with style !{width:100px;height100px}http://foo.bar/image.jpg!' => 'with style <img src="http://foo.bar/image.jpg" style="width:100px;height100px;" alt="" />', | ||||
'with title !http://foo.bar/image.jpg(This is a title)!' => 'with title <img src="http://foo.bar/image.jpg" title="This is a title" alt="This is a title" />', | |||||
'with title !http://foo.bar/image.jpg(This is a double-quoted "title")!' => 'with title <img src="http://foo.bar/image.jpg" title="This is a double-quoted "title"" alt="This is a double-quoted "title"" />', | |||||
} | } | ||||
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | ||||
end | end |