PERF: Show excerpt on group page.
This commit is contained in:
parent
965b38ff2a
commit
cdb7e14fa7
|
@ -7,12 +7,12 @@
|
||||||
</span>
|
</span>
|
||||||
<span class="category">{{category-link post.category}}</span>
|
<span class="category">{{category-link post.category}}</span>
|
||||||
<div class="group-member-info">
|
<div class="group-member-info">
|
||||||
{{#if post.user_long_name}}
|
{{#if post.user.name}}
|
||||||
<span class="name">{{post.user_long_name}}</span>{{#if post.user_title}}<span class="title">, {{post.user_title}}</span>{{/if}}
|
<span class="name">{{post.user.name}}</span>{{#if post.user.title}}<span class="title">, {{post.user.title}}</span>{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class='excerpt'>
|
<p class='excerpt'>
|
||||||
{{{unbound post.cooked}}}
|
{{{unbound post.excerpt}}}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class BasicUserSerializer < ApplicationSerializer
|
class BasicUserSerializer < ApplicationSerializer
|
||||||
attributes :id, :username, :avatar_template
|
attributes :id, :username, :avatar_template, :title, :name
|
||||||
|
|
||||||
def include_name?
|
def include_name?
|
||||||
SiteSetting.enable_names?
|
SiteSetting.enable_names?
|
||||||
|
|
|
@ -1,42 +1,22 @@
|
||||||
class GroupPostSerializer < ApplicationSerializer
|
class GroupPostSerializer < ApplicationSerializer
|
||||||
attributes :id,
|
attributes :id,
|
||||||
:cooked,
|
:excerpt,
|
||||||
:created_at,
|
:created_at,
|
||||||
:title,
|
:title,
|
||||||
:url,
|
:url,
|
||||||
:user_title,
|
|
||||||
:user_long_name,
|
|
||||||
:topic,
|
|
||||||
:category
|
:category
|
||||||
|
|
||||||
has_one :user, serializer: BasicUserSerializer, embed: :objects
|
has_one :user, serializer: BasicUserSerializer, embed: :object
|
||||||
|
has_one :topic, serializer: BasicTopicSerializer, embed: :object
|
||||||
|
|
||||||
def title
|
def title
|
||||||
object.topic.title
|
object.topic.title
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_long_name
|
|
||||||
object.user.try(:name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_title
|
|
||||||
object.user.try(:title)
|
|
||||||
end
|
|
||||||
|
|
||||||
def include_user_long_name?
|
def include_user_long_name?
|
||||||
SiteSetting.enable_names?
|
SiteSetting.enable_names?
|
||||||
end
|
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
|
def category
|
||||||
object.topic.category
|
object.topic.category
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue