Mercurial > hg > soundsoftware-site
comparison app/helpers/application_helper.rb @ 1294:3e4c3460b6ca redmine-2.2
Update to Redmine SVN revision 11972 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:01:12 +0100 |
parents | 433d4f72a19b |
children | 622f24f53b42 0a574315af3e 261b3d9a4903 |
comparison
equal
deleted
inserted
replaced
1115:433d4f72a19b | 1294:3e4c3460b6ca |
---|---|
595 parsed | 595 parsed |
596 end | 596 end |
597 | 597 |
598 def parse_inline_attachments(text, project, obj, attr, only_path, options) | 598 def parse_inline_attachments(text, project, obj, attr, only_path, options) |
599 # when using an image link, try to use an attachment, if possible | 599 # when using an image link, try to use an attachment, if possible |
600 if options[:attachments] || (obj && obj.respond_to?(:attachments)) | 600 attachments = options[:attachments] || [] |
601 attachments = options[:attachments] || obj.attachments | 601 attachments += obj.attachments if obj.respond_to?(:attachments) |
602 if attachments.present? | |
602 text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m| | 603 text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m| |
603 filename, ext, alt, alttext = $1.downcase, $2, $3, $4 | 604 filename, ext, alt, alttext = $1.downcase, $2, $3, $4 |
604 # search for the picture in attachments | 605 # search for the picture in attachments |
605 if found = Attachment.latest_attach(attachments, filename) | 606 if found = Attachment.latest_attach(attachments, filename) |
606 image_url = url_for :only_path => only_path, :controller => 'attachments', | 607 image_url = url_for :only_path => only_path, :controller => 'attachments', |
701 # Links can refer other objects from other projects, using project identifier: | 702 # Links can refer other objects from other projects, using project identifier: |
702 # identifier:r52 | 703 # identifier:r52 |
703 # identifier:document:"Some document" | 704 # identifier:document:"Some document" |
704 # identifier:version:1.0.0 | 705 # identifier:version:1.0.0 |
705 # identifier:source:some/file | 706 # identifier:source:some/file |
706 def parse_redmine_links(text, project, obj, attr, only_path, options) | 707 def parse_redmine_links(text, default_project, obj, attr, only_path, options) |
707 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| | 708 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| |
708 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 | 709 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 |
709 link = nil | 710 link = nil |
711 project = default_project | |
710 if project_identifier | 712 if project_identifier |
711 project = Project.visible.find_by_identifier(project_identifier) | 713 project = Project.visible.find_by_identifier(project_identifier) |
712 end | 714 end |
713 if esc.nil? | 715 if esc.nil? |
714 if prefix.nil? && sep == 'r' | 716 if prefix.nil? && sep == 'r' |
790 :class => 'news' | 792 :class => 'news' |
791 end | 793 end |
792 when 'commit', 'source', 'export' | 794 when 'commit', 'source', 'export' |
793 if project | 795 if project |
794 repository = nil | 796 repository = nil |
795 if name =~ %r{^(([a-z0-9\-]+)\|)(.+)$} | 797 if name =~ %r{^(([a-z0-9\-_]+)\|)(.+)$} |
796 repo_prefix, repo_identifier, name = $1, $2, $3 | 798 repo_prefix, repo_identifier, name = $1, $2, $3 |
797 repository = project.repositories.detect {|repo| repo.identifier == repo_identifier} | 799 repository = project.repositories.detect {|repo| repo.identifier == repo_identifier} |
798 else | 800 else |
799 repository = project.repository | 801 repository = project.repository |
800 end | 802 end |
817 end | 819 end |
818 repo_prefix = nil | 820 repo_prefix = nil |
819 end | 821 end |
820 when 'attachment' | 822 when 'attachment' |
821 attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil) | 823 attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil) |
822 if attachments && attachment = attachments.detect {|a| a.filename == name } | 824 if attachments && attachment = Attachment.latest_attach(attachments, name) |
823 link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment}, | 825 link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment}, |
824 :class => 'attachment' | 826 :class => 'attachment' |
825 end | 827 end |
826 when 'project' | 828 when 'project' |
827 if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}]) | 829 if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}]) |