# export:some/file -> Force the download of the file
# Forum messages:
# message#1218 -> Link to message with id 1218
- text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export|message)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|<|$)}) do |m|
+ text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export|message|project)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|<|$)}) do |m|
leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8
link = nil
if esc.nil?
:anchor => (message.parent ? "message-#{message.id}" : nil)},
:class => 'message'
end
+ when 'project'
+ if p = Project.visible.find_by_id(oid)
+ link = link_to h(p.name), {:only_path => only_path, :controller => 'projects', :action => 'show', :id => p},
+ :class => 'project'
+ end
end
elsif sep == ':'
# removes the double quotes if any
link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment},
:class => 'attachment'
end
+ when 'project'
+ if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}])
+ link = link_to h(p.name), {:only_path => only_path, :controller => 'projects', :action => 'show', :id => p},
+ :class => 'project'
+ end
end
end
end
:trackers, :issue_statuses, :issues, :versions, :documents,
:wikis, :wiki_pages, :wiki_contents,
:boards, :messages,
- :attachments
+ :attachments,
+ :enumerations
def setup
super
message_url = {:controller => 'messages', :action => 'show', :board_id => 1, :id => 4}
+ project_url = {:controller => 'projects', :action => 'show', :id => 'subproject1'}
+
source_url = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file']}
source_url_with_ext = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file.ext']}
# message
'message#4' => link_to('Post 2', message_url, :class => 'message'),
'message#5' => link_to('RE: post 2', message_url.merge(:anchor => 'message-5'), :class => 'message'),
+ # project
+ 'project#3' => link_to('eCookbook Subproject 1', project_url, :class => 'project'),
+ 'project:subproject1' => link_to('eCookbook Subproject 1', project_url, :class => 'project'),
+ 'project:"eCookbook subProject 1"' => link_to('eCookbook Subproject 1', project_url, :class => 'project'),
# escaping
'!#3.' => '#3.',
'!r1' => 'r1',
"http://foo.bar/FAQ#3" => '<a class="external" href="http://foo.bar/FAQ#3">http://foo.bar/FAQ#3</a>',
}
@project = Project.find(1)
- to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
+ to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" }
end
def test_wiki_links