discourse/app/assets/javascripts/discourse/routes/application_routes.js

102 lines
3.3 KiB
JavaScript
Raw Normal View History

/**
Builds the routes for the application
@method buildRoutes
@for Discourse.ApplicationRoute
**/
2013-02-26 14:54:43 -05:00
Discourse.Route.buildRoutes(function() {
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' });
// Topic routes
this.resource('topic', { path: '/t/:slug/:id' }, function() {
this.route('fromParams', { path: '/' });
this.route('fromParamsNear', { path: '/:nearPost' });
});
this.resource('discovery', { path: '/' }, function() {
router = this;
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' });
2014-01-13 19:02:14 -05:00
// top by periods
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
// filters
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 });
});
this.route('categories');
2014-01-13 19:02:14 -05:00
// default filter for a category
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
this.route(Discourse.Utilities.defaultHomepage(), { path: '/' });
});
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');
});
// User routes
this.resource('user', { path: '/users/:username' }, function() {
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('_', '-') });
});
});
2014-04-16 14:49:28 -04:00
this.route('badges');
this.route('notifications');
this.route('flaggedPosts', { path: '/flagged-posts' });
this.route('deletedPosts', { path: '/deleted-posts' });
2014-04-16 14:49:28 -04:00
this.resource('userPrivateMessages', { path: '/private-messages' }, function() {
2014-01-13 19:02:14 -05:00
this.route('mine');
this.route('unread');
});
2014-01-13 19:02:14 -05:00
this.resource('preferences', function() {
this.route('username');
this.route('email');
this.route('about', { path: '/about-me' });
this.route('badgeTitle', { path: '/badge_title' });
});
2014-01-13 19:02:14 -05:00
this.route('invited');
});
this.route('signup', {path: '/signup'});
this.route('login', {path: '/login'});
this.route('faq', {path: '/faq'});
this.route('tos', {path: '/tos'});
this.route('privacy', {path: '/privacy'});
this.route('guidelines', {path: '/guidelines'});
2014-04-16 10:56:11 -04:00
this.resource('badges', function() {
this.route('show', {path: '/:id/:slug'});
});
});