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

299 lines
6 KiB
JavaScript
Raw Normal View History

2014-09-18 07:24:42 +09:00
// ------------------------------------- Schemas -------------------------------- //
2014-07-06 14:09:55 +09:00
// array containing properties to be added to the post/settings/comments schema on startup.
addToPostSchema = [];
2014-07-06 14:09:55 +09:00
addToCommentsSchema = [];
addToSettingsSchema = [];
addToUserSchema = [];
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
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
// array containing items in the views menu
viewNav = [
{
route: 'posts_top',
2014-11-20 14:55:34 +09:00
label: 'top'
},
{
route: 'posts_new',
2014-11-20 14:55:34 +09:00
label: 'new'
},
{
route: 'posts_best',
2014-11-20 14:55:34 +09:00
label: 'best'
2014-12-08 11:15:20 +09:00
}
];
2014-09-18 07:24:42 +09:00
// ------------------------------------- Views -------------------------------- //
// object containing post list view parameters
viewParameters = {};
// will be common to all other view unless specific properties are overwritten
viewParameters.baseParameters = {
find: {
status: STATUS_APPROVED
},
options: {
limit: 10
}
};
viewParameters.top = function (terms) {
return {
options: {sort: {sticky: -1, score: -1}}
};
}
viewParameters.new = function (terms) {
return {
options: {sort: {sticky: -1, postedAt: -1}}
};
}
viewParameters.best = function (terms) {
return {
options: {sort: {sticky: -1, baseScore: -1}}
};
}
viewParameters.pending = function (terms) {
return {
2014-10-06 10:27:28 +09:00
find: {
status: 1
2014-10-06 10:27:28 +09:00
},
options: {sort: {createdAt: -1}},
showFuture: true
};
}
viewParameters.scheduled = function (terms) {
return {
find: {postedAt: {$gte: new Date()}},
options: {sort: {postedAt: -1}},
showFuture: true
};
}
viewParameters.userPosts = function (terms) {
return {
find: {userId: terms.userId},
options: {limit: 5, sort: {postedAt: -1}}
};
}
viewParameters.userUpvotedPosts = function (terms) {
var user = Meteor.users.findOne(terms.userId);
var postsIds = _.pluck(user.votes.upvotedPosts, "itemId");
return {
find: {_id: {$in: postsIds}, userId: {$ne: terms.userId}}, // exclude own posts
options: {limit: 5, sort: {postedAt: -1}}
};
}
viewParameters.userDownvotedPosts = function (terms) {
var user = Meteor.users.findOne(terms.userId);
var postsIds = _.pluck(user.votes.downvotedPosts, "itemId");
return {
find: {_id: {$in: postsIds}, userId: {$ne: terms.userId}}, // exclude own posts
options: {limit: 5, sort: {postedAt: -1}}
};
}
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
},
{
template: 'postActions',
position: 'left-right'
2014-07-04 12:44:36 +09:00
},
{
template: 'postContent',
position: 'center-center'
},
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
];
postHeading = [
{
template: 'postTitle',
order: 1
},
{
template: 'postDomain',
order: 5
}
];
postMeta = [
{
template: 'postAuthor',
order: 1
},
{
template: 'postInfo',
order: 2
},
{
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 = [];
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 = [];
postEditMethodCallbacks = []; // not used yet
2014-11-29 10:25:11 +09:00
postAfterEditMethodCallbacks = []; // not used yet
2014-07-05 18:06:28 +09:00
commentSubmitRenderedCallbacks = [];
commentSubmitClientCallbacks = [];
commentSubmitMethodCallbacks = [];
2014-09-20 10:42:42 +09:00
commentAfterSubmitMethodCallbacks = [];
2014-07-05 18:06:28 +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
}
]
userEditRenderedCallbacks = [];
userEditClientCallbacks = [];
userProfileCompleteChecks = [
function(user) {
2014-12-06 18:19:54 +09:00
return !!getEmail(user) && !!getUserName(user);
}
];
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;
}
// ------------------------------ 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 = [];