Patch #20063 » IssueLinkFormatting.patch
| 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 | ||
|---|---|---|
|
# Examples:
|
||
|
# Issues:
|
||
|
# #52 -> Link to issue #52
|
||
|
# issue#52 -> Link to issue (title + status) with id 52
|
||
|
# Changesets:
|
||
|
# r52 -> Link to revision 52
|
||
|
# commit:a85130f -> Link to scmid starting with a85130f
|
||
| ... | ... | |
|
# identifier:version:1.0.0
|
||
|
# identifier:source:some/file
|
||
|
def parse_redmine_links(text, default_project, obj, attr, only_path, options)
|
||
|
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|
|
||
|
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|
|
||
|
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
|
||
|
if tag_content
|
||
|
$&
|
||
| ... | ... | |
|
:class => issue.css_classes,
|
||
|
:title => "#{issue.subject.truncate(100)} (#{issue.status.name})")
|
||
|
end
|
||
|
when 'issue'
|
||
|
if oid.to_s == identifier &&
|
||
|
issue = Issue.visible.find_by_id(oid)
|
||
|
anchor = comment_id ? "note-#{comment_id}" : nil
|
||
|
link = link_to("#{issue.subject.truncate(100)} (#{issue.status.name})",
|
||
|
issue_url(issue, :only_path => only_path, :anchor => anchor),
|
||
|
:class => issue.css_classes)
|
||
|
end
|
||
|
when 'document'
|
||
|
if document = Document.visible.find_by_id(oid)
|
||
|
link = link_to(document.title, document_url(document, :only_path => only_path), :class => 'document')
|
||