summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-27 10:52:02 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-27 10:52:02 +0000
commitb718d5dec2071b9f73a739dfff49757356f93331 (patch)
tree2b39ede90b222c45f656cbd300342164fae04da9
parenta359ffb39713d70cc29e66e98c1a9b3849b0afd7 (diff)
downloadredmine-b718d5dec2071b9f73a739dfff49757356f93331.tar.gz
redmine-b718d5dec2071b9f73a739dfff49757356f93331.zip
Moves attachments parsing after textile parsing so that:
* attachments parsing does not rely on textile syntax * textile output can be cached (#4482) git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3253 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/application_helper.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 0876127a1..c6f743dd4 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -402,6 +402,8 @@ module ApplicationHelper
end
return '' if text.blank?
+ text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text) { |macro, args| exec_macro(macro, obj, args) }
+
only_path = options.delete(:only_path) == false ? false : true
# when using an image link, try to use an attachment, if possible
@@ -409,22 +411,23 @@ module ApplicationHelper
if attachments
attachments = attachments.sort_by(&:created_on).reverse
- text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(bmp|gif|jpg|jpeg|png))!/i) do |m|
- style = $1
- filename = $6.downcase
+ text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
+ filename, ext, alt, alttext = $1.downcase, $2, $3, $4
+
# search for the picture in attachments
if found = attachments.detect { |att| att.filename.downcase == filename }
image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
- desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1")
- alt = desc.blank? ? nil : "(#{desc})"
- "!#{style}#{image_url}#{alt}!"
+ desc = found.description.to_s.gsub('"', '')
+ if !desc.blank? && alttext.blank?
+ alt = " title=\"#{desc}\" alt=\"#{desc}\""
+ end
+ "src=\"#{image_url}\"#{alt}"
else
m
end
end
end
- text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text) { |macro, args| exec_macro(macro, obj, args) }
# different methods for formatting wiki links
case options[:wiki_links]