Vulcan/packages/telescope-comments/lib/comments.js

140 lines
2.6 KiB
JavaScript
Raw Normal View History

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,
public: 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,
// regEx: SimpleSchema.RegEx.Id,
max: 500,
editableBy: ["member", "admin"],
optional: true,
2016-02-17 11:28:00 +09:00
public: true,
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
*/
topLevelCommentId: {
type: String,
// regEx: SimpleSchema.RegEx.Id,
max: 500,
editableBy: ["member", "admin"],
optional: true,
2016-02-17 11:28:00 +09:00
public: true,
autoform: {
omit: true // never show this
}
},
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-17 12:54:18 +09:00
public: 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,
public: 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,
max: 3000,
editableBy: ["member", "admin"],
2016-02-17 11:28:00 +09:00
public: 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,
public: 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,
public: 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,
public: 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,
optional: true,
2016-02-17 11:28:00 +09:00
public: true,
// regEx: SimpleSchema.RegEx.Id,
max: 500,
// editableBy: ["member", "admin"], // TODO: should users be able to set postId, but not modify it?
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,
public: 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,
public: true,
2015-04-22 07:50:26 +09:00
}
});
// Meteor.startup(function(){
// // needs to happen after every fields are added
// Comments.internationalize();
// });
Comments.attachSchema(Comments.schema);