2016-02-19 12:27:58 +09:00
|
|
|
import React from 'react';
|
2016-03-23 11:46:56 +09:00
|
|
|
import Router from './router.js'
|
2016-02-19 12:27:58 +09:00
|
|
|
import {mount} from 'react-mounter';
|
|
|
|
|
2016-02-17 15:09:49 +09:00
|
|
|
// ------------------------------------- Posts -------------------------------- //
|
|
|
|
|
2016-03-23 11:46:56 +09:00
|
|
|
Router.route('/', {
|
2016-02-18 12:16:32 +09:00
|
|
|
name: 'posts.list',
|
2016-02-19 12:27:58 +09:00
|
|
|
action(params, queryParams) {
|
|
|
|
|
2016-03-27 16:32:29 +09:00
|
|
|
({App, ListContainer, PostList} = Telescope.components);
|
2016-03-05 09:46:35 -08:00
|
|
|
queryParams = _.isEmpty(queryParams) ? {view: 'new'} : _.clone(queryParams);
|
2016-02-17 19:39:43 +09:00
|
|
|
({selector, options} = Posts.parameters.get(queryParams));
|
2016-02-19 12:27:58 +09:00
|
|
|
|
2016-03-27 16:32:29 +09:00
|
|
|
mount(App, {content:
|
2016-02-17 17:22:32 +09:00
|
|
|
<ListContainer
|
|
|
|
collection={Posts}
|
2016-02-17 19:39:43 +09:00
|
|
|
publication="posts.list"
|
|
|
|
selector={selector}
|
|
|
|
options={options}
|
2016-02-17 17:22:32 +09:00
|
|
|
terms={queryParams}
|
2016-02-27 16:41:50 +09:00
|
|
|
joins={Posts.getJoins()}
|
2016-03-15 11:23:44 +09:00
|
|
|
component={PostList}
|
|
|
|
/>})
|
2016-02-17 15:09:49 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-03-23 11:46:56 +09:00
|
|
|
Router.route('/daily/:days?', {
|
|
|
|
name: 'posts.daily',
|
2016-03-22 10:22:46 +09:00
|
|
|
action(params, queryParams) {
|
|
|
|
|
2016-03-27 16:32:29 +09:00
|
|
|
({App, PostDaily} = Telescope.components);
|
2016-03-22 10:22:46 +09:00
|
|
|
|
2016-03-27 16:32:29 +09:00
|
|
|
mount(App, {content: <PostDaily days={params.days}/>})
|
2016-03-22 10:22:46 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-03-24 10:56:47 +09:00
|
|
|
Router.route('/posts/:_id/:slug?', {
|
2016-02-18 12:16:32 +09:00
|
|
|
name: 'posts.single',
|
2016-02-19 12:27:58 +09:00
|
|
|
action(params, queryParams) {
|
2016-03-27 16:32:29 +09:00
|
|
|
({App, DocumentContainer, PostPage} = Telescope.components);
|
|
|
|
mount(App, {content:
|
2016-03-02 13:54:58 +09:00
|
|
|
<DocumentContainer
|
2016-02-22 13:23:46 +09:00
|
|
|
collection={Posts}
|
|
|
|
publication="posts.single"
|
2016-02-27 10:58:57 +09:00
|
|
|
selector={params}
|
|
|
|
terms={params}
|
2016-02-27 16:41:50 +09:00
|
|
|
joins={Posts.getJoins()}
|
2016-03-25 11:30:01 +09:00
|
|
|
component={PostPage}
|
2016-03-15 11:23:44 +09:00
|
|
|
/>});
|
2016-02-17 15:09:49 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-03-28 10:55:19 +09:00
|
|
|
// ------------------------------------- Users -------------------------------- //
|
2016-02-17 15:09:49 +09:00
|
|
|
|
2016-03-23 11:46:56 +09:00
|
|
|
Router.route('/users/:slug', {
|
2016-02-23 21:35:54 +09:00
|
|
|
name: 'users.single',
|
|
|
|
action(params, queryParams) {
|
2016-03-28 12:36:29 +09:00
|
|
|
({App, DocumentContainer, UserProfile} = Telescope.components);
|
2016-03-27 16:32:29 +09:00
|
|
|
mount(App, {content:
|
2016-03-02 13:54:58 +09:00
|
|
|
<DocumentContainer
|
2016-02-23 21:35:54 +09:00
|
|
|
collection={Users}
|
|
|
|
publication="users.single"
|
2016-02-27 10:58:57 +09:00
|
|
|
selector={{'telescope.slug': params.slug}}
|
|
|
|
terms={{'telescope.slug': params.slug}}
|
2016-03-28 12:36:29 +09:00
|
|
|
component={UserProfile}
|
|
|
|
documentPropName="user"
|
2016-03-15 11:23:44 +09:00
|
|
|
/>});
|
2016-02-23 21:35:54 +09:00
|
|
|
}
|
|
|
|
});
|
2016-02-23 11:34:40 +09:00
|
|
|
|
2016-03-23 11:46:56 +09:00
|
|
|
Router.route('/account', {
|
2016-02-23 11:34:40 +09:00
|
|
|
name: 'account',
|
|
|
|
action(params, queryParams) {
|
2016-03-27 16:32:29 +09:00
|
|
|
({App, DocumentContainer, UserEdit} = Telescope.components);
|
|
|
|
mount(App, {content:
|
2016-03-02 13:54:58 +09:00
|
|
|
<DocumentContainer
|
2016-02-23 11:34:40 +09:00
|
|
|
collection={Users}
|
|
|
|
publication="users.single"
|
2016-02-27 10:58:57 +09:00
|
|
|
selector={{_id: Meteor.userId()}}
|
2016-02-23 11:34:40 +09:00
|
|
|
terms={{_id: Meteor.userId()}}
|
2016-03-25 12:42:25 +09:00
|
|
|
component={UserEdit}
|
2016-03-15 11:19:48 +09:00
|
|
|
/>});
|
2016-02-23 11:34:40 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-03-23 11:46:56 +09:00
|
|
|
Router.route('/users/:slug/edit', {
|
2016-02-23 11:34:40 +09:00
|
|
|
name: 'users.edit',
|
|
|
|
action(params, queryParams) {
|
2016-03-27 16:32:29 +09:00
|
|
|
({App, DocumentContainer, UserEdit} = Telescope.components);
|
|
|
|
mount(App, {content:
|
2016-03-02 13:54:58 +09:00
|
|
|
<DocumentContainer
|
2016-02-23 11:34:40 +09:00
|
|
|
collection={Users}
|
|
|
|
publication="users.single"
|
2016-02-27 10:58:57 +09:00
|
|
|
selector={params}
|
2016-02-23 11:34:40 +09:00
|
|
|
terms={params}
|
2016-03-25 12:42:25 +09:00
|
|
|
component={UserEdit}
|
2016-03-15 11:19:48 +09:00
|
|
|
/>});
|
2016-02-23 11:34:40 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-03-28 10:55:19 +09:00
|
|
|
// ------------------------------------- Other -------------------------------- //
|
|
|
|
|
2016-03-23 11:46:56 +09:00
|
|
|
Router.route('/cheatsheet', {
|
2016-03-19 10:15:36 +09:00
|
|
|
name: 'cheatsheet',
|
|
|
|
action() {
|
2016-03-27 16:32:29 +09:00
|
|
|
({App, Cheatsheet} = Telescope.components);
|
|
|
|
mount(App, {content: <Cheatsheet/>});
|
2016-03-19 10:15:36 +09:00
|
|
|
}
|
|
|
|
});
|
2016-02-23 11:34:40 +09:00
|
|
|
|
2016-03-28 10:55:19 +09:00
|
|
|
FlowRouter.notFound = {
|
|
|
|
action() {
|
|
|
|
({Error404} = Telescope.components);
|
|
|
|
mount(App, {content: <Error404/>});
|
|
|
|
}
|
|
|
|
};
|