FEATURE: hide excerpt if 'solved_quote_length' is set to zero

This commit is contained in:
Kyle Zhao 2017-08-06 17:22:30 -04:00
parent 6ab44835b8
commit 9104e2292c
3 changed files with 19 additions and 3 deletions

View File

@ -102,8 +102,9 @@ function initializeWithApi(api) {
if (postModel) { if (postModel) {
const topic = postModel.get('topic'); const topic = postModel.get('topic');
if (topic.get('accepted_answer')) { if (topic.get('accepted_answer')) {
const hasExcerpt = !!topic.get('accepted_answer').excerpt;
var rawhtml = ` const withExcerpt = `
<aside class='quote' data-post="${topic.get('accepted_answer').post_number}" data-topic="${topic.get('id')}"> <aside class='quote' data-post="${topic.get('accepted_answer').post_number}" data-topic="${topic.get('id')}">
<div class='title'> <div class='title'>
${topic.get('acceptedAnswerHtml')} <div class="quote-controls"><\/div> ${topic.get('acceptedAnswerHtml')} <div class="quote-controls"><\/div>
@ -113,7 +114,14 @@ function initializeWithApi(api) {
</blockquote> </blockquote>
</aside>`; </aside>`;
var cooked = new PostCooked({cooked:rawhtml}); const withoutExcerpt = `
<aside class='quote'>
<div class='title title-only'>
${topic.get('acceptedAnswerHtml')}
</div>
</aside>`;
var cooked = new PostCooked({ cooked: hasExcerpt ? withExcerpt : withoutExcerpt });
var html = cooked.init(); var html = cooked.init();

View File

@ -38,3 +38,7 @@
//border-top: 1px solid #ddd; //border-top: 1px solid #ddd;
//background-color: #E9FFE0; //background-color: #E9FFE0;
} }
aside.quote .title.title-only {
padding: 12px;
}

View File

@ -250,7 +250,11 @@ SQL
.first .first
if postInfo if postInfo
postInfo[2] = PrettyText.excerpt(postInfo[2], SiteSetting.solved_quote_length) postInfo[2] = if SiteSetting.solved_quote_length > 0
PrettyText.excerpt(postInfo[2], SiteSetting.solved_quote_length)
else
nil
end
return postInfo return postInfo
end end
end end