mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 14:03:18 +08:00
NEW: Add user name and title to group posts.
This commit is contained in:
parent
669247977b
commit
a929eda8ba
|
@ -0,0 +1,21 @@
|
||||||
|
Discourse.GroupPostController = Em.ObjectController.extend({
|
||||||
|
|
||||||
|
byName: function() {
|
||||||
|
var result = "",
|
||||||
|
longName = this.get('user_long_name'),
|
||||||
|
title = this.get('user_title');
|
||||||
|
|
||||||
|
if (!Em.isEmpty(longName)) {
|
||||||
|
result += longName;
|
||||||
|
}
|
||||||
|
if (!Em.isEmpty(title)) {
|
||||||
|
if (result.length > 0) {
|
||||||
|
result += ", ";
|
||||||
|
}
|
||||||
|
result += title;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}.property()
|
||||||
|
|
||||||
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class='user-stream'>
|
<div class='user-stream'>
|
||||||
{{#groupedEach model}}
|
{{#each model itemController="groupPost"}}
|
||||||
<div class='item'>
|
<div class='item'>
|
||||||
<div class='clearfix info'>
|
<div class='clearfix info'>
|
||||||
{{#link-to 'user' user class="avatar-link"}}<div class='avatar-wrapper'>{{avatar user imageSize="large" extraClasses="actor" ignoreTitle="true"}}</div>{{/link-to}}
|
{{#link-to 'user' user class="avatar-link"}}<div class='avatar-wrapper'>{{avatar user imageSize="large" extraClasses="actor" ignoreTitle="true"}}</div>{{/link-to}}
|
||||||
|
@ -7,10 +7,15 @@
|
||||||
<span class="title">
|
<span class="title">
|
||||||
<a href="{{unbound url}}">{{unbound title}}</a>
|
<a href="{{unbound url}}">{{unbound title}}</a>
|
||||||
</span>
|
</span>
|
||||||
|
{{#if byName}}
|
||||||
|
<span class="title">
|
||||||
|
{{unbound byName}}
|
||||||
|
</span>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<p class='excerpt'>
|
<p class='excerpt'>
|
||||||
{{{unbound cooked}}}
|
{{{unbound cooked}}}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{{/groupedEach}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,7 +3,9 @@ class GroupPostSerializer < ApplicationSerializer
|
||||||
:cooked,
|
:cooked,
|
||||||
:created_at,
|
:created_at,
|
||||||
:title,
|
:title,
|
||||||
:url
|
:url,
|
||||||
|
:user_title,
|
||||||
|
:user_long_name
|
||||||
|
|
||||||
has_one :user, serializer: BasicUserSerializer, embed: :objects
|
has_one :user, serializer: BasicUserSerializer, embed: :objects
|
||||||
|
|
||||||
|
@ -11,5 +13,16 @@ class GroupPostSerializer < ApplicationSerializer
|
||||||
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?
|
||||||
|
SiteSetting.enable_names?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user