2013-02-22 15:41:12 -05:00
|
|
|
/**
|
|
|
|
Builds the routes for the application
|
|
|
|
|
|
|
|
@method buildRoutes
|
|
|
|
@for Discourse.ApplicationRoute
|
|
|
|
**/
|
2013-02-26 14:54:43 -05:00
|
|
|
Discourse.Route.buildRoutes(function() {
|
2013-02-22 15:41:12 -05:00
|
|
|
var router = this;
|
|
|
|
|
2014-06-16 14:25:33 -04:00
|
|
|
// Error page
|
|
|
|
this.route('exception', { path: '/exception' });
|
|
|
|
|
2014-08-11 16:59:00 -04:00
|
|
|
this.resource('about', { path: '/about' });
|
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
// Topic routes
|
|
|
|
this.resource('topic', { path: '/t/:slug/:id' }, function() {
|
|
|
|
this.route('fromParams', { path: '/' });
|
2013-08-29 12:26:05 -04:00
|
|
|
this.route('fromParamsNear', { path: '/:nearPost' });
|
2013-02-22 15:41:12 -05:00
|
|
|
});
|
2013-02-22 10:20:23 -05:00
|
|
|
|
2014-01-14 12:48:57 -05:00
|
|
|
this.resource('discovery', { path: '/' }, function() {
|
|
|
|
router = this;
|
2014-01-16 22:38:08 -05:00
|
|
|
|
2014-01-13 19:02:14 -05:00
|
|
|
// top
|
|
|
|
this.route('top');
|
|
|
|
this.route('topCategory', { path: '/category/:slug/l/top' });
|
|
|
|
this.route('topCategoryNone', { path: '/category/:slug/none/l/top' });
|
|
|
|
this.route('topCategory', { path: '/category/:parentSlug/:slug/l/top' });
|
2013-03-28 09:01:13 -04:00
|
|
|
|
2014-01-13 19:02:14 -05:00
|
|
|
// top by periods
|
2014-01-14 12:48:57 -05:00
|
|
|
Discourse.Site.currentProp('periods').forEach(function(period) {
|
2014-01-13 19:02:14 -05:00
|
|
|
var top = 'top' + period.capitalize();
|
|
|
|
router.route(top, { path: '/top/' + period });
|
|
|
|
router.route(top + 'Category', { path: '/category/:slug/l/top/' + period });
|
|
|
|
router.route(top + 'CategoryNone', { path: '/category/:slug/none/l/top/' + period });
|
|
|
|
router.route(top + 'Category', { path: '/category/:parentSlug/:slug/l/top/' + period });
|
|
|
|
});
|
2013-12-23 18:50:36 -05:00
|
|
|
|
2014-01-20 08:41:11 -05:00
|
|
|
// filters
|
2014-01-14 12:48:57 -05:00
|
|
|
Discourse.Site.currentProp('filters').forEach(function(filter) {
|
2014-01-13 19:02:14 -05:00
|
|
|
router.route(filter, { path: '/' + filter });
|
|
|
|
router.route(filter + 'Category', { path: '/category/:slug/l/' + filter });
|
|
|
|
router.route(filter + 'CategoryNone', { path: '/category/:slug/none/l/' + filter });
|
|
|
|
router.route(filter + 'Category', { path: '/category/:parentSlug/:slug/l/' + filter });
|
|
|
|
});
|
|
|
|
|
2014-01-14 12:48:57 -05:00
|
|
|
this.route('categories');
|
|
|
|
|
2014-01-13 19:02:14 -05:00
|
|
|
// default filter for a category
|
2014-06-19 17:11:21 -04:00
|
|
|
this.route('parentCategory', { path: '/category/:slug' });
|
2013-12-13 17:18:28 -05:00
|
|
|
this.route('categoryNone', { path: '/category/:slug/none' });
|
2013-10-23 14:40:39 -04:00
|
|
|
this.route('category', { path: '/category/:parentSlug/:slug' });
|
2013-12-23 18:50:36 -05:00
|
|
|
|
2014-01-13 19:02:14 -05:00
|
|
|
// homepage
|
2014-04-21 12:43:44 -04:00
|
|
|
this.route(Discourse.Utilities.defaultHomepage(), { path: '/' });
|
2013-02-22 15:41:12 -05:00
|
|
|
});
|
|
|
|
|
2014-02-06 16:14:32 -05:00
|
|
|
this.resource('group', { path: '/groups/:name' }, function() {
|
2014-02-06 13:06:19 -05:00
|
|
|
this.route('members');
|
|
|
|
});
|
2014-01-30 17:10:36 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
// User routes
|
|
|
|
this.resource('user', { path: '/users/:username' }, function() {
|
2013-07-16 16:16:37 -04:00
|
|
|
this.resource('userActivity', { path: '/activity' }, function() {
|
2014-01-13 19:02:14 -05:00
|
|
|
router = this;
|
|
|
|
_.map(Discourse.UserAction.TYPES, function (id, userAction) {
|
|
|
|
router.route(userAction, { path: userAction.replace('_', '-') });
|
2013-07-16 16:16:37 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-04-16 14:49:28 -04:00
|
|
|
this.route('badges');
|
2014-09-02 21:32:27 -04:00
|
|
|
this.route('notifications');
|
2014-07-16 15:04:55 -04:00
|
|
|
this.route('flaggedPosts', { path: '/flagged-posts' });
|
|
|
|
this.route('deletedPosts', { path: '/deleted-posts' });
|
2014-04-16 14:49:28 -04:00
|
|
|
|
2013-07-16 16:16:37 -04:00
|
|
|
this.resource('userPrivateMessages', { path: '/private-messages' }, function() {
|
2014-01-13 19:02:14 -05:00
|
|
|
this.route('mine');
|
|
|
|
this.route('unread');
|
2013-07-16 16:16:37 -04:00
|
|
|
});
|
|
|
|
|
2014-01-13 19:02:14 -05:00
|
|
|
this.resource('preferences', function() {
|
|
|
|
this.route('username');
|
|
|
|
this.route('email');
|
2013-07-22 16:52:46 -04:00
|
|
|
this.route('about', { path: '/about-me' });
|
2014-04-17 23:10:53 -04:00
|
|
|
this.route('badgeTitle', { path: '/badge_title' });
|
2013-02-20 13:15:50 -05:00
|
|
|
});
|
2013-07-16 16:16:37 -04:00
|
|
|
|
2014-01-13 19:02:14 -05:00
|
|
|
this.route('invited');
|
2013-02-20 13:15:50 -05:00
|
|
|
});
|
2014-02-18 17:18:42 -05:00
|
|
|
|
|
|
|
this.route('signup', {path: '/signup'});
|
|
|
|
this.route('login', {path: '/login'});
|
2014-07-29 14:24:16 -04:00
|
|
|
this.route('faq', {path: '/faq'});
|
|
|
|
this.route('tos', {path: '/tos'});
|
|
|
|
this.route('privacy', {path: '/privacy'});
|
|
|
|
this.route('guidelines', {path: '/guidelines'});
|
2014-04-16 09:12:06 -04:00
|
|
|
|
2014-04-16 10:56:11 -04:00
|
|
|
this.resource('badges', function() {
|
|
|
|
this.route('show', {path: '/:id/:slug'});
|
|
|
|
});
|
2013-02-22 15:41:12 -05:00
|
|
|
});
|