Moves link_to_message to ApplicationHelper to make it available to redmine links.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4760 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-01-23 17:02:10 +00:00
parent b20210e83c
commit a2a01e6b72
3 changed files with 16 additions and 18 deletions

View File

@ -109,6 +109,20 @@ module ApplicationHelper
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev},
:title => l(:label_revision_id, format_revision(revision)))
end
# Generates a link to a message
def link_to_message(message, options={}, html_options = nil)
link_to(
h(truncate(message.subject, :length => 60)),
{ :controller => 'messages', :action => 'show',
:board_id => message.board_id,
:id => message.root,
:r => (message.parent_id && message.id),
:anchor => (message.parent_id ? "message-#{message.id}" : nil)
}.merge(options),
html_options
)
end
# Generates a link to a project if active
# Examples:
@ -632,13 +646,7 @@ module ApplicationHelper
end
when 'message'
if message = Message.visible.find_by_id(oid, :include => :parent)
link = link_to h(truncate(message.subject, :length => 60)), {:only_path => only_path,
:controller => 'messages',
:action => 'show',
:board_id => message.board,
:id => message.root,
:anchor => (message.parent ? "message-#{message.id}" : nil)},
:class => 'message'
link = link_to_message(message, {:only_path => only_path}, :class => 'message')
end
when 'project'
if p = Project.visible.find_by_id(oid)

View File

@ -16,14 +16,4 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module MessagesHelper
def link_to_message(message)
return '' unless message
link_to h(truncate(message.subject, :length => 60)), :controller => 'messages',
:action => 'show',
:board_id => message.board_id,
:id => message.root,
:r => (message.parent_id && message.id),
:anchor => (message.parent_id ? "message-#{message.id}" : nil)
end
end

View File

@ -200,7 +200,7 @@ RAW
'export:/some/file' => link_to('export:/some/file', source_url.merge(:format => 'raw'), :class => 'source download'),
# 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'),
'message#5' => link_to('RE: post 2', message_url.merge(:anchor => 'message-5', :r => 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'),