Project

General

Profile

Patch #20063 » IssueLinkFormatting.patch

Olivier Houdas, 2015-06-10 11:49

View differences:

app/helpers/application_helper.rb Sat May 30 08:24:03 2015 +0000 → app/helpers/application_helper.rb Wed Jun 10 11:43:56 2015 +0200
707 707
  # Examples:
708 708
  #   Issues:
709 709
  #     #52 -> Link to issue #52
710
  #     issue#52 -> Link to issue (title + status) with id 52
710 711
  #   Changesets:
711 712
  #     r52 -> Link to revision 52
712 713
  #     commit:a85130f -> Link to scmid starting with a85130f
......
738 739
  #     identifier:version:1.0.0
739 740
  #     identifier:source:some/file
740 741
  def parse_redmine_links(text, default_project, obj, attr, only_path, options)
741
    text.gsub!(%r{<a( [^>]+?)?>(.*?)</a>|([\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|
742
    text.gsub!(%r{<a( [^>]+?)?>(.*?)</a>|([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(issue|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|
742 743
      tag_content, leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, $3, $4, $5, $6, $7, $12, $13, $10 || $14 || $20, $16 || $21, $17, $19
743 744
      if tag_content
744 745
        $&
......
782 783
                               :class => issue.css_classes,
783 784
                               :title => "#{issue.subject.truncate(100)} (#{issue.status.name})")
784 785
              end
786
            when 'issue'
787
              if oid.to_s == identifier &&
788
                issue = Issue.visible.find_by_id(oid)
789
                anchor = comment_id ? "note-#{comment_id}" : nil
790
                link = link_to("#{issue.subject.truncate(100)} (#{issue.status.name})",
791
                               issue_url(issue, :only_path => only_path, :anchor => anchor),
792
                               :class => issue.css_classes)
793
              end
785 794
            when 'document'
786 795
              if document = Document.visible.find_by_id(oid)
787 796
                link = link_to(document.title, document_url(document, :only_path => only_path), :class => 'document')
(1-1/3)