PERF: Show excerpt on group page.
This commit is contained in:
parent
965b38ff2a
commit
cdb7e14fa7
|
@ -7,12 +7,12 @@
|
|||
</span>
|
||||
<span class="category">{{category-link post.category}}</span>
|
||||
<div class="group-member-info">
|
||||
{{#if post.user_long_name}}
|
||||
<span class="name">{{post.user_long_name}}</span>{{#if post.user_title}}<span class="title">, {{post.user_title}}</span>{{/if}}
|
||||
{{#if post.user.name}}
|
||||
<span class="name">{{post.user.name}}</span>{{#if post.user.title}}<span class="title">, {{post.user.title}}</span>{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
<p class='excerpt'>
|
||||
{{{unbound post.cooked}}}
|
||||
{{{unbound post.excerpt}}}
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue