@@ -510,7 +510,7 module ApplicationHelper | |||
|
510 | 510 | # export:some/file -> Force the download of the file |
|
511 | 511 | # Forum messages: |
|
512 | 512 | # message#1218 -> Link to message with id 1218 |
|
513 | text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export|message)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|<|$)}) do |m| | |
|
513 | text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export|message|project)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|<|$)}) do |m| | |
|
514 | 514 | leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8 |
|
515 | 515 | link = nil |
|
516 | 516 | if esc.nil? |
@@ -549,6 +549,11 module ApplicationHelper | |||
|
549 | 549 | :anchor => (message.parent ? "message-#{message.id}" : nil)}, |
|
550 | 550 | :class => 'message' |
|
551 | 551 | end |
|
552 | when 'project' | |
|
553 | if p = Project.visible.find_by_id(oid) | |
|
554 | link = link_to h(p.name), {:only_path => only_path, :controller => 'projects', :action => 'show', :id => p}, | |
|
555 | :class => 'project' | |
|
556 | end | |
|
552 | 557 | end |
|
553 | 558 | elsif sep == ':' |
|
554 | 559 | # removes the double quotes if any |
@@ -586,6 +591,11 module ApplicationHelper | |||
|
586 | 591 | link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment}, |
|
587 | 592 | :class => 'attachment' |
|
588 | 593 | end |
|
594 | when 'project' | |
|
595 | if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}]) | |
|
596 | link = link_to h(p.name), {:only_path => only_path, :controller => 'projects', :action => 'show', :id => p}, | |
|
597 | :class => 'project' | |
|
598 | end | |
|
589 | 599 | end |
|
590 | 600 | end |
|
591 | 601 | end |
@@ -27,7 +27,8 class ApplicationHelperTest < HelperTestCase | |||
|
27 | 27 | :trackers, :issue_statuses, :issues, :versions, :documents, |
|
28 | 28 | :wikis, :wiki_pages, :wiki_contents, |
|
29 | 29 | :boards, :messages, |
|
30 | :attachments | |
|
30 | :attachments, | |
|
31 | :enumerations | |
|
31 | 32 | |
|
32 | 33 | def setup |
|
33 | 34 | super |
@@ -150,6 +151,8 RAW | |||
|
150 | 151 | |
|
151 | 152 | message_url = {:controller => 'messages', :action => 'show', :board_id => 1, :id => 4} |
|
152 | 153 | |
|
154 | project_url = {:controller => 'projects', :action => 'show', :id => 'subproject1'} | |
|
155 | ||
|
153 | 156 | source_url = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file']} |
|
154 | 157 | source_url_with_ext = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file.ext']} |
|
155 | 158 | |
@@ -184,6 +187,10 RAW | |||
|
184 | 187 | # message |
|
185 | 188 | 'message#4' => link_to('Post 2', message_url, :class => 'message'), |
|
186 | 189 | 'message#5' => link_to('RE: post 2', message_url.merge(:anchor => 'message-5'), :class => 'message'), |
|
190 | # project | |
|
191 | 'project#3' => link_to('eCookbook Subproject 1', project_url, :class => 'project'), | |
|
192 | 'project:subproject1' => link_to('eCookbook Subproject 1', project_url, :class => 'project'), | |
|
193 | 'project:"eCookbook subProject 1"' => link_to('eCookbook Subproject 1', project_url, :class => 'project'), | |
|
187 | 194 | # escaping |
|
188 | 195 | '!#3.' => '#3.', |
|
189 | 196 | '!r1' => 'r1', |
@@ -199,7 +206,7 RAW | |||
|
199 | 206 | "http://foo.bar/FAQ#3" => '<a class="external" href="http://foo.bar/FAQ#3">http://foo.bar/FAQ#3</a>', |
|
200 | 207 | } |
|
201 | 208 | @project = Project.find(1) |
|
202 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } | |
|
209 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" } | |
|
203 | 210 | end |
|
204 | 211 | |
|
205 | 212 | def test_wiki_links |
General Comments 0
You need to be logged in to leave comments.
Login now