Show an excerpt of a pinned topic's body in the topic list
This commit is contained in:
parent
3673744e6d
commit
442be64d5e
|
@ -368,7 +368,12 @@ Discourse.Topic = Discourse.Model.extend({
|
|||
// If the post directly below's reply_to_post_number is our post number, it's
|
||||
// considered directly below.
|
||||
return (postBelow ? postBelow.get('reply_to_post_number') : void 0) === post.get('post_number');
|
||||
}
|
||||
},
|
||||
|
||||
excerptTruncated: function() {
|
||||
var e = this.get('excerpt');
|
||||
return( e && e.substr(e.length - 8,8) == '…' );
|
||||
}.property('excerpt')
|
||||
});
|
||||
|
||||
Discourse.Topic.reopenClass({
|
||||
|
|
|
@ -28,6 +28,15 @@
|
|||
{{#if unseen}}
|
||||
<a href="{{lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
||||
{{/if}}
|
||||
|
||||
{{#if excerpt}}
|
||||
<div class="topic-excerpt">
|
||||
{{excerpt}}
|
||||
{{#if excerptTruncated}}
|
||||
<a href="{{lastReadUrl}}">{{i18n read_more}}</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td class='category'>
|
||||
|
|
|
@ -105,6 +105,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
.topic-excerpt {
|
||||
font-size: 14px;
|
||||
margin-top: 8px;
|
||||
color: $dark_gray;
|
||||
}
|
||||
|
||||
.rank-details {
|
||||
background-color: #eee;
|
||||
padding: 6px;
|
||||
|
|
|
@ -11,7 +11,8 @@ class TopicListItemSerializer < ListableTopicSerializer
|
|||
:starred,
|
||||
:has_best_of,
|
||||
:archetype,
|
||||
:rank_details
|
||||
:rank_details,
|
||||
:excerpt
|
||||
|
||||
has_one :category
|
||||
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
|
||||
|
@ -54,5 +55,12 @@ class TopicListItemSerializer < ListableTopicSerializer
|
|||
PinnedCheck.new(object, object.user_data).pinned?
|
||||
end
|
||||
|
||||
def include_excerpt?
|
||||
pinned
|
||||
end
|
||||
|
||||
def excerpt
|
||||
object.posts.first.try(:excerpt,200) || nil
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -30,6 +30,7 @@ en:
|
|||
you: "You"
|
||||
or: "or"
|
||||
now: "just now"
|
||||
read_more: 'read more'
|
||||
|
||||
suggested_topics:
|
||||
title: "Suggested Topics"
|
||||
|
|
Loading…
Reference in New Issue