2015-04-24 09:28:50 +09:00
|
|
|
/**
|
|
|
|
* The global namespace for Comments.
|
|
|
|
* @namespace Comments
|
|
|
|
*/
|
|
|
|
Comments = new Mongo.Collection("comments");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Comments schema
|
|
|
|
* @type {SimpleSchema}
|
|
|
|
*/
|
2015-05-11 12:15:10 +09:00
|
|
|
Comments.schema = new SimpleSchema({
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
ID
|
|
|
|
*/
|
2015-04-22 07:50:26 +09:00
|
|
|
_id: {
|
|
|
|
type: String,
|
2016-02-17 11:28:00 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: true,
|
2015-04-22 07:50:26 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The `_id` of the parent comment, if there is one
|
|
|
|
*/
|
2015-04-22 07:50:26 +09:00
|
|
|
parentCommentId: {
|
|
|
|
type: String,
|
2015-07-14 11:40:24 +09:00
|
|
|
// regEx: SimpleSchema.RegEx.Id,
|
2015-07-10 11:05:13 +09:00
|
|
|
max: 500,
|
2016-02-28 13:12:36 +09:00
|
|
|
insertableIf: Users.is.memberOrAdmin,
|
|
|
|
editableIf: Users.is.ownerOrAdmin,
|
2015-05-03 21:22:21 -04:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: true,
|
2015-05-03 21:22:21 -04:00
|
|
|
autoform: {
|
|
|
|
omit: true // never show this
|
|
|
|
}
|
2015-04-22 07:50:26 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The `_id` of the top-level parent comment, if there is one
|
|
|
|
*/
|
2015-05-05 16:45:53 -07:00
|
|
|
topLevelCommentId: {
|
|
|
|
type: String,
|
2015-07-14 11:40:24 +09:00
|
|
|
// regEx: SimpleSchema.RegEx.Id,
|
2015-07-10 11:05:13 +09:00
|
|
|
max: 500,
|
2016-02-28 13:12:36 +09:00
|
|
|
insertableIf: Users.is.memberOrAdmin,
|
|
|
|
editableIf: Users.is.ownerOrAdmin,
|
2015-05-05 17:10:19 -07:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: true,
|
2015-05-05 17:10:19 -07:00
|
|
|
autoform: {
|
|
|
|
omit: true // never show this
|
|
|
|
}
|
2015-05-05 16:45:53 -07:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The timestamp of comment creation
|
|
|
|
*/
|
2015-04-22 07:50:26 +09:00
|
|
|
createdAt: {
|
|
|
|
type: Date,
|
2016-02-17 11:28:00 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: false
|
2015-04-22 07:50:26 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The timestamp of the comment being posted. For now, comments are always created and posted at the same time
|
|
|
|
*/
|
|
|
|
postedAt: {
|
2015-04-22 07:50:26 +09:00
|
|
|
type: Date,
|
2016-02-17 11:28:00 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: true,
|
2015-04-22 07:50:26 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The comment body (Markdown)
|
|
|
|
*/
|
2015-04-22 07:50:26 +09:00
|
|
|
body: {
|
|
|
|
type: String,
|
2015-07-10 11:05:13 +09:00
|
|
|
max: 3000,
|
2016-02-28 13:12:36 +09:00
|
|
|
insertableIf: Users.is.memberOrAdmin,
|
|
|
|
editableIf: Users.is.ownerOrAdmin,
|
|
|
|
publish: true,
|
2015-04-28 09:44:43 +09:00
|
|
|
autoform: {
|
2015-08-12 17:56:42 +09:00
|
|
|
rows: 5,
|
|
|
|
afFormGroup: {
|
|
|
|
'formgroup-class': 'hide-label'
|
|
|
|
}
|
2015-04-28 09:44:43 +09:00
|
|
|
}
|
2015-04-22 07:50:26 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The HTML version of the comment body
|
|
|
|
*/
|
2015-04-22 07:50:26 +09:00
|
|
|
htmlBody: {
|
|
|
|
type: String,
|
2016-02-17 11:28:00 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: true,
|
2015-04-22 07:50:26 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The comment author's name
|
|
|
|
*/
|
2015-04-22 07:50:26 +09:00
|
|
|
author: {
|
|
|
|
type: String,
|
2016-02-17 11:28:00 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: true,
|
2015-04-22 07:50:26 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
Whether the comment is inactive. Inactive comments' scores gets recalculated less often
|
|
|
|
*/
|
2015-04-22 07:50:26 +09:00
|
|
|
inactive: {
|
|
|
|
type: Boolean,
|
2016-02-17 11:28:00 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: true,
|
2015-04-22 07:50:26 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The post's `_id`
|
|
|
|
*/
|
2015-04-22 07:50:26 +09:00
|
|
|
postId: {
|
2015-04-28 09:44:43 +09:00
|
|
|
type: String,
|
2015-04-28 15:54:19 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: true,
|
2015-07-14 11:40:24 +09:00
|
|
|
// regEx: SimpleSchema.RegEx.Id,
|
2015-07-10 11:05:13 +09:00
|
|
|
max: 500,
|
2016-02-28 13:12:36 +09:00
|
|
|
// editableIf: Users.is.ownerOrAdmin, // TODO: should users be able to set postId, but not modify it?
|
2015-04-28 15:54:19 +09:00
|
|
|
autoform: {
|
|
|
|
omit: true // never show this
|
|
|
|
}
|
2015-04-22 07:50:26 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
The comment author's `_id`
|
|
|
|
*/
|
2015-04-22 07:50:26 +09:00
|
|
|
userId: {
|
2015-04-28 09:44:43 +09:00
|
|
|
type: String,
|
2016-02-17 11:28:00 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: true,
|
2015-04-22 07:50:26 +09:00
|
|
|
},
|
2015-05-11 11:46:18 +09:00
|
|
|
/**
|
|
|
|
Whether the comment is deleted. Delete comments' content doesn't appear on the site.
|
|
|
|
*/
|
2015-04-22 07:50:26 +09:00
|
|
|
isDeleted: {
|
|
|
|
type: Boolean,
|
2016-02-17 11:28:00 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
publish: true,
|
2015-04-22 07:50:26 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-02-16 15:40:37 +09:00
|
|
|
// Meteor.startup(function(){
|
|
|
|
// // needs to happen after every fields are added
|
|
|
|
// Comments.internationalize();
|
|
|
|
// });
|
2015-04-25 13:03:04 +09:00
|
|
|
|
2016-02-17 21:57:07 +09:00
|
|
|
Comments.attachSchema(Comments.schema);
|
|
|
|
|
|
|
|
if (typeof Herald !== "undefined") {
|
|
|
|
Comments.addField({
|
|
|
|
fieldName: 'disableNotifications',
|
|
|
|
fieldSchema: {
|
|
|
|
type: Boolean,
|
|
|
|
optional: true,
|
|
|
|
autoform: {
|
|
|
|
omit: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|