@@ -659,8 +659,8 module ApplicationHelper | |||||
659 | # identifier:version:1.0.0 |
|
659 | # identifier:version:1.0.0 | |
660 | # identifier:source:some/file |
|
660 | # identifier:source:some/file | |
661 | def parse_redmine_links(text, project, obj, attr, only_path, options) |
|
661 | def parse_redmine_links(text, project, obj, attr, only_path, options) | |
662 | text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-]+)\|)?(r)))(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m| |
|
662 | 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| | |
663 |
leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier = $1, $2, $3, $4, $5, $10, $11, $8 || $12 || $1 |
|
663 | 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 | |
664 | link = nil |
|
664 | link = nil | |
665 | if project_identifier |
|
665 | if project_identifier | |
666 | project = Project.visible.find_by_identifier(project_identifier) |
|
666 | project = Project.visible.find_by_identifier(project_identifier) | |
@@ -686,7 +686,8 module ApplicationHelper | |||||
686 | case prefix |
|
686 | case prefix | |
687 | when nil |
|
687 | when nil | |
688 | if issue = Issue.visible.find_by_id(oid, :include => :status) |
|
688 | if issue = Issue.visible.find_by_id(oid, :include => :status) | |
689 | link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid}, |
|
689 | anchor = comment_id ? "note-#{comment_id}" : nil | |
|
690 | link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor}, | |||
690 | :class => issue.css_classes, |
|
691 | :class => issue.css_classes, | |
691 | :title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})") |
|
692 | :title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})") | |
692 | end |
|
693 | end | |
@@ -785,7 +786,7 module ApplicationHelper | |||||
785 | end |
|
786 | end | |
786 | end |
|
787 | end | |
787 | end |
|
788 | end | |
788 | (leading + (link || "#{project_prefix}#{prefix}#{repo_prefix}#{sep}#{identifier}")).html_safe |
|
789 | (leading + (link || "#{project_prefix}#{prefix}#{repo_prefix}#{sep}#{identifier}#{comment_suffix}")).html_safe | |
789 | end |
|
790 | end | |
790 | end |
|
791 | end | |
791 |
|
792 |
@@ -227,6 +227,8 RAW | |||||
227 | def test_redmine_links |
|
227 | def test_redmine_links | |
228 | issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3}, |
|
228 | issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3}, | |
229 | :class => 'issue status-1 priority-1 overdue', :title => 'Error 281 when updating a recipe (New)') |
|
229 | :class => 'issue status-1 priority-1 overdue', :title => 'Error 281 when updating a recipe (New)') | |
|
230 | note_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3, :anchor => 'note-14'}, | |||
|
231 | :class => 'issue status-1 priority-1 overdue', :title => 'Error 281 when updating a recipe (New)') | |||
230 |
|
232 | |||
231 | changeset_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 1}, |
|
233 | changeset_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 1}, | |
232 | :class => 'changeset', :title => 'My very first commit') |
|
234 | :class => 'changeset', :title => 'My very first commit') | |
@@ -253,6 +255,9 RAW | |||||
253 | to_test = { |
|
255 | to_test = { | |
254 | # tickets |
|
256 | # tickets | |
255 | '#3, [#3], (#3) and #3.' => "#{issue_link}, [#{issue_link}], (#{issue_link}) and #{issue_link}.", |
|
257 | '#3, [#3], (#3) and #3.' => "#{issue_link}, [#{issue_link}], (#{issue_link}) and #{issue_link}.", | |
|
258 | # ticket notes | |||
|
259 | '#3-14' => note_link, | |||
|
260 | '#3#note-14' => note_link, | |||
256 | # changesets |
|
261 | # changesets | |
257 | 'r1' => changeset_link, |
|
262 | 'r1' => changeset_link, | |
258 | 'r1.' => "#{changeset_link}.", |
|
263 | 'r1.' => "#{changeset_link}.", | |
@@ -294,6 +299,8 RAW | |||||
294 | 'project:"eCookbook subProject 1"' => link_to('eCookbook Subproject 1', project_url, :class => 'project'), |
|
299 | 'project:"eCookbook subProject 1"' => link_to('eCookbook Subproject 1', project_url, :class => 'project'), | |
295 | # escaping |
|
300 | # escaping | |
296 | '!#3.' => '#3.', |
|
301 | '!#3.' => '#3.', | |
|
302 | '!#3-14.' => '#3-14.', | |||
|
303 | '!#3#-note14.' => '#3#-note14.', | |||
297 | '!r1' => 'r1', |
|
304 | '!r1' => 'r1', | |
298 | '!document#1' => 'document#1', |
|
305 | '!document#1' => 'document#1', | |
299 | '!document:"Test document"' => 'document:"Test document"', |
|
306 | '!document:"Test document"' => 'document:"Test document"', |
General Comments 0
You need to be logged in to leave comments.
Login now