2015-05-08 09:20:58 +09:00
|
|
|
/**
|
2016-04-09 09:41:20 +09:00
|
|
|
* @summary Comment views are filters used for subscribing to and viewing comments
|
2015-05-08 09:20:58 +09:00
|
|
|
* @namespace Comments.views
|
|
|
|
*/
|
|
|
|
Comments.views = {};
|
|
|
|
|
|
|
|
/**
|
2016-04-09 09:41:20 +09:00
|
|
|
* @summary Add a module to a comment view
|
2015-05-08 09:20:58 +09:00
|
|
|
* @param {string} viewName - The name of the view
|
|
|
|
* @param {function} [viewFunction] - The function used to calculate query terms. Takes terms and baseParameters arguments
|
|
|
|
*/
|
2015-05-17 15:38:02 +09:00
|
|
|
Comments.views.add = function (viewName, viewFunction) {
|
2015-05-08 09:20:58 +09:00
|
|
|
Comments.views[viewName] = viewFunction;
|
|
|
|
};
|
|
|
|
|
|
|
|
// will be common to all other view unless specific properties are overwritten
|
|
|
|
Comments.views.baseParameters = {
|
|
|
|
options: {
|
|
|
|
limit: 10
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-17 15:38:02 +09:00
|
|
|
Comments.views.add("postComments", function (terms) {
|
2015-05-08 09:20:58 +09:00
|
|
|
return {
|
2016-02-17 19:39:43 +09:00
|
|
|
selector: {postId: terms.postId},
|
2015-05-20 09:19:50 +09:00
|
|
|
options: {limit: 0, sort: {score: -1, postedAt: -1}}
|
2015-05-08 09:20:58 +09:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2015-05-17 15:38:02 +09:00
|
|
|
Comments.views.add("userComments", function (terms) {
|
2015-05-08 09:20:58 +09:00
|
|
|
return {
|
2016-02-17 19:39:43 +09:00
|
|
|
selector: {userId: terms.userId},
|
2015-05-08 09:33:27 +09:00
|
|
|
options: {sort: {postedAt: -1}}
|
2015-05-08 09:20:58 +09:00
|
|
|
};
|
|
|
|
});
|