define('home/models/Post',[
'jquery',
'underscore',
'core/models/Post',
'core/UniqueModel',
'home/models/Thread',
'home/models/User',
'home/collections/VotersUserCollection',
], function (
$,
_,
CorePost,
UniqueModel,
Thread,
User,
VotersUserCollection
) {
'use strict';
var parent = CorePost;
var parentProto = parent.prototype;
var Post = CorePost.extend({
// TODO: unify Home's VotersUserCollection with embed's
votersCollectionClass: VotersUserCollection,
initialize: function (attrs, options) {
parentProto.initialize.call(this, attrs, options);
this.set({ state: this._getPostState() });
this.initializeRelated(
'thread',
_.extend({ forum: attrs.forum }, options),
Thread
);
// this.author is set via the Post.withAuthor mixin from next-core
},
toJSON: function () {
var stringifiable = parentProto.toJSON.apply(this, arguments);
stringifiable.thread = this.thread.toJSON();
return stringifiable;
},
getLinks: _.memoize(function () {
var $wrapper = $('<div>').html(this.get('message'));
return $wrapper.find('a[href]').map(function (__, el) {
return $(el).attr('href');
});
}, function () {
return this.id;
}),
getThreadId: function () {
return this.thread.id;
},
_getPostState: function () {
if (this.get('isSpam'))
return 'spam';
if (this.get('isDeleted'))
return 'deleted';
// Once a post is flagged to over the site flag threshold it is unapproved
// Flagged + approved means it's still visible
if (this.get('isFlagged') && !this.get('isApproved'))
return 'flagged';
if (!this.get('isApproved'))
return 'pending';
return 'visible';
},
});
CorePost.withAuthor.call(Post.prototype, UniqueModel.boundModel(User));
// TODO - apply Post.withMediaCollection mixin
UniqueModel.addType('Post', Post);
return Post;
});
// https://c.disquscdn.com/next/82c6de3/home/js/models/Post.js
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}