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
|
|
|
|
Forgot Password
|
|
|
|
Account
|
|
|
|
All Users
|
|
|
|
Unsubscribe (from notifications)
|
|
|
|
Sign Up
|
|
|
|
Sign In
|
|
|
|
|
|
|
|
6) Misc Routes
|
|
|
|
--------------------
|
|
|
|
Settings
|
2013-10-09 22:21:28 +09:00
|
|
|
Categories
|
2013-10-09 20:59:42 +09:00
|
|
|
Toolbox
|
|
|
|
|
2013-10-09 21:34:55 +09:00
|
|
|
|
|
|
|
|
2013-10-09 20:59:42 +09:00
|
|
|
*/
|
|
|
|
|
2013-10-24 14:34:50 +09:00
|
|
|
|
2013-10-10 11:41:11 +09:00
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
//--------------------------------------------- Config ---------------------------------------------//
|
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
|
2013-10-24 14:34:50 +09:00
|
|
|
|
2013-10-06 08:37:17 +09:00
|
|
|
Router.configure({
|
2013-10-12 11:44:29 +09:00
|
|
|
layoutTemplate: 'layout',
|
2013-10-06 09:33:00 +09:00
|
|
|
loadingTemplate: 'loading',
|
2013-10-14 12:14:12 +09:00
|
|
|
notFoundTemplate: 'not_found',
|
2013-10-06 08:37:17 +09:00
|
|
|
});
|
|
|
|
|
2013-10-10 11:41:11 +09:00
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
//--------------------------------------------- Filters --------------------------------------------//
|
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
var filters = {
|
2013-10-13 10:27:49 +09:00
|
|
|
|
2013-10-24 14:34:50 +09:00
|
|
|
nProgressHook: function () {
|
|
|
|
if (this.ready()) {
|
|
|
|
NProgress.done();
|
|
|
|
} else {
|
|
|
|
NProgress.start();
|
|
|
|
this.stop();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-10-24 20:30:05 +09:00
|
|
|
resetScroll: function () {
|
|
|
|
var scrollTo = window.currentScroll || 0;
|
|
|
|
$('body').scrollTop(scrollTo);
|
|
|
|
$('body').css("min-height", 0);
|
|
|
|
},
|
|
|
|
|
2013-10-13 10:27:49 +09:00
|
|
|
isLoggedIn: function() {
|
2013-10-24 14:34:50 +09:00
|
|
|
if (!(Meteor.loggingIn() || Meteor.user())) {
|
2013-11-11 22:07:19 +01:00
|
|
|
throwError(i18n.t('Please Sign In First.'))
|
2013-10-24 14:34:50 +09:00
|
|
|
this.render('signin');
|
2013-10-13 10:27:49 +09:00
|
|
|
this.stop();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
isLoggedOut: function() {
|
|
|
|
if(Meteor.user()){
|
|
|
|
this.render('already_logged_in');
|
|
|
|
this.stop();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
isAdmin: function() {
|
2013-10-25 10:04:34 +09:00
|
|
|
if(!Meteor.loggingIn() && Session.get('settingsLoaded') && !isAdmin()){
|
2013-11-11 22:07:19 +01:00
|
|
|
throwError(i18n.t("Sorry, you have to be an admin to view this page."))
|
2013-10-13 10:27:49 +09:00
|
|
|
this.render('no_rights');
|
2013-10-25 10:04:34 +09:00
|
|
|
this.stop();
|
2013-10-13 10:27:49 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
canView: function() {
|
2013-10-24 21:07:55 +09:00
|
|
|
if(Session.get('settingsLoaded') && !canView()){
|
2013-11-15 11:50:57 +09:00
|
|
|
console.log('cannot view')
|
2013-10-13 10:27:49 +09:00
|
|
|
this.render('no_rights');
|
|
|
|
this.stop();
|
|
|
|
}
|
|
|
|
},
|
2013-10-12 11:44:29 +09:00
|
|
|
|
2013-10-24 14:34:50 +09:00
|
|
|
canPost: function () {
|
2013-10-26 10:37:32 +09:00
|
|
|
if(!Meteor.loggingIn() && Session.get('settingsLoaded') && !canPost()){
|
2013-11-11 22:07:19 +01:00
|
|
|
throwError(i18n.t("Sorry, you don't have permissions to add new items."))
|
2013-10-24 14:34:50 +09:00
|
|
|
this.render('no_rights');
|
|
|
|
this.stop();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-10-12 11:44:29 +09:00
|
|
|
canEditPost: function() {
|
|
|
|
var post = Posts.findOne(this.params._id);
|
2013-10-26 10:37:32 +09:00
|
|
|
if(!Meteor.loggingIn() && Session.get('settingsLoaded') && !currentUserCanEdit(post)){
|
2013-11-11 22:07:19 +01:00
|
|
|
throwError(i18n.t("Sorry, you cannot edit this post."))
|
2013-10-12 11:44:29 +09:00
|
|
|
this.render('no_rights');
|
|
|
|
this.stop();
|
2013-10-10 11:41:11 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-10-12 11:44:29 +09:00
|
|
|
canEditComment: function() {
|
|
|
|
var comment = Comments.findOne(this.params._id);
|
2013-10-26 10:37:32 +09:00
|
|
|
if(!Meteor.loggingIn() && Session.get('settingsLoaded') && !currentUserCanEdit(comment)){
|
2013-11-11 22:07:19 +01:00
|
|
|
throwError(i18n.t("Sorry, you cannot edit this comment."))
|
2013-10-12 11:44:29 +09:00
|
|
|
this.render('no_rights');
|
|
|
|
this.stop();
|
2013-10-10 11:41:11 +09:00
|
|
|
}
|
2013-10-13 10:27:49 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
hasCompletedProfile: function() {
|
|
|
|
var user = Meteor.user();
|
|
|
|
if (user && ! Meteor.loggingIn() && ! userProfileComplete(user)){
|
|
|
|
this.render('user_email');
|
|
|
|
this.stop();
|
|
|
|
}
|
2013-10-12 11:44:29 +09:00
|
|
|
}
|
2013-10-10 11:41:11 +09:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-10-24 14:36:20 +09:00
|
|
|
// Load Hooks
|
|
|
|
|
2013-10-24 14:34:50 +09:00
|
|
|
Router.load( function () {
|
2013-10-24 21:18:55 +09:00
|
|
|
clearSeenErrors(); // set all errors who have already been seen to not show anymore
|
2013-11-16 14:01:00 +09:00
|
|
|
Session.set('categorySlug', null);
|
|
|
|
|
2013-11-16 16:53:38 +09:00
|
|
|
// if we're not on the search page itself, clear search query and field
|
|
|
|
if(getCurrentRoute().indexOf('search') == -1){
|
2013-11-16 14:01:00 +09:00
|
|
|
Session.set('searchQuery', '');
|
|
|
|
$('.search-field').val('').blur();
|
|
|
|
}
|
|
|
|
|
2013-10-24 14:34:50 +09:00
|
|
|
});
|
|
|
|
|
2013-10-24 14:36:20 +09:00
|
|
|
// Before Hooks
|
2013-10-15 12:35:05 +09:00
|
|
|
|
2013-10-26 11:18:18 +09:00
|
|
|
// Use nProgress on every route that has to load a subscription
|
|
|
|
Router.before(filters.nProgressHook, {only: [
|
|
|
|
'posts_top',
|
|
|
|
'posts_new',
|
|
|
|
'posts_best',
|
|
|
|
'posts_pending',
|
|
|
|
'posts_digest',
|
2013-11-16 16:53:38 +09:00
|
|
|
'posts_category',
|
|
|
|
'search',
|
2013-10-26 11:18:18 +09:00
|
|
|
'post_page',
|
|
|
|
'post_edit',
|
|
|
|
'comment_page',
|
|
|
|
'comment_edit',
|
|
|
|
'comment_reply',
|
|
|
|
'user_edit',
|
|
|
|
'user_profile',
|
2013-11-22 14:20:47 +09:00
|
|
|
'all-users',
|
|
|
|
'logs'
|
2013-10-26 11:18:18 +09:00
|
|
|
]});
|
|
|
|
|
2013-11-15 11:50:57 +09:00
|
|
|
Router.before(filters.canView);
|
2013-10-24 14:34:50 +09:00
|
|
|
Router.before(filters.hasCompletedProfile);
|
|
|
|
Router.before(filters.isLoggedIn, {only: ['comment_reply','post_submit']});
|
|
|
|
Router.before(filters.isLoggedOut, {only: ['signin', 'signup']});
|
|
|
|
Router.before(filters.canPost, {only: ['posts_pending', 'comment_reply', 'post_submit']});
|
|
|
|
Router.before(filters.canEditPost, {only: ['post_edit']});
|
|
|
|
Router.before(filters.canEditComment, {only: ['comment_edit']});
|
2013-11-22 14:20:47 +09:00
|
|
|
Router.before(filters.isAdmin, {only: ['posts_pending', 'all-users', 'settings', 'categories', 'toolbox', 'logs']});
|
2013-10-24 14:34:50 +09:00
|
|
|
|
2013-10-24 14:36:20 +09:00
|
|
|
// After Hooks
|
|
|
|
|
2013-10-26 11:18:18 +09:00
|
|
|
Router.after(filters.resetScroll, {except:['posts_top', 'posts_new', 'posts_best', 'posts_pending', 'posts_category', 'all-users']});
|
2013-10-29 22:28:52 -07:00
|
|
|
Router.after( function () {
|
|
|
|
analyticsRequest() // log this request with mixpanel, etc
|
|
|
|
});
|
2013-10-15 12:35:05 +09:00
|
|
|
|
2013-10-24 14:36:20 +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
|
|
|
|
|
|
|
PostsListController = RouteController.extend({
|
|
|
|
template:'posts_list',
|
|
|
|
waitOn: 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 = {
|
2013-11-17 08:01:56 +09:00
|
|
|
view: this.path == '/' ? 'top' : this.path.split('/')[1],
|
|
|
|
limit: this.params.limit || getSetting('postsPerPage', 10),
|
|
|
|
category: this.params.slug,
|
|
|
|
query: Session.get("searchQuery")
|
|
|
|
}
|
2013-10-25 11:54:19 +09:00
|
|
|
return [
|
2013-11-17 11:42:17 +09:00
|
|
|
Meteor.subscribe('postsList', this._terms),
|
|
|
|
Meteor.subscribe('postsListUsers', this._terms)
|
2013-10-25 11:54:19 +09:00
|
|
|
]
|
|
|
|
},
|
|
|
|
data: function () {
|
2013-11-17 11:42:17 +09:00
|
|
|
var parameters = getParameters(this._terms),
|
2013-10-29 17:05:20 +09:00
|
|
|
posts = Posts.find(parameters.find, parameters.options);
|
|
|
|
postsCount = posts.count();
|
2013-11-16 17:44:33 +09:00
|
|
|
|
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 {
|
2013-10-29 17:05:20 +09:00
|
|
|
postsList: posts,
|
|
|
|
postsCount: postsCount
|
2013-10-25 11:54:19 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
after: function() {
|
2013-10-25 12:28:21 +09:00
|
|
|
var view = this.path == '/' ? 'top' : this.path.split('/')[1];
|
|
|
|
Session.set('view', view);
|
2013-10-25 11:54:19 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-10-26 10:37:32 +09:00
|
|
|
// Controller for post digest
|
|
|
|
|
|
|
|
PostsDigestController = RouteController.extend({
|
|
|
|
template: 'posts_digest',
|
|
|
|
waitOn: function() {
|
|
|
|
// if day is set, use that. If not default to today
|
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',
|
|
|
|
after: moment(currentDate).startOf('day').valueOf(),
|
|
|
|
before: moment(currentDate).endOf('day').valueOf()
|
|
|
|
}
|
2013-10-26 10:37:32 +09:00
|
|
|
return [
|
2013-11-17 08:01:56 +09:00
|
|
|
Meteor.subscribe('postsList', terms),
|
|
|
|
Meteor.subscribe('postsListUsers', terms)
|
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',
|
|
|
|
after: moment(currentDate).startOf('day').valueOf(),
|
|
|
|
before: moment(currentDate).endOf('day').valueOf()
|
|
|
|
},
|
|
|
|
parameters = getParameters(terms);
|
2013-10-26 10:37:32 +09:00
|
|
|
Session.set('currentDate', currentDate);
|
|
|
|
return {
|
|
|
|
posts: Posts.find(parameters.find, parameters.options)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Controller for post pages
|
2013-10-25 11:54:19 +09:00
|
|
|
|
|
|
|
PostPageController = RouteController.extend({
|
|
|
|
template: 'post_page',
|
|
|
|
waitOn: function () {
|
|
|
|
return [
|
|
|
|
Meteor.subscribe('singlePost', this.params._id),
|
2013-10-26 10:50:49 +09:00
|
|
|
Meteor.subscribe('postComments', this.params._id),
|
2013-10-25 11:54:19 +09:00
|
|
|
Meteor.subscribe('postUsers', this.params._id)
|
|
|
|
];
|
|
|
|
},
|
|
|
|
data: function () {
|
|
|
|
return {postId: this.params._id};
|
|
|
|
},
|
|
|
|
after: function () {
|
|
|
|
window.queueComments = false;
|
|
|
|
window.openedComments = [];
|
|
|
|
// TODO: scroll to comment position
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-10-26 10:37:32 +09:00
|
|
|
// Controller for comment pages
|
2013-10-25 11:54:19 +09:00
|
|
|
|
2013-10-26 10:37:32 +09:00
|
|
|
CommentPageController = RouteController.extend({
|
|
|
|
waitOn: function() {
|
|
|
|
return [
|
|
|
|
Meteor.subscribe('singleComment', this.params._id),
|
2013-10-26 10:47:13 +09:00
|
|
|
Meteor.subscribe('commentUser', this.params._id),
|
|
|
|
Meteor.subscribe('commentPost', this.params._id)
|
2013-10-26 10:37:32 +09:00
|
|
|
]
|
|
|
|
},
|
|
|
|
data: function() {
|
|
|
|
return {
|
|
|
|
comment: Comments.findOne(this.params._id)
|
|
|
|
}
|
2013-10-26 17:35:45 +09:00
|
|
|
},
|
|
|
|
after: function () {
|
|
|
|
window.queueComments = false;
|
|
|
|
}
|
2013-10-26 10:37:32 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// Controller for user pages
|
|
|
|
|
|
|
|
UserPageController = RouteController.extend({
|
|
|
|
waitOn: function() {
|
|
|
|
return Meteor.subscribe('singleUser', this.params._idOrSlug);
|
|
|
|
},
|
|
|
|
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
|
|
|
|
}
|
2013-10-26 10:37:32 +09:00
|
|
|
}
|
|
|
|
}
|
2013-11-05 09:32:21 +09:00
|
|
|
});
|
|
|
|
|
2013-10-09 21:49:02 +09:00
|
|
|
//--------------------------------------------------------------------------------------------------//
|
|
|
|
//--------------------------------------------- Routes ---------------------------------------------//
|
|
|
|
//--------------------------------------------------------------------------------------------------//
|
2013-10-09 21:34:55 +09:00
|
|
|
|
2013-10-06 08:37:17 +09:00
|
|
|
Router.map(function() {
|
2013-10-06 09:33:00 +09:00
|
|
|
|
2013-11-16 14:01:00 +09:00
|
|
|
// -------------------------------------------- Post Lists -------------------------------------------- //
|
|
|
|
|
2013-10-09 20:59:42 +09:00
|
|
|
// Top
|
|
|
|
|
2013-10-24 20:46:14 +09:00
|
|
|
this.route('posts_top', {
|
2013-10-12 11:59:34 +09:00
|
|
|
path: '/',
|
2013-10-25 11:44:52 +09:00
|
|
|
controller: PostsListController
|
2013-10-12 11:59:34 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
this.route('posts_top', {
|
2013-10-24 20:46:14 +09:00
|
|
|
path: '/top/:limit?',
|
2013-10-25 11:44:52 +09:00
|
|
|
controller: PostsListController
|
2013-10-12 11:59:34 +09:00
|
|
|
});
|
2013-10-09 22:21:28 +09:00
|
|
|
|
2013-10-09 20:59:42 +09:00
|
|
|
// New
|
|
|
|
|
2013-10-12 11:59:34 +09:00
|
|
|
this.route('posts_new', {
|
2013-10-24 20:46:14 +09:00
|
|
|
path: '/new/:limit?',
|
2013-10-25 11:44:52 +09:00
|
|
|
controller: PostsListController
|
2013-10-12 11:59:34 +09:00
|
|
|
});
|
2013-10-09 22:21:28 +09:00
|
|
|
|
2013-10-09 20:59:42 +09:00
|
|
|
// Best
|
|
|
|
|
2013-10-12 11:59:34 +09:00
|
|
|
this.route('posts_best', {
|
2013-10-24 20:30:05 +09:00
|
|
|
path: '/best/:limit?',
|
2013-10-25 11:44:52 +09:00
|
|
|
controller: PostsListController
|
2013-10-12 11:59:34 +09:00
|
|
|
});
|
2013-10-09 22:21:28 +09:00
|
|
|
|
2013-10-09 20:59:42 +09:00
|
|
|
// Pending
|
|
|
|
|
2013-10-12 11:59:34 +09:00
|
|
|
this.route('posts_pending', {
|
2013-10-24 20:51:45 +09:00
|
|
|
path: '/pending/:limit?',
|
2013-10-25 11:44:52 +09:00
|
|
|
controller: PostsListController
|
2013-10-12 11:59:34 +09:00
|
|
|
});
|
2013-10-09 22:21:28 +09:00
|
|
|
|
2013-10-09 20:59:42 +09:00
|
|
|
// Categories
|
|
|
|
|
2013-10-26 11:18:18 +09:00
|
|
|
this.route('posts_category', {
|
2013-10-24 21:02:42 +09:00
|
|
|
path: '/category/:slug/:limit?',
|
2013-10-25 12:28:21 +09:00
|
|
|
controller: PostsListController,
|
2013-10-15 12:15:32 +09:00
|
|
|
after: function() {
|
|
|
|
Session.set('categorySlug', this.params.slug);
|
|
|
|
}
|
2013-10-12 13:32:34 +09:00
|
|
|
});
|
2013-10-12 13:01:16 +09:00
|
|
|
|
2013-10-15 12:35:05 +09:00
|
|
|
// TODO: enable /category/new, /category/best, etc. views
|
|
|
|
|
2013-11-16 14:01:00 +09:00
|
|
|
// Search
|
|
|
|
|
|
|
|
this.route('search', {
|
2013-11-16 16:53:38 +09:00
|
|
|
path: '/search/:limit?',
|
2013-11-16 14:01:00 +09:00
|
|
|
controller: PostsListController
|
|
|
|
});
|
2013-10-15 12:35:05 +09:00
|
|
|
|
2013-10-09 11:32:36 +09:00
|
|
|
// Digest
|
2013-10-09 11:21:23 +09:00
|
|
|
|
|
|
|
this.route('posts_digest', {
|
2013-10-06 09:33:00 +09:00
|
|
|
path: '/digest/:year/:month/:day',
|
2013-10-26 10:37:32 +09:00
|
|
|
controller: PostsDigestController
|
2013-10-06 09:33:00 +09:00
|
|
|
});
|
2013-10-06 08:37:17 +09:00
|
|
|
|
2013-10-26 11:18:18 +09:00
|
|
|
this.route('posts_digest', {
|
2013-10-09 21:49:02 +09:00
|
|
|
path: '/digest',
|
2013-10-26 10:37:32 +09:00
|
|
|
controller: PostsDigestController
|
2013-10-09 21:49:02 +09:00
|
|
|
});
|
|
|
|
|
2013-10-12 11:44:29 +09:00
|
|
|
// -------------------------------------------- Post -------------------------------------------- //
|
|
|
|
|
2013-10-24 14:34:50 +09:00
|
|
|
|
2013-10-09 11:32:36 +09:00
|
|
|
// Post Page
|
|
|
|
|
2013-10-06 08:47:15 +09:00
|
|
|
this.route('post_page', {
|
|
|
|
path: '/posts/:_id',
|
2013-10-25 11:54:19 +09:00
|
|
|
controller: PostPageController
|
2013-10-09 20:11:58 +09:00
|
|
|
});
|
|
|
|
|
2013-10-26 11:18:18 +09:00
|
|
|
this.route('post_page', {
|
2013-10-24 14:34:50 +09:00
|
|
|
path: '/posts/:_id/comment/:commentId',
|
2013-10-25 11:54:19 +09:00
|
|
|
controller: PostPageController,
|
2013-10-24 14:34:50 +09:00
|
|
|
after: function () {
|
|
|
|
// TODO: scroll to comment position
|
2013-10-06 08:47:15 +09:00
|
|
|
}
|
|
|
|
});
|
2013-10-09 12:39:05 +09:00
|
|
|
|
2013-10-09 11:32:36 +09:00
|
|
|
// Post Edit
|
|
|
|
|
2013-10-06 09:17:37 +09:00
|
|
|
this.route('post_edit', {
|
|
|
|
path: '/posts/:_id/edit',
|
2013-10-24 14:34:50 +09:00
|
|
|
waitOn: function () {
|
2013-10-06 09:17:37 +09:00
|
|
|
return Meteor.subscribe('singlePost', this.params._id);
|
|
|
|
},
|
|
|
|
data: function() {
|
2013-10-24 14:34:50 +09:00
|
|
|
return {postId: this.params._id};
|
|
|
|
}
|
2013-10-06 09:17:37 +09:00
|
|
|
});
|
2013-10-09 11:32:36 +09:00
|
|
|
|
2013-10-09 12:39:05 +09:00
|
|
|
// Post Submit
|
|
|
|
|
|
|
|
this.route('post_submit', {path: '/submit'});
|
|
|
|
|
2013-10-12 11:44:29 +09:00
|
|
|
// -------------------------------------------- Comment -------------------------------------------- //
|
|
|
|
|
2013-10-09 11:32:36 +09:00
|
|
|
// Comment Page
|
|
|
|
|
2013-10-09 11:46:44 +09:00
|
|
|
this.route('comment_page', {
|
2013-10-09 12:39:05 +09:00
|
|
|
path: '/comments/:_id',
|
2013-10-26 10:37:32 +09:00
|
|
|
controller: CommentPageController
|
2013-10-09 12:39:05 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// Comment Reply
|
|
|
|
|
|
|
|
this.route('comment_reply', {
|
|
|
|
path: '/comments/:_id/reply',
|
2013-10-26 10:37:32 +09:00
|
|
|
controller: CommentPageController,
|
2013-10-23 10:40:29 +08:00
|
|
|
after: function() {
|
|
|
|
window.queueComments = false;
|
2013-10-09 11:46:44 +09:00
|
|
|
}
|
|
|
|
});
|
2013-10-09 11:32:36 +09:00
|
|
|
|
|
|
|
// Comment Edit
|
|
|
|
|
2013-10-09 12:39:05 +09:00
|
|
|
this.route('comment_edit', {
|
|
|
|
path: '/comments/:_id/edit',
|
2013-10-26 10:37:32 +09:00
|
|
|
controller: CommentPageController,
|
|
|
|
after: function() {
|
|
|
|
window.queueComments = false;
|
|
|
|
}
|
2013-10-09 12:39:05 +09:00
|
|
|
});
|
|
|
|
|
2013-10-14 11:37:37 +09:00
|
|
|
// -------------------------------------------- Users -------------------------------------------- //
|
|
|
|
|
2013-10-09 20:50:26 +09:00
|
|
|
// User Profile
|
|
|
|
|
|
|
|
this.route('user_profile', {
|
2013-10-24 11:04:27 +09:00
|
|
|
path: '/users/:_idOrSlug',
|
2013-10-26 10:37:32 +09:00
|
|
|
controller: UserPageController
|
2013-10-09 20:50:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// User Edit
|
|
|
|
|
|
|
|
this.route('user_edit', {
|
2013-10-26 10:37:32 +09:00
|
|
|
path: '/users/:_idOrSlug/edit',
|
|
|
|
controller: UserPageController
|
2013-10-09 20:50:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// Account
|
|
|
|
|
|
|
|
this.route('account', {
|
|
|
|
path: '/account',
|
|
|
|
template: 'user_edit',
|
|
|
|
data: function() {
|
|
|
|
return {
|
|
|
|
user: Meteor.user()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-10-26 10:37:32 +09:00
|
|
|
// Forgot Password
|
|
|
|
|
|
|
|
this.route('forgot_password');
|
|
|
|
|
2013-10-09 20:50:26 +09:00
|
|
|
// All Users
|
|
|
|
|
2013-10-25 09:54:40 +09:00
|
|
|
this.route('all-users', {
|
|
|
|
path: '/all-users/:limit?',
|
|
|
|
template: 'users',
|
2013-10-09 22:16:47 +09:00
|
|
|
waitOn: function() {
|
2013-11-17 08:01:56 +09:00
|
|
|
var limit = parseInt(this.params.limit) || 20;
|
|
|
|
return Meteor.subscribe('allUsers', this.params.filterBy, this.params.sortBy, limit);
|
2013-10-09 22:16:47 +09:00
|
|
|
},
|
|
|
|
data: function() {
|
2013-11-04 22:05:19 +09:00
|
|
|
var limit = parseInt(this.params.limit) || 20,
|
2013-11-08 09:47:23 +09:00
|
|
|
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';
|
2013-10-25 09:54:40 +09:00
|
|
|
Session.set('usersLimit', limit);
|
2013-10-09 22:16:47 +09:00
|
|
|
return {
|
2013-11-04 22:05:19 +09:00
|
|
|
users: Meteor.users.find(parameters.find, parameters.options),
|
2013-11-08 09:47:23 +09:00
|
|
|
filterBy: filterBy,
|
|
|
|
sortBy: sortBy
|
2013-10-09 22:16:47 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2013-10-09 20:50:26 +09:00
|
|
|
|
2013-10-09 20:26:58 +09:00
|
|
|
// Unsubscribe (from notifications)
|
|
|
|
|
|
|
|
this.route('unsubscribe', {
|
|
|
|
path: '/unsubscribe/:hash',
|
|
|
|
data: function() {
|
|
|
|
return {
|
|
|
|
hash: this.params.hash
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2013-10-09 20:50:26 +09:00
|
|
|
|
2013-10-09 20:53:55 +09:00
|
|
|
// User Sign-Up
|
|
|
|
|
|
|
|
this.route('signup');
|
2013-10-09 20:59:42 +09:00
|
|
|
|
2013-10-09 20:53:55 +09:00
|
|
|
// User Sign-In
|
|
|
|
|
|
|
|
this.route('signin');
|
|
|
|
|
2013-10-14 11:37:37 +09:00
|
|
|
// -------------------------------------------- Other -------------------------------------------- //
|
|
|
|
|
2013-10-09 22:21:28 +09:00
|
|
|
// Categories
|
|
|
|
|
|
|
|
this.route('categories');
|
|
|
|
|
2013-10-09 20:53:55 +09:00
|
|
|
// Settings
|
|
|
|
|
|
|
|
this.route('settings');
|
|
|
|
|
|
|
|
// Toolbox
|
|
|
|
|
|
|
|
this.route('toolbox');
|
|
|
|
|
2013-11-22 14:20:47 +09:00
|
|
|
// Search Logs
|
|
|
|
|
|
|
|
this.route('logs', {
|
|
|
|
path: '/logs/:limit?',
|
|
|
|
waitOn: function () {
|
|
|
|
var limit = this.params.limit || 100;
|
|
|
|
Session.set('logsLimit', limit);
|
|
|
|
return Meteor.subscribe('searches', limit);
|
|
|
|
},
|
|
|
|
data: function () {
|
|
|
|
return Searches.find({}, {sort: {timestamp: -1}});
|
|
|
|
}
|
|
|
|
});
|
2013-10-06 08:37:17 +09:00
|
|
|
});
|