Merge pull request #50 from davidtaylorhq/quote_answer
UX: Show configurable length excerpt when quoting the solution
This commit is contained in:
commit
cf4a3b2043
|
@ -47,7 +47,8 @@ function acceptPost(post) {
|
||||||
|
|
||||||
topic.set('accepted_answer', {
|
topic.set('accepted_answer', {
|
||||||
username: post.get('username'),
|
username: post.get('username'),
|
||||||
post_number: post.get('post_number')
|
post_number: post.get('post_number'),
|
||||||
|
excerpt: post.get('cooked'),
|
||||||
});
|
});
|
||||||
|
|
||||||
ajax("/solution/accept", {
|
ajax("/solution/accept", {
|
||||||
|
@ -160,7 +161,9 @@ function initializeWithApi(api) {
|
||||||
<div class='title'>
|
<div class='title'>
|
||||||
${topic.get('acceptedAnswerHtml')} <div class="quote-controls"><\/div>
|
${topic.get('acceptedAnswerHtml')} <div class="quote-controls"><\/div>
|
||||||
</div>
|
</div>
|
||||||
<blockquote></blockquote>
|
<blockquote>
|
||||||
|
${topic.get('accepted_answer').excerpt}
|
||||||
|
</blockquote>
|
||||||
</aside>`
|
</aside>`
|
||||||
|
|
||||||
var cooked = new PostCooked({cooked:rawhtml});
|
var cooked = new PostCooked({cooked:rawhtml});
|
||||||
|
|
|
@ -4,6 +4,7 @@ en:
|
||||||
allow_solved_on_all_topics: "Allow users to select solutions on all topics (by default you control this by editing categories)"
|
allow_solved_on_all_topics: "Allow users to select solutions on all topics (by default you control this by editing categories)"
|
||||||
accept_all_solutions_trust_level: "Minimum trust level required to accept solutions on any topic (even when not OP)"
|
accept_all_solutions_trust_level: "Minimum trust level required to accept solutions on any topic (even when not OP)"
|
||||||
empty_box_on_unsolved: "Display an empty box next to unsolved topics"
|
empty_box_on_unsolved: "Display an empty box next to unsolved topics"
|
||||||
|
solved_quote_length: "Number of characters to quote when displaying the solution under the first post"
|
||||||
reports:
|
reports:
|
||||||
accepted_solutions:
|
accepted_solutions:
|
||||||
title: "Accepted solutions"
|
title: "Accepted solutions"
|
||||||
|
|
|
@ -11,3 +11,7 @@ plugins:
|
||||||
empty_box_on_unsolved:
|
empty_box_on_unsolved:
|
||||||
default: false
|
default: false
|
||||||
client: true
|
client: true
|
||||||
|
solved_quote_length:
|
||||||
|
default: 100
|
||||||
|
client: false
|
||||||
|
|
||||||
|
|
11
plugin.rb
11
plugin.rb
|
@ -224,17 +224,22 @@ SQL
|
||||||
{
|
{
|
||||||
post_number: info[0],
|
post_number: info[0],
|
||||||
username: info[1],
|
username: info[1],
|
||||||
|
excerpt: info[2]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def accepted_answer_post_info
|
def accepted_answer_post_info
|
||||||
# TODO: we may already have it in the stream ... so bypass query here
|
# TODO: we may already have it in the stream ... so bypass query here
|
||||||
|
postInfo = Post.where(id: accepted_answer_post_id, topic_id: object.topic.id)
|
||||||
Post.where(id: accepted_answer_post_id, topic_id: object.topic.id)
|
|
||||||
.joins(:user)
|
.joins(:user)
|
||||||
.pluck('post_number, username')
|
.pluck('post_number', 'username', 'cooked')
|
||||||
.first
|
.first
|
||||||
|
|
||||||
|
if postInfo
|
||||||
|
postInfo[2] = PrettyText.excerpt(postInfo[2], SiteSetting.solved_quote_length)
|
||||||
|
return postInfo
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def accepted_answer_post_id
|
def accepted_answer_post_id
|
||||||
|
|
Loading…
Reference in New Issue