diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-08-28 18:56:47 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-08-28 18:56:47 +0000 |
commit | bfd0fb067ac35a4fa76b545a7b357fac72a63e18 (patch) | |
tree | 940f80e27e6175750fd61a7692156f1a4821b9eb /app/controllers/messages_controller.rb | |
parent | 8f3a04ce6906b7e9008bc6488a07404413c4552b (diff) | |
download | redmine-bfd0fb067ac35a4fa76b545a7b357fac72a63e18.tar.gz redmine-bfd0fb067ac35a4fa76b545a7b357fac72a63e18.zip |
Adds posts quoting functionality (#1825).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1772 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/messages_controller.rb')
-rw-r--r-- | app/controllers/messages_controller.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 08c77d7d2..554279d21 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -22,7 +22,9 @@ class MessagesController < ApplicationController before_filter :authorize, :except => :preview verify :method => :post, :only => [ :reply, :destroy ], :redirect_to => { :action => :show } + verify :xhr => true, :only => :quote + helper :attachments include AttachmentsHelper @@ -82,6 +84,20 @@ class MessagesController < ApplicationController { :action => 'show', :id => @message.parent } end + def quote + user = @message.author + text = @message.content + content = "#{ll(Setting.default_language, :text_user_wrote, user)}\\n> " + content << text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\\n> ") + "\\n\\n" + render(:update) { |page| + page.<< "$('message_content').value = \"#{content}\";" + page.show 'reply' + page << "Form.Element.focus('message_content');" + page << "Element.scrollTo('reply');" + page << "$('message_content').scrollTop = $('message_content').scrollHeight - $('message_content').clientHeight;" + } + end + def preview message = @board.messages.find_by_id(params[:id]) @attachements = message.attachments if message |