| 610 |
610 |
|
| 611 |
611 |
def parse_inline_attachments(text, project, obj, attr, only_path, options)
|
| 612 |
612 |
# when using an image link, try to use an attachment, if possible
|
| 613 |
|
if options[:attachments] || (obj && obj.respond_to?(:attachments))
|
| 614 |
|
attachments = options[:attachments] || obj.attachments
|
|
613 |
attachments = options[:attachments] || []
|
|
614 |
attachments += obj.attachments if obj.respond_to?(:attachments)
|
|
615 |
if attachments.present?
|
| 615 |
616 |
text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
|
| 616 |
617 |
filename, ext, alt, alttext = $1.downcase, $2, $3, $4
|
| 617 |
618 |
# search for the picture in attachments
|
| ... | ... | |
| 716 |
717 |
# identifier:document:"Some document"
|
| 717 |
718 |
# identifier:version:1.0.0
|
| 718 |
719 |
# identifier:source:some/file
|
| 719 |
|
def parse_redmine_links(text, project, obj, attr, only_path, options)
|
| 720 |
|
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
|
|
720 |
def parse_redmine_links(text, default_project, obj, attr, only_path, options)
|
|
721 |
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-_]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
|
| 721 |
722 |
leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, $2, $3, $4, $5, $10, $11, $8 || $12 || $18, $14 || $19, $15, $17
|
| 722 |
723 |
link = nil
|
|
724 |
project = default_project
|
| 723 |
725 |
if project_identifier
|
| 724 |
726 |
project = Project.visible.find_by_identifier(project_identifier)
|
| 725 |
727 |
end
|
| ... | ... | |
| 805 |
807 |
when 'commit', 'source', 'export'
|
| 806 |
808 |
if project
|
| 807 |
809 |
repository = nil
|
| 808 |
|
if name =~ %r{^(([a-z0-9\-]+)\|)(.+)$}
|
|
810 |
if name =~ %r{^(([a-z0-9\-_]+)\|)(.+)$}
|
| 809 |
811 |
repo_prefix, repo_identifier, name = $1, $2, $3
|
| 810 |
812 |
repository = project.repositories.detect {|repo| repo.identifier == repo_identifier}
|
| 811 |
813 |
else
|
| ... | ... | |
| 832 |
834 |
end
|
| 833 |
835 |
when 'attachment'
|
| 834 |
836 |
attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
|
| 835 |
|
if attachments && attachment = attachments.detect {|a| a.filename == name }
|
|
837 |
if attachments && attachment = Attachment.latest_attach(attachments, name)
|
| 836 |
838 |
link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment},
|
| 837 |
839 |
:class => 'attachment'
|
| 838 |
840 |
end
|