##// END OF EJS Templates
Adds projects links (#4812)....
Jean-Philippe Lang -
r3308:3168ee3d47f5
parent child
Show More
@@ -510,7 +510,7 module ApplicationHelper
510 # export:some/file -> Force the download of the file
510 # export:some/file -> Force the download of the file
511 # Forum messages:
511 # Forum messages:
512 # message#1218 -> Link to message with id 1218
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 leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8
514 leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8
515 link = nil
515 link = nil
516 if esc.nil?
516 if esc.nil?
@@ -549,6 +549,11 module ApplicationHelper
549 :anchor => (message.parent ? "message-#{message.id}" : nil)},
549 :anchor => (message.parent ? "message-#{message.id}" : nil)},
550 :class => 'message'
550 :class => 'message'
551 end
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 end
557 end
553 elsif sep == ':'
558 elsif sep == ':'
554 # removes the double quotes if any
559 # removes the double quotes if any
@@ -586,6 +591,11 module ApplicationHelper
586 link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment},
591 link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment},
587 :class => 'attachment'
592 :class => 'attachment'
588 end
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 end
599 end
590 end
600 end
591 end
601 end
@@ -27,7 +27,8 class ApplicationHelperTest < HelperTestCase
27 :trackers, :issue_statuses, :issues, :versions, :documents,
27 :trackers, :issue_statuses, :issues, :versions, :documents,
28 :wikis, :wiki_pages, :wiki_contents,
28 :wikis, :wiki_pages, :wiki_contents,
29 :boards, :messages,
29 :boards, :messages,
30 :attachments
30 :attachments,
31 :enumerations
31
32
32 def setup
33 def setup
33 super
34 super
@@ -150,6 +151,8 RAW
150
151
151 message_url = {:controller => 'messages', :action => 'show', :board_id => 1, :id => 4}
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 source_url = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file']}
156 source_url = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file']}
154 source_url_with_ext = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file.ext']}
157 source_url_with_ext = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file.ext']}
155
158
@@ -184,6 +187,10 RAW
184 # message
187 # message
185 'message#4' => link_to('Post 2', message_url, :class => 'message'),
188 'message#4' => link_to('Post 2', message_url, :class => 'message'),
186 'message#5' => link_to('RE: post 2', message_url.merge(:anchor => 'message-5'), :class => 'message'),
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 # escaping
194 # escaping
188 '!#3.' => '#3.',
195 '!#3.' => '#3.',
189 '!r1' => 'r1',
196 '!r1' => 'r1',
@@ -199,7 +206,7 RAW
199 "http://foo.bar/FAQ#3" => '<a class="external" href="http://foo.bar/FAQ#3">http://foo.bar/FAQ#3</a>',
206 "http://foo.bar/FAQ#3" => '<a class="external" href="http://foo.bar/FAQ#3">http://foo.bar/FAQ#3</a>',
200 }
207 }
201 @project = Project.find(1)
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 end
210 end
204
211
205 def test_wiki_links
212 def test_wiki_links
General Comments 0
You need to be logged in to leave comments. Login now