2013-10-09 20:59:42 +09:00
|
|
|
/*
|
|
|
|
|
2013-10-10 11:41:11 +09:00
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
//---------------------------------------- Table Of Contents ---------------------------------------//
|
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
---------------------------------------------------------------
|
|
|
|
# Config #
|
|
|
|
---------------------------------------------------------------
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2013-10-09 20:59:42 +09:00
|
|
|
---------------------------------------------------------------
|
2013-10-10 11:41:11 +09:00
|
|
|
# Filters #
|
2013-10-09 20:59:42 +09:00
|
|
|
---------------------------------------------------------------
|
|
|
|
|
2013-10-10 11:41:11 +09:00
|
|
|
isLoggedIn
|
|
|
|
isLoggedOut
|
|
|
|
isAdmin
|
|
|
|
|
|
|
|
canView
|
|
|
|
canPost
|
|
|
|
canEditPost
|
|
|
|
canEditComment
|
|
|
|
|
|
|
|
hasCompletedProfile
|
|
|
|
|
2013-10-12 11:59:34 +09:00
|
|
|
---------------------------------------------------------------
|
2013-10-25 11:54:19 +09:00
|
|
|
# Controllers #
|
2013-10-12 11:59:34 +09:00
|
|
|
---------------------------------------------------------------
|
2013-10-10 11:41:11 +09:00
|
|
|
|
2013-10-25 11:54:19 +09:00
|
|
|
PostsListController
|
|
|
|
PostPageController
|
|
|
|
|
2013-10-10 11:41:11 +09:00
|
|
|
---------------------------------------------------------------
|
|
|
|
# Routes #
|
|
|
|
---------------------------------------------------------------
|
2013-10-09 20:59:42 +09:00
|
|
|
|
|
|
|
1) Paginated Lists
|
|
|
|
----------------------
|
|
|
|
Top
|
|
|
|
New
|
|
|
|
Best
|
|
|
|
Pending
|
|
|
|
Categories
|
|
|
|
|
|
|
|
2) Digest
|
|
|
|
--------------------
|
|
|
|
Digest
|
|
|
|
|
|
|
|
3) Posts
|
|
|
|
--------------------
|
|
|
|
Post Page
|
|
|
|
Post Page (scroll to comment)
|
|
|
|
Post Edit
|
|
|
|
Post Submit
|
|
|
|
|
|
|
|
4) Comments
|
|
|
|
--------------------
|
|
|
|
Comment Page
|
|
|
|
Comment Edit
|
|
|
|
Comment Submit
|
|
|
|
|
|
|
|
5) Users
|
|
|
|
--------------------
|
|
|
|
User Profie
|
|
|
|
User Edit
|
|
|
|
Account
|
|
|
|
All Users
|
|
|
|
Unsubscribe (from notifications)
|
|
|
|
|
|
|
|
6) Misc Routes
|
|
|
|
--------------------
|
|
|
|
Settings
|
2013-10-09 22:21:28 +09:00
|
|
|
Categories
|
2013-10-09 20:59:42 +09:00
|
|
|
Toolbox
|
|
|
|
|
2014-01-18 16:52:12 +09:00
|
|
|
7) Server-side
|
|
|
|
--------------------
|
|
|
|
API
|
|
|
|
RSS
|
2013-10-09 21:34:55 +09:00
|
|
|
|
2013-10-09 20:59:42 +09:00
|
|
|
*/
|
|
|
|
|
2014-02-18 14:46:53 +09:00
|
|
|
// uncomment to disable FastRender
|
2014-07-04 14:22:21 +09:00
|
|
|
var FastRender = {RouteController: RouteController, onAllRoutes: function() {}};
|
2013-10-24 14:34:50 +09:00
|
|
|
|
2013-10-10 11:41:11 +09:00
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
//--------------------------------------------- Config ---------------------------------------------//
|
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
|
2014-05-09 11:05:33 +09:00
|
|
|
preloadSubscriptions.push('settings');
|
|
|
|
preloadSubscriptions.push('currentUser');
|
2013-10-24 14:34:50 +09:00
|
|
|
|
2013-10-06 08:37:17 +09:00
|
|
|
Router.configure({
|
2014-08-18 10:07:53 +09:00
|
|
|
layoutTemplate: getTemplate('layout'),
|
|
|
|
loadingTemplate: getTemplate('loading'),
|
|
|
|
notFoundTemplate: getTemplate('notFound'),
|
2014-02-18 14:46:53 +09:00
|
|
|
waitOn: function () {
|
|
|
|
return _.map(preloadSubscriptions, function(sub){
|
2014-05-21 16:01:15 +09:00
|
|
|
// can either pass strings or objects with subName and subArguments properties
|
|
|
|
if (typeof sub === 'object'){
|
|
|
|
Meteor.subscribe(sub.subName, sub.subArguments);
|
|
|
|
}else{
|
|
|
|
Meteor.subscribe(sub);
|
|
|
|
}
|
2014-02-18 14:46:53 +09:00
|
|
|
});
|
2014-01-12 23:36:03 +05:30
|
|
|
}
|
2013-10-06 08:37:17 +09:00
|
|
|
});
|
|
|
|
|
2013-10-10 11:41:11 +09:00
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
//--------------------------------------------- Filters --------------------------------------------//
|
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
|
2014-05-09 11:05:33 +09:00
|
|
|
Router._filters = {
|
2013-10-13 10:27:49 +09:00
|
|
|
|
2014-05-07 10:48:47 +09:00
|
|
|
isReady: function(pause) {
|
|
|
|
if (!this.ready()) {
|
|
|
|
// console.log('not ready')
|
2014-09-30 15:53:36 +09:00
|
|
|
this.render(getTemplate('loading'));
|
2014-05-07 10:48:47 +09:00
|
|
|
pause();
|
|
|
|
}else{
|
|
|
|
// console.log('ready')
|
|
|
|
}
|
|
|
|
},
|
2013-10-24 14:34:50 +09:00
|
|
|
|
2013-10-24 20:30:05 +09:00
|
|
|
resetScroll: function () {
|
|
|
|
var scrollTo = window.currentScroll || 0;
|
2014-09-16 15:13:42 -04:00
|
|
|
var $body = $('body');
|
|
|
|
$body.scrollTop(scrollTo);
|
|
|
|
$body.css("min-height", 0);
|
2013-10-24 20:30:05 +09:00
|
|
|
},
|
|
|
|
|
2014-09-18 11:00:12 +02:00
|
|
|
/*
|
2014-05-01 13:10:34 -07:00
|
|
|
isLoggedIn: function(pause) {
|
2013-10-24 14:34:50 +09:00
|
|
|
if (!(Meteor.loggingIn() || Meteor.user())) {
|
2014-05-06 20:15:48 -07:00
|
|
|
throwError(i18n.t('Please Sign In First.'));
|
2014-09-08 02:08:34 +08:00
|
|
|
var current = getCurrentRoute();
|
|
|
|
if (current){
|
|
|
|
Session.set('fromWhere', current);
|
|
|
|
}
|
|
|
|
this.render('entrySignIn');
|
2014-05-01 13:10:34 -07:00
|
|
|
pause();
|
2013-10-13 10:27:49 +09:00
|
|
|
}
|
|
|
|
},
|
2014-09-18 11:00:12 +02:00
|
|
|
*/
|
|
|
|
isLoggedIn: AccountsTemplates.ensureSignedIn,
|
2013-10-13 10:27:49 +09:00
|
|
|
|
2014-05-01 13:10:34 -07:00
|
|
|
isLoggedOut: function(pause) {
|
2013-10-13 10:27:49 +09:00
|
|
|
if(Meteor.user()){
|
|
|
|
this.render('already_logged_in');
|
2014-04-30 16:58:11 -07:00
|
|
|
pause();
|
2013-10-13 10:27:49 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-05-01 13:10:34 -07:00
|
|
|
isAdmin: function(pause) {
|
2014-01-06 21:01:21 +02:00
|
|
|
if(!this.ready()) return;
|
2014-01-07 22:50:56 +02:00
|
|
|
if(!isAdmin()){
|
2014-09-30 15:53:36 +09:00
|
|
|
this.render(getTemplate('no_rights'));
|
2014-07-08 09:27:26 +05:30
|
|
|
pause();
|
2013-10-13 10:27:49 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-05-01 13:10:34 -07:00
|
|
|
canView: function(pause) {
|
2014-05-23 13:32:52 +09:00
|
|
|
if(!this.ready() || Meteor.loggingIn()){
|
2014-09-30 15:53:36 +09:00
|
|
|
this.render(getTemplate('loading'));
|
2014-05-23 13:32:52 +09:00
|
|
|
pause();
|
|
|
|
}else if (!canView()) {
|
2014-09-30 15:53:36 +09:00
|
|
|
this.render(getTemplate('no_rights'));
|
2014-04-30 16:58:11 -07:00
|
|
|
pause();
|
2013-10-13 10:27:49 +09:00
|
|
|
}
|
|
|
|
},
|
2013-10-12 11:44:29 +09:00
|
|
|
|
2014-05-01 13:10:34 -07:00
|
|
|
canPost: function (pause) {
|
2014-05-23 13:32:52 +09:00
|
|
|
if(!this.ready() || Meteor.loggingIn()){
|
2014-09-30 15:53:36 +09:00
|
|
|
this.render(getTemplate('loading'));
|
2014-05-23 13:32:52 +09:00
|
|
|
pause();
|
|
|
|
}else if(!canPost()){
|
2014-05-06 20:15:48 -07:00
|
|
|
throwError(i18n.t("Sorry, you don't have permissions to add new items."));
|
2014-09-30 15:53:36 +09:00
|
|
|
this.render(getTemplate('no_rights'));
|
2014-07-08 09:27:26 +05:30
|
|
|
pause();
|
2013-10-24 14:34:50 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-05-01 13:10:34 -07:00
|
|
|
canEditPost: function(pause) {
|
2014-01-07 22:50:56 +02:00
|
|
|
if(!this.ready()) return;
|
|
|
|
// Already subscribed to this post by route({waitOn: ...})
|
2013-10-12 11:44:29 +09:00
|
|
|
var post = Posts.findOne(this.params._id);
|
2014-01-07 22:50:56 +02:00
|
|
|
if(!currentUserCanEdit(post)){
|
2014-05-06 20:15:48 -07:00
|
|
|
throwError(i18n.t("Sorry, you cannot edit this post."));
|
2014-09-30 15:53:36 +09:00
|
|
|
this.render(getTemplate('no_rights'));
|
2014-04-30 16:58:11 -07:00
|
|
|
pause();
|
2013-10-10 11:41:11 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-05-01 13:10:34 -07:00
|
|
|
canEditComment: function(pause) {
|
2014-01-07 22:50:56 +02:00
|
|
|
if(!this.ready()) return;
|
2014-08-17 08:17:35 +09:00
|
|
|
// Already subscribed to this comment by CommentPageController
|
2013-10-12 11:44:29 +09:00
|
|
|
var comment = Comments.findOne(this.params._id);
|
2014-01-07 22:50:56 +02:00
|
|
|
if(!currentUserCanEdit(comment)){
|
2014-05-06 20:15:48 -07:00
|
|
|
throwError(i18n.t("Sorry, you cannot edit this comment."));
|
2014-09-30 15:53:36 +09:00
|
|
|
this.render(getTemplate('no_rights'));
|
2014-04-30 16:58:11 -07:00
|
|
|
pause();
|
2013-10-10 11:41:11 +09:00
|
|
|
}
|
2013-10-13 10:27:49 +09:00
|
|
|
},
|
|
|
|
|
2014-05-01 13:10:34 -07:00
|
|
|
hasCompletedProfile: function(pause) {
|
2014-01-07 22:50:56 +02:00
|
|
|
if(!this.ready()) return;
|
2013-10-13 10:27:49 +09:00
|
|
|
var user = Meteor.user();
|
2014-01-07 22:50:56 +02:00
|
|
|
if (user && ! userProfileComplete(user)){
|
2014-09-30 15:53:36 +09:00
|
|
|
this.render(getTemplate('user_email'));
|
2014-04-30 16:58:11 -07:00
|
|
|
pause();
|
2013-10-13 10:27:49 +09:00
|
|
|
}
|
2014-07-08 09:27:26 +05:30
|
|
|
},
|
2014-05-30 10:32:30 +09:00
|
|
|
|
|
|
|
setTitle: function() {
|
|
|
|
// set title
|
|
|
|
var title = getSetting("title");
|
|
|
|
var tagline = getSetting("tagline");
|
|
|
|
document.title = (tagline ? title+': '+tagline : title) || "";
|
2013-10-12 11:44:29 +09:00
|
|
|
}
|
2013-10-10 11:41:11 +09:00
|
|
|
|
2014-05-06 20:15:48 -07:00
|
|
|
};
|
2013-10-10 11:41:11 +09:00
|
|
|
|
2014-07-08 09:27:26 +05:30
|
|
|
var filters = Router._filters;
|
|
|
|
var coreSubscriptions = new SubsManager({
|
|
|
|
// cache recent 50 subscriptions
|
|
|
|
cacheLimit: 50,
|
|
|
|
// expire any subscription after 30 minutes
|
|
|
|
expireIn: 30
|
|
|
|
});
|
2014-05-09 11:05:33 +09:00
|
|
|
|
2014-01-18 16:52:12 +09:00
|
|
|
if(Meteor.isClient){
|
2013-10-24 14:36:20 +09:00
|
|
|
|
2014-01-18 16:52:12 +09:00
|
|
|
// Load Hooks
|
2013-11-16 14:01:00 +09:00
|
|
|
|
2014-04-30 16:58:11 -07:00
|
|
|
Router.onRun( function () {
|
2014-01-18 16:52:12 +09:00
|
|
|
Session.set('categorySlug', null);
|
2013-11-16 14:01:00 +09:00
|
|
|
|
2014-01-18 16:52:12 +09:00
|
|
|
// if we're not on the search page itself, clear search query and field
|
|
|
|
if(getCurrentRoute().indexOf('search') == -1){
|
|
|
|
Session.set('searchQuery', '');
|
|
|
|
$('.search-field').val('').blur();
|
|
|
|
}
|
2013-10-24 14:34:50 +09:00
|
|
|
|
2014-01-18 16:52:12 +09:00
|
|
|
});
|
2013-10-15 12:35:05 +09:00
|
|
|
|
2014-01-18 16:52:12 +09:00
|
|
|
// Before Hooks
|
|
|
|
|
2014-05-07 11:03:53 +09:00
|
|
|
// Router.onBeforeAction(filters.isReady);
|
2014-06-22 14:12:10 +09:00
|
|
|
Router.onBeforeAction(clearSeenErrors);
|
2014-09-18 18:17:31 +02:00
|
|
|
Router.onBeforeAction(filters.canView, {except: ['atSignIn', 'atSignUp', 'atForgotPwd', 'atResetPwd', 'signOut']});
|
2014-04-30 16:58:11 -07:00
|
|
|
Router.onBeforeAction(filters.hasCompletedProfile);
|
2014-08-17 08:17:35 +09:00
|
|
|
Router.onBeforeAction(filters.isLoggedIn, {only: ['post_submit']});
|
2014-09-08 01:39:29 +08:00
|
|
|
Router.onBeforeAction(filters.isLoggedOut, {only: []});
|
2014-08-17 08:17:35 +09:00
|
|
|
Router.onBeforeAction(filters.canPost, {only: ['posts_pending', 'post_submit']});
|
2014-04-30 16:58:11 -07:00
|
|
|
Router.onBeforeAction(filters.canEditPost, {only: ['post_edit']});
|
|
|
|
Router.onBeforeAction(filters.canEditComment, {only: ['comment_edit']});
|
2014-05-09 11:05:33 +09:00
|
|
|
Router.onBeforeAction(filters.isAdmin, {only: ['posts_pending', 'all-users', 'settings', 'toolbox', 'logs']});
|
2014-01-18 16:52:12 +09:00
|
|
|
|
|
|
|
// After Hooks
|
|
|
|
|
2014-08-28 11:10:31 +09:00
|
|
|
// Router.onAfterAction(filters.resetScroll, {except:['posts_top', 'posts_new', 'posts_best', 'posts_pending', 'posts_category', 'all-users']});
|
2014-05-30 10:32:30 +09:00
|
|
|
Router.onAfterAction(analyticsInit); // will only run once thanks to _.once()
|
|
|
|
Router.onAfterAction(analyticsRequest); // log this request with mixpanel, etc
|
|
|
|
Router.onAfterAction(filters.setTitle);
|
2013-10-24 14:36:20 +09:00
|
|
|
|
2014-01-18 16:52:12 +09:00
|
|
|
// Unload Hooks
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
}
|
2013-10-15 12:35:05 +09:00
|
|
|
|
2013-10-25 11:54:19 +09:00
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
//------------------------------------------- Controllers ------------------------------------------//
|
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
|
2013-10-26 10:37:32 +09:00
|
|
|
// Controller for all posts lists
|
2013-10-25 11:54:19 +09:00
|
|
|
|
2014-01-12 22:58:07 +05:30
|
|
|
PostsListController = FastRender.RouteController.extend({
|
2014-07-05 11:28:05 +09:00
|
|
|
template: getTemplate('posts_list'),
|
2014-07-04 14:22:21 +09:00
|
|
|
onBeforeAction: function () {
|
2013-10-25 11:59:00 +09:00
|
|
|
// take the first segment of the path to get the view, unless it's '/' in which case the view default to 'top'
|
2013-10-25 12:28:21 +09:00
|
|
|
// note: most of the time this.params.slug will be empty
|
2013-11-17 11:42:17 +09:00
|
|
|
this._terms = {
|
2014-08-28 10:16:17 +09:00
|
|
|
view: this.view,
|
2013-11-17 08:01:56 +09:00
|
|
|
limit: this.params.limit || getSetting('postsPerPage', 10),
|
2014-01-12 22:58:07 +05:30
|
|
|
category: this.params.slug
|
|
|
|
};
|
|
|
|
|
|
|
|
if(Meteor.isClient) {
|
|
|
|
this._terms.query = Session.get("searchQuery");
|
2013-11-17 08:01:56 +09:00
|
|
|
}
|
2014-01-12 22:58:07 +05:30
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.postsListSub = coreSubscriptions.subscribe('postsList', this._terms);
|
2013-10-25 11:54:19 +09:00
|
|
|
return [
|
2014-08-28 10:16:17 +09:00
|
|
|
this.postsListSub,
|
2014-07-08 09:27:26 +05:30
|
|
|
coreSubscriptions.subscribe('postsListUsers', this._terms)
|
2014-05-06 20:15:48 -07:00
|
|
|
];
|
2013-10-25 11:54:19 +09:00
|
|
|
},
|
|
|
|
data: function () {
|
2014-07-04 14:22:21 +09:00
|
|
|
this._terms = {
|
2014-08-28 10:16:17 +09:00
|
|
|
view: this.view,
|
2014-07-04 14:22:21 +09:00
|
|
|
limit: this.params.limit || getSetting('postsPerPage', 10),
|
|
|
|
category: this.params.slug
|
|
|
|
};
|
|
|
|
|
|
|
|
if(Meteor.isClient) {
|
|
|
|
this._terms.query = Session.get("searchQuery");
|
|
|
|
}
|
|
|
|
|
2014-09-29 15:42:35 +08:00
|
|
|
var parameters = getPostsParameters(this._terms),
|
2014-09-15 12:42:17 +10:00
|
|
|
postsCount = Posts.find(parameters.find, parameters.options).count();
|
|
|
|
|
|
|
|
parameters.find.createdAt = { $lte: Session.get('listPopulatedAt') };
|
|
|
|
var posts = Posts.find(parameters.find, parameters.options);
|
|
|
|
|
|
|
|
// Incoming posts
|
|
|
|
parameters.find.createdAt = { $gt: Session.get('listPopulatedAt') };
|
|
|
|
var postsIncoming = Posts.find(parameters.find, parameters.options);
|
2014-07-08 09:27:26 +05:30
|
|
|
|
2013-11-17 11:42:17 +09:00
|
|
|
Session.set('postsLimit', this._terms.limit);
|
2013-10-28 13:35:20 +09:00
|
|
|
|
2013-10-25 11:54:19 +09:00
|
|
|
return {
|
2014-09-16 15:29:11 +10:00
|
|
|
incoming: postsIncoming,
|
2013-10-29 17:05:20 +09:00
|
|
|
postsList: posts,
|
2014-08-28 10:16:17 +09:00
|
|
|
postsCount: postsCount,
|
|
|
|
ready: this.postsListSub.ready
|
2014-05-06 20:15:48 -07:00
|
|
|
};
|
2013-10-25 11:54:19 +09:00
|
|
|
},
|
2014-04-30 16:58:11 -07:00
|
|
|
onAfterAction: function() {
|
2014-08-28 10:16:17 +09:00
|
|
|
Session.set('view', this.view);
|
2014-07-08 09:27:26 +05:30
|
|
|
}
|
2013-10-25 11:54:19 +09:00
|
|
|
});
|
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
PostsTopController = PostsListController.extend({
|
|
|
|
view: 'top'
|
|
|
|
});
|
|
|
|
|
|
|
|
PostsNewController = PostsListController.extend({
|
|
|
|
view: 'new'
|
|
|
|
});
|
|
|
|
|
|
|
|
PostsBestController = PostsListController.extend({
|
|
|
|
view: 'best'
|
|
|
|
});
|
|
|
|
|
|
|
|
PostsPendingController = PostsListController.extend({
|
|
|
|
view: 'pending'
|
|
|
|
});
|
|
|
|
|
2013-10-26 10:37:32 +09:00
|
|
|
// Controller for post digest
|
|
|
|
|
2014-01-12 22:58:07 +05:30
|
|
|
PostsDigestController = FastRender.RouteController.extend({
|
2014-07-05 11:28:05 +09:00
|
|
|
template: getTemplate('posts_digest'),
|
2013-10-26 10:37:32 +09:00
|
|
|
waitOn: function() {
|
|
|
|
// if day is set, use that. If not default to today
|
2014-01-12 22:58:07 +05:30
|
|
|
var currentDate = this.params.day ? new Date(this.params.year, this.params.month-1, this.params.day) : new Date(),
|
2013-11-17 08:01:56 +09:00
|
|
|
terms = {
|
|
|
|
view: 'digest',
|
2014-06-22 15:54:54 +09:00
|
|
|
after: moment(currentDate).startOf('day').toDate(),
|
|
|
|
before: moment(currentDate).endOf('day').toDate()
|
2014-05-06 20:15:48 -07:00
|
|
|
};
|
2013-10-26 10:37:32 +09:00
|
|
|
return [
|
2014-07-08 09:27:26 +05:30
|
|
|
coreSubscriptions.subscribe('postsList', terms),
|
|
|
|
coreSubscriptions.subscribe('postsListUsers', terms)
|
2014-05-06 20:15:48 -07:00
|
|
|
];
|
2013-10-26 10:37:32 +09:00
|
|
|
},
|
|
|
|
data: function() {
|
2013-11-17 08:01:56 +09:00
|
|
|
var currentDate = this.params.day ? new Date(this.params.year, this.params.month-1, this.params.day) : Session.get('today'),
|
|
|
|
terms = {
|
|
|
|
view: 'digest',
|
2014-06-22 15:54:54 +09:00
|
|
|
after: moment(currentDate).startOf('day').toDate(),
|
|
|
|
before: moment(currentDate).endOf('day').toDate()
|
2013-11-17 08:01:56 +09:00
|
|
|
},
|
2014-09-29 15:42:35 +08:00
|
|
|
parameters = getPostsParameters(terms);
|
2013-10-26 10:37:32 +09:00
|
|
|
Session.set('currentDate', currentDate);
|
2014-09-15 12:42:17 +10:00
|
|
|
|
|
|
|
parameters.find.createdAt = { $lte: Session.get('listPopulatedAt') };
|
|
|
|
var posts = Posts.find(parameters.find, parameters.options);
|
|
|
|
|
|
|
|
// Incoming posts
|
|
|
|
parameters.find.createdAt = { $gt: Session.get('listPopulatedAt') };
|
|
|
|
var postsIncoming = Posts.find(parameters.find, parameters.options);
|
|
|
|
|
2013-10-26 10:37:32 +09:00
|
|
|
return {
|
2014-09-16 15:29:11 +10:00
|
|
|
incoming: postsIncoming,
|
2014-09-15 12:42:17 +10:00
|
|
|
posts: posts
|
2014-05-06 20:15:48 -07:00
|
|
|
};
|
2013-10-26 10:37:32 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Controller for post pages
|
2013-10-25 11:54:19 +09:00
|
|
|
|
2014-07-08 09:34:38 +09:00
|
|
|
PostPageController = FastRender.RouteController.extend({
|
2014-07-08 10:21:18 +05:30
|
|
|
waitOn: function() {
|
2014-07-08 11:24:59 +05:30
|
|
|
this.postSubscription = coreSubscriptions.subscribe('singlePost', this.params._id);
|
|
|
|
this.postUsersSubscription = coreSubscriptions.subscribe('postUsers', this.params._id);
|
2014-08-18 10:07:53 +09:00
|
|
|
this.commentSubscription = coreSubscriptions.subscribe('postComments', this.params._id);
|
2014-07-08 09:34:38 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
post: function() {
|
|
|
|
return Posts.findOne(this.params._id);
|
|
|
|
},
|
2014-07-08 09:27:26 +05:30
|
|
|
|
2014-07-08 09:34:38 +09:00
|
|
|
onBeforeAction: function(pause) {
|
2014-07-08 11:24:59 +05:30
|
|
|
if (! this.post()) {
|
|
|
|
if (this.postSubscription.ready()) {
|
2014-09-30 15:53:36 +09:00
|
|
|
this.render(getTemplate('not_found'));
|
2014-07-08 09:34:38 +09:00
|
|
|
return pause();
|
|
|
|
}
|
2014-07-08 11:24:59 +05:30
|
|
|
|
2014-09-30 15:53:36 +09:00
|
|
|
this.render(getTemplate('loading'));
|
2014-07-08 11:24:59 +05:30
|
|
|
pause();
|
2014-07-08 09:34:38 +09:00
|
|
|
}
|
|
|
|
},
|
2014-07-08 09:27:26 +05:30
|
|
|
|
2014-07-08 09:34:38 +09:00
|
|
|
data: function() {
|
|
|
|
return this.post();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2013-10-26 10:37:32 +09:00
|
|
|
// Controller for comment pages
|
2013-10-25 11:54:19 +09:00
|
|
|
|
2014-01-12 22:58:07 +05:30
|
|
|
CommentPageController = FastRender.RouteController.extend({
|
2013-10-26 10:37:32 +09:00
|
|
|
waitOn: function() {
|
|
|
|
return [
|
2014-07-08 09:27:26 +05:30
|
|
|
coreSubscriptions.subscribe('singleComment', this.params._id),
|
|
|
|
coreSubscriptions.subscribe('commentUser', this.params._id),
|
|
|
|
coreSubscriptions.subscribe('commentPost', this.params._id)
|
2014-05-06 20:15:48 -07:00
|
|
|
];
|
2013-10-26 10:37:32 +09:00
|
|
|
},
|
|
|
|
data: function() {
|
|
|
|
return {
|
|
|
|
comment: Comments.findOne(this.params._id)
|
2014-05-06 20:15:48 -07:00
|
|
|
};
|
2013-10-26 17:35:45 +09:00
|
|
|
},
|
2014-04-30 16:58:11 -07:00
|
|
|
onAfterAction: function () {
|
2013-10-26 17:35:45 +09:00
|
|
|
window.queueComments = false;
|
2014-07-08 09:27:26 +05:30
|
|
|
}
|
2013-10-26 10:37:32 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// Controller for user pages
|
|
|
|
|
2014-01-12 22:58:07 +05:30
|
|
|
UserPageController = FastRender.RouteController.extend({
|
2013-10-26 10:37:32 +09:00
|
|
|
waitOn: function() {
|
2014-08-11 10:14:53 +09:00
|
|
|
return [
|
2014-09-03 09:46:39 +09:00
|
|
|
coreSubscriptions.subscribe('userProfile', this.params._idOrSlug)
|
2014-08-11 10:14:53 +09:00
|
|
|
]
|
2013-10-26 10:37:32 +09:00
|
|
|
},
|
|
|
|
data: function() {
|
|
|
|
var findById = Meteor.users.findOne(this.params._idOrSlug);
|
|
|
|
var findBySlug = Meteor.users.findOne({slug: this.params._idOrSlug});
|
2013-11-18 11:30:58 +09:00
|
|
|
if(typeof findById !== "undefined"){
|
|
|
|
// redirect to slug-based URL
|
|
|
|
Router.go(getProfileUrl(findById), {replaceState: true});
|
|
|
|
}else{
|
|
|
|
return {
|
|
|
|
user: (typeof findById == "undefined") ? findBySlug : findById
|
2014-05-06 20:15:48 -07:00
|
|
|
};
|
2013-10-26 10:37:32 +09:00
|
|
|
}
|
|
|
|
}
|
2013-11-05 09:32:21 +09:00
|
|
|
});
|
|
|
|
|
2014-07-31 01:21:14 +02:00
|
|
|
// Controller for user account editing
|
|
|
|
|
|
|
|
AccountController = FastRender.RouteController.extend({
|
|
|
|
waitOn: function() {
|
|
|
|
return coreSubscriptions.subscribe('invites');
|
|
|
|
},
|
|
|
|
data: function() {
|
|
|
|
return {
|
|
|
|
user : Meteor.user(),
|
|
|
|
invites: Invites.find({invitingUserId:Meteor.userId()})
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
var getDefaultViewController = function () {
|
|
|
|
var defaultView = getSetting('defaultView', 'top');
|
|
|
|
defaultView = defaultView.charAt(0).toUpperCase() + defaultView.slice(1);
|
|
|
|
return eval("Posts"+defaultView+"Controller");
|
2014-09-16 15:13:42 -04:00
|
|
|
};
|
2014-08-28 10:16:17 +09:00
|
|
|
|
2013-10-09 21:49:02 +09:00
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
//--------------------------------------------- Routes ---------------------------------------------//
|
|
|
|
//--------------------------------------------------------------------------------------------------//
|
2014-08-28 10:16:17 +09:00
|
|
|
Meteor.startup(function () {
|
2013-10-09 21:34:55 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
Router.map(function() {
|
2014-07-05 11:57:41 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// -------------------------------------------- Post Lists -------------------------------------------- //
|
2014-07-05 11:57:41 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('posts_default', {
|
|
|
|
path: '/',
|
|
|
|
controller: getDefaultViewController()
|
|
|
|
});
|
2013-10-09 22:21:28 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('posts_top', {
|
|
|
|
path: '/top/:limit?',
|
|
|
|
controller: PostsTopController
|
|
|
|
});
|
2013-10-09 20:59:42 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// New
|
2013-10-09 22:21:28 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('posts_new', {
|
|
|
|
path: '/new/:limit?',
|
|
|
|
controller: PostsNewController
|
|
|
|
});
|
2013-10-09 20:59:42 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Best
|
2013-10-09 22:21:28 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('posts_best', {
|
|
|
|
path: '/best/:limit?',
|
|
|
|
controller: PostsBestController
|
|
|
|
});
|
2013-10-09 20:59:42 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Pending
|
2013-10-09 22:21:28 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('posts_pending', {
|
|
|
|
path: '/pending/:limit?',
|
|
|
|
controller: PostsPendingController
|
|
|
|
});
|
2013-10-09 20:59:42 +09:00
|
|
|
|
2013-10-12 13:01:16 +09:00
|
|
|
|
2013-10-15 12:35:05 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// TODO: enable /category/new, /category/best, etc. views
|
2013-10-15 12:35:05 +09:00
|
|
|
|
2013-10-09 11:21:23 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Digest
|
2014-07-08 09:27:26 +05:30
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('posts_digest', {
|
|
|
|
path: '/digest/:year/:month/:day',
|
|
|
|
controller: PostsDigestController
|
|
|
|
});
|
2013-10-09 21:49:02 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('posts_digest', {
|
|
|
|
path: '/digest',
|
|
|
|
controller: PostsDigestController
|
|
|
|
});
|
2013-10-12 11:44:29 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// -------------------------------------------- Post -------------------------------------------- //
|
2013-10-24 14:34:50 +09:00
|
|
|
|
2013-10-09 11:32:36 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Post Page
|
2013-10-09 20:11:58 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('post_page', {
|
|
|
|
template: getTemplate('post_page'),
|
|
|
|
path: '/posts/:_id',
|
|
|
|
controller: PostPageController
|
|
|
|
});
|
2013-10-09 12:39:05 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('post_page', {
|
|
|
|
template: getTemplate('post_page'),
|
|
|
|
path: '/posts/:_id/comment/:commentId',
|
|
|
|
controller: PostPageController,
|
|
|
|
onAfterAction: function () {
|
|
|
|
// TODO: scroll to comment position
|
|
|
|
}
|
|
|
|
});
|
2013-10-09 11:32:36 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Post Edit
|
|
|
|
|
|
|
|
this.route('post_edit', {
|
|
|
|
template: getTemplate('post_edit'),
|
|
|
|
path: '/posts/:_id/edit',
|
|
|
|
waitOn: function () {
|
2014-09-24 14:19:34 +09:00
|
|
|
return [
|
|
|
|
coreSubscriptions.subscribe('singlePost', this.params._id),
|
|
|
|
coreSubscriptions.subscribe('allUsersAdmin')
|
|
|
|
];
|
2014-08-28 10:16:17 +09:00
|
|
|
},
|
|
|
|
data: function() {
|
|
|
|
return {
|
|
|
|
postId: this.params._id,
|
|
|
|
post: Posts.findOne(this.params._id)
|
|
|
|
};
|
|
|
|
},
|
|
|
|
fastRender: true
|
|
|
|
});
|
2013-10-09 11:32:36 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Post Submit
|
2013-10-09 12:39:05 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('post_submit', {
|
|
|
|
template: getTemplate('post_submit'),
|
|
|
|
path: '/submit'
|
|
|
|
});
|
2013-10-09 12:39:05 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// -------------------------------------------- Comment -------------------------------------------- //
|
2013-10-09 12:39:05 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Comment Reply
|
2013-10-09 12:39:05 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('comment_reply', {
|
|
|
|
template: getTemplate('comment_reply'),
|
|
|
|
path: '/comments/:_id',
|
|
|
|
controller: CommentPageController,
|
|
|
|
onAfterAction: function() {
|
|
|
|
window.queueComments = false;
|
|
|
|
}
|
|
|
|
});
|
2013-10-09 11:32:36 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Comment Edit
|
2013-10-09 11:32:36 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('comment_edit', {
|
|
|
|
template: getTemplate('comment_edit'),
|
|
|
|
path: '/comments/:_id/edit',
|
|
|
|
controller: CommentPageController,
|
|
|
|
onAfterAction: function() {
|
|
|
|
window.queueComments = false;
|
|
|
|
}
|
|
|
|
});
|
2013-10-09 12:39:05 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// -------------------------------------------- Users -------------------------------------------- //
|
2013-10-14 11:37:37 +09:00
|
|
|
|
2014-09-18 18:17:31 +02:00
|
|
|
// User Logout
|
|
|
|
|
|
|
|
this.route('signOut', {
|
|
|
|
path: '/sign-out',
|
|
|
|
onBeforeAction: function(pause) {
|
|
|
|
Meteor.logout(function() {
|
|
|
|
return Router.go('/');
|
|
|
|
});
|
|
|
|
return pause();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// User Profile
|
2013-10-09 20:50:26 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('user_profile', {
|
|
|
|
template: getTemplate('user_profile'),
|
|
|
|
path: '/users/:_idOrSlug',
|
|
|
|
controller: UserPageController
|
|
|
|
});
|
2013-10-09 20:50:26 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// User Edit
|
2013-10-09 20:50:26 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('user_edit', {
|
|
|
|
template: getTemplate('user_edit'),
|
|
|
|
path: '/users/:_idOrSlug/edit',
|
|
|
|
controller: UserPageController
|
|
|
|
});
|
2013-10-09 20:50:26 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Account
|
2013-10-09 20:50:26 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('account', {
|
|
|
|
template: getTemplate('user_edit'),
|
|
|
|
path: '/account',
|
|
|
|
controller: AccountController
|
|
|
|
});
|
2013-10-09 20:50:26 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// All Users
|
|
|
|
|
|
|
|
this.route('all-users', {
|
|
|
|
template: getTemplate('users'),
|
|
|
|
path: '/all-users/:limit?',
|
|
|
|
waitOn: function() {
|
|
|
|
var limit = parseInt(this.params.limit) || 20;
|
|
|
|
return coreSubscriptions.subscribe('allUsers', this.params.filterBy, this.params.sortBy, limit);
|
|
|
|
},
|
|
|
|
data: function() {
|
|
|
|
var limit = parseInt(this.params.limit) || 20,
|
|
|
|
parameters = getUsersParameters(this.params.filterBy, this.params.sortBy, limit),
|
|
|
|
filterBy = (typeof this.params.filterBy === 'string') ? this.params.filterBy : 'all',
|
|
|
|
sortBy = (typeof this.params.sortBy === 'string') ? this.params.sortBy : 'createdAt';
|
|
|
|
Session.set('usersLimit', limit);
|
|
|
|
return {
|
|
|
|
users: Meteor.users.find(parameters.find, parameters.options),
|
|
|
|
filterBy: filterBy,
|
|
|
|
sortBy: sortBy
|
|
|
|
};
|
|
|
|
},
|
|
|
|
fastRender: true
|
|
|
|
});
|
2013-10-09 20:50:26 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Unsubscribe (from notifications)
|
2013-10-09 20:26:58 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('unsubscribe', {
|
|
|
|
template: getTemplate('unsubscribe'),
|
|
|
|
path: '/unsubscribe/:hash',
|
|
|
|
data: function() {
|
|
|
|
return {
|
|
|
|
hash: this.params.hash
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
2013-10-09 20:50:26 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// -------------------------------------------- Other -------------------------------------------- //
|
2013-10-14 11:37:37 +09:00
|
|
|
|
2014-07-08 09:27:26 +05:30
|
|
|
|
2013-10-09 22:21:28 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Settings
|
2013-10-09 20:53:55 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('settings', {
|
|
|
|
template: getTemplate('settings'),
|
|
|
|
data: function () {
|
|
|
|
// we only have one set of settings for now
|
|
|
|
return {
|
|
|
|
hasSettings: !!Settings.find().count(),
|
|
|
|
settings: Settings.findOne()
|
|
|
|
}
|
2014-05-09 09:39:49 +09:00
|
|
|
}
|
2014-08-28 10:16:17 +09:00
|
|
|
});
|
2014-02-06 15:45:43 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Loading (for testing purposes)
|
2013-10-09 20:53:55 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('loading', {
|
2014-09-16 15:13:42 -04:00
|
|
|
template: getTemplate('loading')
|
2014-08-28 10:16:17 +09:00
|
|
|
});
|
2013-10-09 20:53:55 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Toolbox
|
2014-01-18 16:52:12 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('toolbox',{
|
2014-09-16 15:13:42 -04:00
|
|
|
template: getTemplate('toolbox')
|
2014-08-28 10:16:17 +09:00
|
|
|
});
|
2014-01-18 16:52:12 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// -------------------------------------------- Server-Side -------------------------------------------- //
|
|
|
|
|
|
|
|
// Link Out
|
|
|
|
|
|
|
|
this.route('out', {
|
|
|
|
where: 'server',
|
|
|
|
path: '/out',
|
|
|
|
action: function(){
|
|
|
|
var query = this.request.query;
|
|
|
|
if(query.url){
|
|
|
|
var decodedUrl = decodeURIComponent(query.url);
|
|
|
|
var post = Posts.findOne({url: decodedUrl});
|
|
|
|
if(post){
|
|
|
|
Posts.update(post._id, {$inc: {clicks: 1}});
|
|
|
|
}
|
|
|
|
this.response.writeHead(302, {'Location': query.url});
|
|
|
|
this.response.end();
|
2014-01-18 16:52:12 +09:00
|
|
|
}
|
|
|
|
}
|
2014-08-28 10:16:17 +09:00
|
|
|
});
|
2014-01-18 16:52:12 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Notification email
|
2014-08-03 11:50:10 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('notification', {
|
|
|
|
where: 'server',
|
|
|
|
path: '/email/notification/:id?',
|
|
|
|
action: function() {
|
|
|
|
var notification = Notifications.findOne(this.params.id);
|
|
|
|
var notificationContents = buildEmailNotification(notification);
|
|
|
|
this.response.write(notificationContents.html);
|
|
|
|
this.response.end();
|
|
|
|
}
|
|
|
|
});
|
2014-08-03 11:50:10 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// New user email
|
2014-08-03 16:27:54 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('newUser', {
|
|
|
|
where: 'server',
|
|
|
|
path: '/email/new-user/:id?',
|
|
|
|
action: function() {
|
|
|
|
var user = Meteor.users.findOne(this.params.id);
|
|
|
|
var emailProperties = {
|
|
|
|
profileUrl: getProfileUrl(user),
|
|
|
|
username: getUserName(user)
|
2014-09-16 15:13:42 -04:00
|
|
|
};
|
|
|
|
console.log(Handlebars);
|
2014-08-29 10:23:11 +09:00
|
|
|
|
2014-09-16 15:13:42 -04:00
|
|
|
console.log(Handlebars.templates);
|
2014-08-29 10:23:11 +09:00
|
|
|
|
|
|
|
html = getEmailTemplate('emailNewUser')(emailProperties);
|
2014-08-28 10:16:17 +09:00
|
|
|
this.response.write(buildEmailTemplate(html));
|
|
|
|
this.response.end();
|
2014-08-03 11:50:10 +09:00
|
|
|
}
|
2014-08-28 10:16:17 +09:00
|
|
|
});
|
2014-08-03 11:50:10 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// New post email
|
2014-08-03 16:27:54 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
this.route('newPost', {
|
|
|
|
where: 'server',
|
|
|
|
path: '/email/new-post/:id?',
|
|
|
|
action: function() {
|
|
|
|
var post = Posts.findOne(this.params.id);
|
|
|
|
html = Handlebars.templates[getTemplate('emailNewPost')](getPostProperties(post));
|
|
|
|
this.response.write(buildEmailTemplate(html));
|
|
|
|
this.response.end();
|
|
|
|
}
|
|
|
|
});
|
2014-08-03 16:27:54 +09:00
|
|
|
|
2014-08-28 10:16:17 +09:00
|
|
|
// Account approved email
|
|
|
|
|
|
|
|
this.route('accountApproved', {
|
|
|
|
where: 'server',
|
|
|
|
path: '/email/account-approved/:id?',
|
|
|
|
action: function() {
|
|
|
|
var user = Meteor.users.findOne(this.params.id);
|
|
|
|
var emailProperties = {
|
|
|
|
profileUrl: getProfileUrl(user),
|
|
|
|
username: getUserName(user),
|
|
|
|
siteTitle: getSetting('title'),
|
|
|
|
siteUrl: getSiteUrl()
|
2014-09-16 15:13:42 -04:00
|
|
|
};
|
2014-08-28 10:16:17 +09:00
|
|
|
html = Handlebars.templates[getTemplate('emailAccountApproved')](emailProperties);
|
|
|
|
this.response.write(buildEmailTemplate(html));
|
|
|
|
this.response.end();
|
2014-08-03 16:27:54 +09:00
|
|
|
}
|
2014-08-28 10:16:17 +09:00
|
|
|
});
|
2014-08-03 16:27:54 +09:00
|
|
|
});
|
2014-08-28 10:16:17 +09:00
|
|
|
|
2013-10-06 08:37:17 +09:00
|
|
|
});
|
2014-01-12 22:58:07 +05:30
|
|
|
|
|
|
|
// adding common subscriptions that's need to be loaded on all the routes
|
2014-07-08 09:27:26 +05:30
|
|
|
// notification does not included here since it is not much critical and
|
2014-01-12 22:58:07 +05:30
|
|
|
// it might have considerable amount of docs
|
|
|
|
if(Meteor.isServer) {
|
|
|
|
FastRender.onAllRoutes(function() {
|
2014-02-18 14:46:53 +09:00
|
|
|
var router = this;
|
|
|
|
_.each(preloadSubscriptions, function(sub){
|
|
|
|
router.subscribe(sub);
|
|
|
|
});
|
2014-01-12 22:58:07 +05:30
|
|
|
});
|
2014-01-18 16:52:12 +09:00
|
|
|
}
|