mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 12:43:52 +08:00
Bring back sticky discussion excerpts
This commit is contained in:
parent
835c3eef71
commit
039606e325
13
extensions/sticky/js/bootstrap.js
vendored
13
extensions/sticky/js/bootstrap.js
vendored
|
@ -3,10 +3,12 @@ import Model from 'flarum/model';
|
|||
import Discussion from 'flarum/models/discussion';
|
||||
import DiscussionPage from 'flarum/components/discussion-page';
|
||||
import DiscussionList from 'flarum/components/discussion-list';
|
||||
import DiscussionListItem from 'flarum/components/discussion-list-item';
|
||||
import Badge from 'flarum/components/badge';
|
||||
import ActionButton from 'flarum/components/action-button';
|
||||
import SettingsPage from 'flarum/components/settings-page';
|
||||
import icon from 'flarum/helpers/icon';
|
||||
import truncate from 'flarum/utils/truncate';
|
||||
import app from 'flarum/app';
|
||||
|
||||
import DiscussionStickiedPost from 'flarum-sticky/components/discussion-stickied-post';
|
||||
|
@ -57,20 +59,23 @@ app.initializers.add('sticky', function() {
|
|||
items.add('discussionStickied', {
|
||||
name: 'discussionStickied',
|
||||
label: [icon('thumb-tack'), ' Someone stickies a discussion I started']
|
||||
});
|
||||
}, {after: 'discussionRenamed'});
|
||||
});
|
||||
|
||||
extend(DiscussionList.prototype, 'params', function(params) {
|
||||
params.include.push('startPost');
|
||||
});
|
||||
|
||||
extend(DiscussionList.prototype, 'infoItems', function(items, discussion) {
|
||||
extend(DiscussionListItem.prototype, 'infoItems', function(items) {
|
||||
var discussion = this.props.discussion;
|
||||
|
||||
if (discussion.isSticky()) {
|
||||
console.log(discussion.startPost())
|
||||
var startPost = discussion.startPost();
|
||||
if (startPost) {
|
||||
var excerpt = m('span', startPost.excerpt());
|
||||
var excerpt = m('span', truncate(startPost.contentPlain(), 200));
|
||||
excerpt.wrapperClass = 'discussion-excerpt';
|
||||
var item = items.add('excerpt', excerpt, {last: true});
|
||||
items.add('excerpt', excerpt, {last: true});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -28,6 +28,10 @@ class StickyServiceProvider extends ServiceProvider
|
|||
$attributes['canSticky'] = (bool) $model->can($user, 'sticky');
|
||||
}),
|
||||
|
||||
// include discussion start posts by default
|
||||
(new Extend\ApiAction('Flarum\Api\Actions\Discussions\IndexAction'))
|
||||
->addInclude('startPost'),
|
||||
|
||||
new Extend\DiscussionGambit('Flarum\Sticky\StickyGambit'),
|
||||
|
||||
(new Extend\NotificationType('Flarum\Sticky\DiscussionStickiedNotification', 'Flarum\Api\Serializers\DiscussionBasicSerializer'))
|
||||
|
|
Loading…
Reference in New Issue
Block a user