Support `/group/xyz` paths as well as `/groups/xyz`

This commit is contained in:
Robin Ward 2014-10-14 15:10:51 -04:00
parent 366d7e892c
commit 216f718607
3 changed files with 14 additions and 4 deletions

View File

@ -129,7 +129,6 @@ Discourse.URL = Em.Object.createWithMixins({
path = path.replace(rootURL, '');
}
// Rewrite /my/* urls
if (path.indexOf('/my/') === 0) {
var currentUser = Discourse.User.current();
@ -141,6 +140,11 @@ Discourse.URL = Em.Object.createWithMixins({
}
}
// Rewrite /groups paths
if (path.indexOf('/group/') === 0) {
path = path.replace('group/', 'groups/');
}
if (this.navigatedToPost(oldPath, path)) { return; }
// Schedule a DOM cleanup event
Em.run.scheduleOnce('afterRender', Discourse.Route, 'cleanDOM');

View File

@ -41,9 +41,11 @@ export default function(filter, extras) {
setupController: function(controller, model, trans) {
controller.setProperties(Em.getProperties(trans, _.keys(queryParams).map(function(v){
return 'queryParams.' + v;
})));
if (trans) {
controller.setProperties(Em.getProperties(trans, _.keys(queryParams).map(function(v){
return 'queryParams.' + v;
})));
}
var periods = this.controllerFor('discovery').get('periods'),

View File

@ -269,6 +269,10 @@ Discourse::Application.routes.draw do
get 'counts'
end
# In case people try the wrong URL
get '/group/:id', to: redirect('/groups/%{id}')
get '/group/:id/members', to: redirect('/groups/%{id}/members')
resources :posts do
put "bookmark"
put "wiki"