2014-09-18 07:24:42 +09:00
|
|
|
// ------------------------------------- Schemas -------------------------------- //
|
2014-06-22 14:53:17 +09:00
|
|
|
|
2014-07-06 14:09:55 +09:00
|
|
|
// array containing properties to be added to the post/settings/comments schema on startup.
|
2014-06-22 14:53:17 +09:00
|
|
|
addToPostSchema = [];
|
2014-07-06 14:09:55 +09:00
|
|
|
addToCommentsSchema = [];
|
|
|
|
addToSettingsSchema = [];
|
2014-10-06 17:11:43 -06:00
|
|
|
addToUserSchema = [];
|
2014-06-22 14:53:17 +09:00
|
|
|
|
2014-10-05 17:20:15 +09:00
|
|
|
SimpleSchema.extendOptions({
|
|
|
|
editable: Match.Optional(Boolean), // editable: true means the field can be edited by the document's owner
|
|
|
|
hidden: Match.Optional(Boolean) // hidden: true means the field is never shown in a form no matter what
|
|
|
|
});
|
|
|
|
// ----------------------------------- Posts Statuses ------------------------------ //
|
|
|
|
|
|
|
|
postStatuses = [
|
|
|
|
{
|
|
|
|
value: 1,
|
|
|
|
label: 'Pending'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 2,
|
|
|
|
label: 'Approved'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 3,
|
|
|
|
label: 'Rejected'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
STATUS_PENDING=1;
|
|
|
|
STATUS_APPROVED=2;
|
|
|
|
STATUS_REJECTED=3;
|
|
|
|
|
2014-09-18 07:24:42 +09:00
|
|
|
// ------------------------------------- Navigation -------------------------------- //
|
|
|
|
|
|
|
|
|
|
|
|
// array containing nav items; initialize with views menu and admin menu
|
|
|
|
primaryNav = ['viewsMenu', 'adminMenu'];
|
|
|
|
|
|
|
|
secondaryNav = ['userMenu', 'notificationsMenu', 'submitButton'];
|
|
|
|
|
|
|
|
// array containing items in the admin menu
|
2014-12-08 16:39:10 +09:00
|
|
|
adminNav = [
|
|
|
|
{
|
|
|
|
route: 'posts_pending',
|
|
|
|
label: 'Pending'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
route: 'posts_scheduled',
|
|
|
|
label: 'Scheduled'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
route: 'all-users',
|
|
|
|
label: 'Users'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
route: 'settings',
|
|
|
|
label: 'Settings'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
route: 'toolbox',
|
|
|
|
label: 'Toolbox'
|
|
|
|
}
|
|
|
|
];
|
2014-09-18 07:24:42 +09:00
|
|
|
|
2014-06-22 14:53:17 +09:00
|
|
|
// array containing items in the views menu
|
2014-07-22 11:29:01 +09:00
|
|
|
viewNav = [
|
|
|
|
{
|
|
|
|
route: 'posts_top',
|
2014-11-20 14:55:34 +09:00
|
|
|
label: 'top'
|
2014-07-22 11:29:01 +09:00
|
|
|
},
|
|
|
|
{
|
|
|
|
route: 'posts_new',
|
2014-11-20 14:55:34 +09:00
|
|
|
label: 'new'
|
2014-07-22 11:29:01 +09:00
|
|
|
},
|
|
|
|
{
|
|
|
|
route: 'posts_best',
|
2014-11-20 14:55:34 +09:00
|
|
|
label: 'best'
|
2014-12-08 11:15:20 +09:00
|
|
|
}
|
2014-07-22 11:29:01 +09:00
|
|
|
];
|
2014-06-22 14:53:17 +09:00
|
|
|
|
2014-09-18 07:24:42 +09:00
|
|
|
// ------------------------------------- Views -------------------------------- //
|
2014-08-12 16:16:44 +09:00
|
|
|
|
2014-06-23 12:08:01 +09:00
|
|
|
|
2014-06-23 12:28:40 +09:00
|
|
|
// object containing post list view parameters
|
2014-12-08 16:39:10 +09:00
|
|
|
viewParameters = {};
|
|
|
|
|
|
|
|
// will be common to all other view unless specific properties are overwritten
|
|
|
|
viewParameters.baseParameters = {
|
|
|
|
find: {
|
|
|
|
status: STATUS_APPROVED
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
limit: 10
|
|
|
|
}
|
|
|
|
};
|
2014-06-23 12:28:40 +09:00
|
|
|
|
2014-07-22 11:29:01 +09:00
|
|
|
viewParameters.top = function (terms) {
|
|
|
|
return {
|
|
|
|
options: {sort: {sticky: -1, score: -1}}
|
|
|
|
};
|
2014-06-23 12:28:40 +09:00
|
|
|
}
|
|
|
|
|
2014-07-22 11:29:01 +09:00
|
|
|
viewParameters.new = function (terms) {
|
|
|
|
return {
|
|
|
|
options: {sort: {sticky: -1, postedAt: -1}}
|
|
|
|
};
|
2014-06-23 12:28:40 +09:00
|
|
|
}
|
|
|
|
|
2014-07-22 11:29:01 +09:00
|
|
|
viewParameters.best = function (terms) {
|
|
|
|
return {
|
|
|
|
options: {sort: {sticky: -1, baseScore: -1}}
|
|
|
|
};
|
2014-06-23 12:28:40 +09:00
|
|
|
}
|
|
|
|
|
2014-07-22 11:29:01 +09:00
|
|
|
viewParameters.pending = function (terms) {
|
|
|
|
return {
|
2014-10-06 10:27:28 +09:00
|
|
|
find: {
|
2014-12-08 16:39:10 +09:00
|
|
|
status: 1
|
2014-10-06 10:27:28 +09:00
|
|
|
},
|
2014-12-08 16:39:10 +09:00
|
|
|
options: {sort: {createdAt: -1}},
|
|
|
|
showFuture: true
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
viewParameters.scheduled = function (terms) {
|
|
|
|
return {
|
|
|
|
find: {postedAt: {$gte: new Date()}},
|
|
|
|
options: {sort: {postedAt: -1}},
|
|
|
|
showFuture: true
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-12-08 17:25:11 +09:00
|
|
|
viewParameters.userPosts = function (terms) {
|
2014-12-08 16:39:10 +09:00
|
|
|
return {
|
2014-12-08 17:25:11 +09:00
|
|
|
find: {userId: terms.userId},
|
|
|
|
options: {limit: 5, sort: {postedAt: -1}}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-12-08 18:16:44 +09:00
|
|
|
viewParameters.userUpvotedPosts = function (terms) {
|
2014-12-08 17:25:11 +09:00
|
|
|
var user = Meteor.users.findOne(terms.userId);
|
|
|
|
var postsIds = _.pluck(user.votes.upvotedPosts, "itemId");
|
|
|
|
return {
|
2014-12-08 18:16:44 +09:00
|
|
|
find: {_id: {$in: postsIds}, userId: {$ne: terms.userId}}, // exclude own posts
|
2014-12-08 17:25:11 +09:00
|
|
|
options: {limit: 5, sort: {postedAt: -1}}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-12-08 18:16:44 +09:00
|
|
|
viewParameters.userDownvotedPosts = function (terms) {
|
2014-12-08 17:25:11 +09:00
|
|
|
var user = Meteor.users.findOne(terms.userId);
|
|
|
|
var postsIds = _.pluck(user.votes.downvotedPosts, "itemId");
|
2014-12-08 19:51:39 +09:00
|
|
|
// TODO: sort based on votedAt timestamp and not postedAt, if possible
|
2014-12-08 17:25:11 +09:00
|
|
|
return {
|
2014-12-08 19:51:39 +09:00
|
|
|
find: {_id: {$in: postsIds}},
|
2014-12-08 17:25:11 +09:00
|
|
|
options: {limit: 5, sort: {postedAt: -1}}
|
2014-07-22 11:29:01 +09:00
|
|
|
};
|
2014-06-23 12:28:40 +09:00
|
|
|
}
|
|
|
|
|
2014-08-05 10:16:05 +09:00
|
|
|
heroModules = [];
|
|
|
|
|
2014-09-18 07:24:42 +09:00
|
|
|
footerModules = [];
|
|
|
|
|
2014-07-04 12:44:36 +09:00
|
|
|
// array containing post modules
|
2014-07-05 13:32:01 +09:00
|
|
|
modulePositions = [
|
2014-07-07 13:41:25 +09:00
|
|
|
'left-left',
|
|
|
|
'left-center',
|
|
|
|
'left-right',
|
|
|
|
'center-left',
|
|
|
|
'center-center',
|
|
|
|
'center-right',
|
|
|
|
'right-left',
|
|
|
|
'right-center',
|
|
|
|
'right-right'
|
2014-07-05 13:32:01 +09:00
|
|
|
];
|
|
|
|
|
2014-07-04 12:44:36 +09:00
|
|
|
postModules = [
|
|
|
|
{
|
2014-07-04 14:07:50 +09:00
|
|
|
template: 'postUpvote',
|
2014-07-07 14:36:51 +09:00
|
|
|
position: 'left-left'
|
2014-07-04 12:44:36 +09:00
|
|
|
},
|
|
|
|
{
|
2014-07-14 11:08:38 +09:00
|
|
|
template: 'postActions',
|
|
|
|
position: 'left-right'
|
2014-07-04 12:44:36 +09:00
|
|
|
},
|
2014-07-14 10:12:02 +09:00
|
|
|
{
|
2014-07-14 11:08:38 +09:00
|
|
|
template: 'postContent',
|
|
|
|
position: 'center-center'
|
2014-07-14 10:12:02 +09:00
|
|
|
},
|
2014-07-04 12:44:36 +09:00
|
|
|
{
|
2014-07-04 14:07:50 +09:00
|
|
|
template: 'postDiscuss',
|
2014-07-07 14:36:51 +09:00
|
|
|
position: 'right-right'
|
2014-07-04 12:44:36 +09:00
|
|
|
}
|
2014-07-05 11:24:28 +09:00
|
|
|
];
|
|
|
|
|
2014-07-14 10:12:02 +09:00
|
|
|
postHeading = [
|
|
|
|
{
|
|
|
|
template: 'postTitle',
|
|
|
|
order: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
template: 'postDomain',
|
|
|
|
order: 5
|
|
|
|
}
|
2014-12-04 12:38:20 +09:00
|
|
|
];
|
2014-07-14 10:12:02 +09:00
|
|
|
|
|
|
|
postMeta = [
|
|
|
|
{
|
2014-12-04 12:38:20 +09:00
|
|
|
template: 'postAuthor',
|
2014-07-14 10:12:02 +09:00
|
|
|
order: 1
|
|
|
|
},
|
2014-12-04 12:38:20 +09:00
|
|
|
{
|
|
|
|
template: 'postInfo',
|
|
|
|
order: 2
|
|
|
|
},
|
2014-07-14 10:12:02 +09:00
|
|
|
{
|
|
|
|
template: 'postCommentsLink',
|
|
|
|
order: 3
|
|
|
|
},
|
|
|
|
{
|
|
|
|
template: 'postAdmin',
|
|
|
|
order: 5
|
|
|
|
}
|
|
|
|
]
|
2014-07-05 18:06:28 +09:00
|
|
|
// ------------------------------ Callbacks ------------------------------ //
|
|
|
|
|
2014-08-01 09:07:58 +09:00
|
|
|
postSubmitRenderedCallbacks = [];
|
2014-07-05 18:06:28 +09:00
|
|
|
postSubmitClientCallbacks = [];
|
2014-09-20 09:53:58 +09:00
|
|
|
postSubmitMethodCallbacks = [];
|
2014-09-20 10:42:42 +09:00
|
|
|
postAfterSubmitMethodCallbacks = [];
|
2014-07-05 18:06:28 +09:00
|
|
|
|
2014-08-01 09:07:58 +09:00
|
|
|
postEditRenderedCallbacks = [];
|
2014-07-05 18:06:28 +09:00
|
|
|
postEditClientCallbacks = [];
|
2014-09-20 09:53:58 +09:00
|
|
|
postEditMethodCallbacks = []; // not used yet
|
2014-11-29 10:25:11 +09:00
|
|
|
postAfterEditMethodCallbacks = []; // not used yet
|
2014-07-05 18:06:28 +09:00
|
|
|
|
2014-09-20 09:53:58 +09:00
|
|
|
commentSubmitRenderedCallbacks = [];
|
|
|
|
commentSubmitClientCallbacks = [];
|
|
|
|
commentSubmitMethodCallbacks = [];
|
2014-09-20 10:42:42 +09:00
|
|
|
commentAfterSubmitMethodCallbacks = [];
|
2014-07-05 18:06:28 +09:00
|
|
|
|
2014-09-20 09:53:58 +09:00
|
|
|
commentEditRenderedCallbacks = [];
|
|
|
|
commentEditClientCallbacks = [];
|
|
|
|
commentEditMethodCallbacks = []; // not used yet
|
2014-09-20 10:42:42 +09:00
|
|
|
commentAfterEditMethodCallbacks = []; // not used yet
|
2014-07-05 18:06:28 +09:00
|
|
|
|
2014-12-08 14:53:26 +09:00
|
|
|
// ------------------------------------- User Profiles -------------------------------- //
|
|
|
|
|
|
|
|
userProfileDisplay = [
|
|
|
|
{
|
|
|
|
template: 'userInfo',
|
|
|
|
order: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
template: 'userPosts',
|
|
|
|
order: 2
|
|
|
|
},
|
|
|
|
{
|
|
|
|
template: 'userUpvotedPosts',
|
|
|
|
order: 3
|
|
|
|
},
|
|
|
|
{
|
|
|
|
template: 'userDownvotedPosts',
|
|
|
|
order: 5
|
|
|
|
},
|
|
|
|
{
|
|
|
|
template: 'userComments',
|
|
|
|
order: 5
|
|
|
|
}
|
2014-12-08 20:36:46 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
userProfileEdit = [
|
|
|
|
{
|
|
|
|
template: 'userAccount',
|
|
|
|
order: 1
|
|
|
|
}
|
2014-12-08 14:53:26 +09:00
|
|
|
]
|
|
|
|
|
2014-10-06 17:11:43 -06:00
|
|
|
userEditRenderedCallbacks = [];
|
|
|
|
userEditClientCallbacks = [];
|
|
|
|
|
|
|
|
userProfileCompleteChecks = [
|
|
|
|
function(user) {
|
2014-12-06 18:19:54 +09:00
|
|
|
return !!getEmail(user) && !!getUserName(user);
|
2014-10-06 17:11:43 -06:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2014-07-05 18:06:28 +09:00
|
|
|
// ------------------------------ Dynamic Templates ------------------------------ //
|
|
|
|
|
2014-07-05 11:24:28 +09:00
|
|
|
|
|
|
|
templates = {}
|
|
|
|
|
|
|
|
getTemplate = function (name) {
|
|
|
|
// if template has been overwritten, return this; else return template name
|
|
|
|
return !!templates[name] ? templates[name] : name;
|
|
|
|
}
|
|
|
|
|
2014-08-15 12:30:51 +09:00
|
|
|
// ------------------------------ Theme Settings ------------------------------ //
|
|
|
|
|
|
|
|
themeSettings = {
|
|
|
|
'useDropdowns': true // whether or not to use dropdown menus in a theme
|
2014-09-18 07:24:42 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
// ------------------------------ Subscriptions ------------------------------ //
|
|
|
|
|
|
|
|
// array containing subscriptions to be preloaded
|
|
|
|
preloadSubscriptions = [];
|