From cdb7e14fa7e1fec62d68674e30eaad99fb13a868 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 5 Dec 2016 18:12:24 +0800 Subject: [PATCH] PERF: Show excerpt on group page. --- .../templates/components/group-post.hbs | 6 ++--- app/serializers/basic_user_serializer.rb | 2 +- app/serializers/group_post_serializer.rb | 26 +++---------------- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/app/assets/javascripts/discourse/templates/components/group-post.hbs b/app/assets/javascripts/discourse/templates/components/group-post.hbs index 45a16422810..09ac259ce27 100644 --- a/app/assets/javascripts/discourse/templates/components/group-post.hbs +++ b/app/assets/javascripts/discourse/templates/components/group-post.hbs @@ -7,12 +7,12 @@ {{category-link post.category}}
- {{#if post.user_long_name}} - {{post.user_long_name}}{{#if post.user_title}}, {{post.user_title}}{{/if}} + {{#if post.user.name}} + {{post.user.name}}{{#if post.user.title}}, {{post.user.title}}{{/if}} {{/if}}

- {{{unbound post.cooked}}} + {{{unbound post.excerpt}}}

diff --git a/app/serializers/basic_user_serializer.rb b/app/serializers/basic_user_serializer.rb index 8880c8dbd7e..6c46413dcd4 100644 --- a/app/serializers/basic_user_serializer.rb +++ b/app/serializers/basic_user_serializer.rb @@ -1,5 +1,5 @@ class BasicUserSerializer < ApplicationSerializer - attributes :id, :username, :avatar_template + attributes :id, :username, :avatar_template, :title, :name def include_name? SiteSetting.enable_names? diff --git a/app/serializers/group_post_serializer.rb b/app/serializers/group_post_serializer.rb index 77f1eb95b38..b6f36716131 100644 --- a/app/serializers/group_post_serializer.rb +++ b/app/serializers/group_post_serializer.rb @@ -1,42 +1,22 @@ class GroupPostSerializer < ApplicationSerializer attributes :id, - :cooked, + :excerpt, :created_at, :title, :url, - :user_title, - :user_long_name, - :topic, :category - has_one :user, serializer: BasicUserSerializer, embed: :objects + has_one :user, serializer: BasicUserSerializer, embed: :object + has_one :topic, serializer: BasicTopicSerializer, embed: :object def title object.topic.title end - def user_long_name - object.user.try(:name) - end - - def user_title - object.user.try(:title) - end - def include_user_long_name? SiteSetting.enable_names? end - def topic - object.topic - end - - def cooked - fragment = Nokogiri::HTML.fragment(object.cooked) - DiscourseEvent.trigger(:reduce_cooked, fragment, object) - fragment.to_html - end - def category object.topic.category end