summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-08-10 22:18:23 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-08-10 22:18:23 +0000
commit16509203398f17fafca33136375263aec64b2a0f (patch)
tree7a6aa963c847072ac526142f3ad9150ff9f66dda /app
parentab4873b83d6f62fa78fdf07da4de2f2f7e0d738d (diff)
downloadredmine-16509203398f17fafca33136375263aec64b2a0f.tar.gz
redmine-16509203398f17fafca33136375263aec64b2a0f.zip
Adds links to forum messages using message#id syntax (#1756).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1729 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/application_helper.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a4102c84a..ed5c6bdb7 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -319,7 +319,9 @@ module ApplicationHelper
# source:some/file#L120 -> Link to line 120 of the file
# source:some/file@52#L120 -> Link to line 120 of the file's revision 52
# export:some/file -> Force the download of the file
- text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|\s|<|$)}) do |m|
+ # 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|
leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8
link = nil
if esc.nil?
@@ -349,6 +351,16 @@ module ApplicationHelper
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
:class => 'version'
end
+ when 'message'
+ if message = Message.find_by_id(oid, :include => [:parent, {:board => :project}], :conditions => Project.visible_by(User.current))
+ link = link_to h(truncate(message.subject, 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'
+ end
end
elsif sep == ':'
# removes the double quotes if any