summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-06-02 13:29:54 +0000
committerGo MAEDA <maeda@farend.jp>2019-06-02 13:29:54 +0000
commit2d475288e4b79bea7f3beefd5f0be151510b0274 (patch)
treeacb70f3c9b295b1839587dd400b895d51d007dc4
parent748e8725d6c93dadfebc94440a0600cdfb890f9a (diff)
downloadredmine-2d475288e4b79bea7f3beefd5f0be151510b0274.tar.gz
redmine-2d475288e4b79bea7f3beefd5f0be151510b0274.zip
Insert a link to the source to the attribution line when quoting a note or a message (#31427).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@18217 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/journals_controller.rb4
-rw-r--r--app/controllers/messages_controller.rb6
-rw-r--r--public/stylesheets/application.css2
-rw-r--r--test/functional/journals_controller_test.rb1
-rw-r--r--test/functional/messages_controller_test.rb18
5 files changed, 27 insertions, 4 deletions
diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb
index 2ff228998..a0a0352dd 100644
--- a/app/controllers/journals_controller.rb
+++ b/app/controllers/journals_controller.rb
@@ -66,13 +66,15 @@ class JournalsController < ApplicationController
if @journal
user = @journal.user
text = @journal.notes
+ indice = @journal.issue.visible_journals_with_index.find{|j| j.id == @journal.id}.indice
+ @content = +"#{ll(Setting.default_language, :text_user_wrote_in, {:value => user, :link => "#note-#{indice}"})}\n> "
else
user = @issue.author
text = @issue.description
+ @content = +"#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
end
# Replaces pre blocks with [...]
text = text.to_s.strip.gsub(%r{<pre>(.*?)</pre>}m, '[...]')
- @content = +"#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
rescue ActiveRecord::RecordNotFound
render_404
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index f0830fcdb..b6bcb2839 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -117,7 +117,11 @@ class MessagesController < ApplicationController
@subject = @message.subject
@subject = "RE: #{@subject}" unless @subject.starts_with?('RE:')
- @content = +"#{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> "
+ if @message.root == @message
+ @content = +"#{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> "
+ else
+ @content = +"#{ll(Setting.default_language, :text_user_wrote_in, {:value => @message.author, :link => "message##{@message.id}"})}\n> "
+ end
@content << @message.content.to_s.strip.gsub(%r{<pre>(.*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
end
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index f08ef30b6..9981efc4b 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -310,7 +310,7 @@ tr.message td.created_on { white-space: nowrap; }
tr.message td.last_message { font-size: 80%; white-space: nowrap; }
tr.message.sticky td.subject { font-weight: bold; }
-body.avatars-on #replies .message {padding-left:32px;}
+body.avatars-on #replies .message.reply {padding-left: 32px;}
#replies .reply:target h4 {background-color:#DDEEFF;}
#replies h4 img.gravatar {margin-left:-32px;}
diff --git a/test/functional/journals_controller_test.rb b/test/functional/journals_controller_test.rb
index b36ab2ddc..6b4c65514 100644
--- a/test/functional/journals_controller_test.rb
+++ b/test/functional/journals_controller_test.rb
@@ -185,6 +185,7 @@ class JournalsControllerTest < Redmine::ControllerTest
:xhr => true
assert_response :success
assert_equal 'text/javascript', response.content_type
+ assert_include 'Redmine Admin wrote in #note-1:', response.body
assert_include '> A comment with a private version', response.body
end
diff --git a/test/functional/messages_controller_test.rb b/test/functional/messages_controller_test.rb
index f93578033..64c70157b 100644
--- a/test/functional/messages_controller_test.rb
+++ b/test/functional/messages_controller_test.rb
@@ -257,7 +257,22 @@ class MessagesControllerTest < Redmine::ControllerTest
assert_nil Message.find_by_id(2)
end
- def test_quote
+ def test_quote_if_message_is_root
+ @request.session[:user_id] = 2
+ get :quote, :params => {
+ :board_id => 1,
+ :id => 1
+ },
+ :xhr => true
+ assert_response :success
+ assert_equal 'text/javascript', response.content_type
+
+ assert_include 'RE: First post', response.body
+ assert_include "Redmine Admin wrote:", response.body
+ assert_include '> This is the very first post\n> in the forum', response.body
+ end
+
+ def test_quote_if_message_is_not_root
@request.session[:user_id] = 2
get :quote, :params => {
:board_id => 1,
@@ -268,6 +283,7 @@ class MessagesControllerTest < Redmine::ControllerTest
assert_equal 'text/javascript', response.content_type
assert_include 'RE: First post', response.body
+ assert_include 'John Smith wrote in message#3:', response.body
assert_include '> An other reply', response.body
end