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;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
// Generate static page routes
|
|
|
|
Discourse.StaticController.pages.forEach(function(p) {
|
|
|
|
router.route(p, { path: "/" + p });
|
|
|
|
});
|
2013-02-22 10:20:23 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
// List routes
|
|
|
|
this.resource('list', { path: '/' }, function() {
|
|
|
|
router = this;
|
2013-02-22 10:20:23 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
// Generate routes for all our filters
|
2013-03-28 09:01:13 -04:00
|
|
|
Discourse.ListController.filters.forEach(function(filter) {
|
|
|
|
router.route(filter, { path: "/" + filter });
|
|
|
|
router.route(filter, { path: "/" + filter + "/more" });
|
2013-10-25 15:23:29 -04:00
|
|
|
router.route(filter + "Category", { path: "/category/:slug/l/" + filter });
|
|
|
|
router.route(filter + "Category", { path: "/category/:slug/l/" + filter + "/more" });
|
|
|
|
router.route(filter + "Category", { path: "/category/:parentSlug/:slug/l/" + filter });
|
|
|
|
router.route(filter + "Category", { path: "/category/:parentSlug/:slug/l/" + filter + "/more" });
|
2013-02-20 13:15:50 -05:00
|
|
|
});
|
2013-02-22 10:20:23 -05:00
|
|
|
|
2013-12-30 12:46:18 -05:00
|
|
|
// homepage
|
|
|
|
var homepage = Discourse.User.current() ?
|
|
|
|
Discourse.User.currentProp("homepage") :
|
|
|
|
Discourse.Utilities.defaultHomepage();
|
2013-03-28 09:01:13 -04:00
|
|
|
this.route(homepage, { path: '/' });
|
|
|
|
|
2013-12-23 18:50:36 -05:00
|
|
|
// categories page
|
2013-10-16 21:45:00 -04:00
|
|
|
this.route('categories', { path: '/categories' });
|
2013-12-23 18:50:36 -05:00
|
|
|
|
|
|
|
// category
|
2013-02-22 15:41:12 -05:00
|
|
|
this.route('category', { path: '/category/:slug' });
|
2013-10-23 14:40:39 -04:00
|
|
|
this.route('category', { path: '/category/:slug/more' });
|
2013-12-13 17:18:28 -05:00
|
|
|
this.route('categoryNone', { path: '/category/:slug/none' });
|
|
|
|
this.route('categoryNone', { path: '/category/:slug/none/more' });
|
2013-10-23 14:40:39 -04:00
|
|
|
this.route('category', { path: '/category/:parentSlug/:slug' });
|
|
|
|
this.route('category', { path: '/category/:parentSlug/:slug/more' });
|
2013-12-23 18:50:36 -05:00
|
|
|
|
|
|
|
// top page
|
|
|
|
this.route('top', { path: '/top' });
|
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.route('index', { path: '/'} );
|
|
|
|
|
|
|
|
this.resource('userActivity', { path: '/activity' }, function() {
|
2013-10-30 15:45:13 -04:00
|
|
|
var self = this;
|
2013-07-16 16:16:37 -04:00
|
|
|
Object.keys(Discourse.UserAction.TYPES).forEach(function (userAction) {
|
2013-10-30 15:45:13 -04:00
|
|
|
self.route(userAction, { path: userAction.replace("_", "-") });
|
2013-07-16 16:16:37 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this.resource('userPrivateMessages', { path: '/private-messages' }, function() {
|
2013-12-23 18:50:36 -05:00
|
|
|
this.route('mine', { path: '/mine' });
|
|
|
|
this.route('unread', { path: '/unread' });
|
2013-07-16 16:16:37 -04:00
|
|
|
});
|
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
this.resource('preferences', { path: '/preferences' }, function() {
|
|
|
|
this.route('username', { path: '/username' });
|
|
|
|
this.route('email', { path: '/email' });
|
2013-07-22 16:52:46 -04:00
|
|
|
this.route('about', { path: '/about-me' });
|
2013-08-13 16:08:29 -04:00
|
|
|
this.route('avatar', { path: '/avatar' });
|
2013-02-20 13:15:50 -05:00
|
|
|
});
|
2013-07-16 16:16:37 -04:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
this.route('invited', { path: 'invited' });
|
2013-02-20 13:15:50 -05:00
|
|
|
});
|
2013-02-22 15:41:12 -05:00
|
|
|
});
|