mirror of
https://github.com/flarum/framework.git
synced 2025-02-02 11:56:16 +08:00
42851f425b
It works but it’s not the most pretty thing in the world. @franzliedke Would be great if you could take a look at the whole formatting API and work your magic on it sometime… my brain is fried!
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
import Model from 'flarum/model';
|
|
import computed from 'flarum/utils/computed';
|
|
|
|
class Post extends Model {}
|
|
|
|
Post.prototype.id = Model.prop('id');
|
|
Post.prototype.number = Model.prop('number');
|
|
Post.prototype.discussion = Model.one('discussion');
|
|
|
|
Post.prototype.time = Model.prop('time', Model.date);
|
|
Post.prototype.user = Model.one('user');
|
|
Post.prototype.contentType = Model.prop('contentType');
|
|
Post.prototype.content = Model.prop('content');
|
|
Post.prototype.contentHtml = Model.prop('contentHtml');
|
|
Post.prototype.contentPlain = computed('contentHtml', contentHtml => $('<div/>').html(contentHtml.replace(/(<\/p>|<br>)/g, '$1 ')).text());
|
|
|
|
Post.prototype.editTime = Model.prop('editTime', Model.date);
|
|
Post.prototype.editUser = Model.one('editUser');
|
|
Post.prototype.isEdited = computed('editTime', editTime => !!editTime);
|
|
|
|
Post.prototype.hideTime = Model.prop('hideTime', Model.date);
|
|
Post.prototype.hideUser = Model.one('hideUser');
|
|
Post.prototype.isHidden = computed('hideTime', hideTime => !!hideTime);
|
|
|
|
Post.prototype.canEdit = Model.prop('canEdit');
|
|
Post.prototype.canDelete = Model.prop('canDelete');
|
|
|
|
export default Post;
|