diff --git a/app/assets/javascripts/discourse/models/topic.js b/app/assets/javascripts/discourse/models/topic.js index 68334d98f47..67d904b4678 100755 --- a/app/assets/javascripts/discourse/models/topic.js +++ b/app/assets/javascripts/discourse/models/topic.js @@ -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({ diff --git a/app/assets/javascripts/discourse/templates/list/topic_list_item.js.handlebars b/app/assets/javascripts/discourse/templates/list/topic_list_item.js.handlebars index 187df13b36a..860113e344e 100644 --- a/app/assets/javascripts/discourse/templates/list/topic_list_item.js.handlebars +++ b/app/assets/javascripts/discourse/templates/list/topic_list_item.js.handlebars @@ -28,6 +28,15 @@ {{#if unseen}} {{/if}} + + {{#if excerpt}} +
+ {{excerpt}} + {{#if excerptTruncated}} + {{i18n read_more}} + {{/if}} +
+ {{/if}} diff --git a/app/assets/stylesheets/application/topic-list.css.scss b/app/assets/stylesheets/application/topic-list.css.scss index 1e962c77932..0b92e9498e3 100755 --- a/app/assets/stylesheets/application/topic-list.css.scss +++ b/app/assets/stylesheets/application/topic-list.css.scss @@ -105,6 +105,12 @@ } } + .topic-excerpt { + font-size: 14px; + margin-top: 8px; + color: $dark_gray; + } + .rank-details { background-color: #eee; padding: 6px; diff --git a/app/serializers/topic_list_item_serializer.rb b/app/serializers/topic_list_item_serializer.rb index 677f0516524..63cebb1c776 100644 --- a/app/serializers/topic_list_item_serializer.rb +++ b/app/serializers/topic_list_item_serializer.rb @@ -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 diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 1005555b8a6..cc06947969b 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -30,6 +30,7 @@ en: you: "You" or: "or" now: "just now" + read_more: 'read more' suggested_topics: title: "Suggested Topics"