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

82 lines
2.8 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;
// Topic routes
this.resource('topic', { path: '/t/:slug/:id' }, function() {
this.route('fromParams', { path: '/' });
this.route('fromParamsNear', { path: '/:nearPost' });
});
// Generate static page routes
Discourse.StaticController.pages.forEach(function(p) {
router.route(p, { path: "/" + p });
});
// List routes
this.resource('list', { path: '/' }, function() {
router = this;
// Generate routes for all our filters
Discourse.ListController.filters.forEach(function(filter) {
router.route(filter, { path: "/" + filter });
router.route(filter, { path: "/" + filter + "/more" });
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" });
});
// homepage
var homepage = Discourse.User.current() ?
Discourse.User.currentProp("homepage") :
Discourse.Utilities.defaultHomepage();
this.route(homepage, { path: '/' });
2013-12-23 18:50:36 -05:00
// categories page
this.route('categories', { path: '/categories' });
2013-12-23 18:50:36 -05:00
// category
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' });
});
// User routes
this.resource('user', { path: '/users/:username' }, function() {
this.route('index', { path: '/'} );
this.resource('userActivity', { path: '/activity' }, function() {
var self = this;
Object.keys(Discourse.UserAction.TYPES).forEach(function (userAction) {
self.route(userAction, { path: userAction.replace("_", "-") });
});
});
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' });
});
this.resource('preferences', { path: '/preferences' }, function() {
this.route('username', { path: '/username' });
this.route('email', { path: '/email' });
this.route('about', { path: '/about-me' });
2013-08-13 16:08:29 -04:00
this.route('avatar', { path: '/avatar' });
});
this.route('invited', { path: 'invited' });
});
});