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