sam
(Sam Saffron)
November 28, 2016, 6:21am
1
Mainly a question for @eviltrout
I am trying to extend some of the internal routes for the solved plugin.
I tried adding assets/javascripts/discourse/solved-route-map.js
with:
export default function() {
this.route('user', { resetNamespace: true, path: '/users/:username'} , function() {
this.route('userActivity', { resetNamespace: true, path: 'user-activity' } , function() {
this.route('solved');
});
});
};
Trouble is that it blows away the existing routes and pretty much breaks everything, I also tries with resource
using the other mechanism but it does not play nice with nested routes.
Any idea how I would go about doing this?
5 Likes
eviltrout
(Robin Ward)
November 28, 2016, 6:46pm
2
This is not super well documented, but the route maps are actually designed just for this purpose!
You should be able to do this:
export default {
resource: 'userActivity',
map() {
this.route('solved');
}
};
The resource
key in the object tells my custom route map code to attach the routes inside that resource.
6 Likes
sam
(Sam Saffron)
November 29, 2016, 4:50am
3
Yeah, I tried that but it fails to map right cause it is nested :
3 Likes
eviltrout
(Robin Ward)
November 29, 2016, 6:10pm
4
Okay, I got this working although it meant a 100% rewrite of how my route map worked!
https://github.com/discourse/discourse/commit/4e251eaf080cb3d77eca843a47a8a950060d2564
Using what I suggested above (with a small change) will now work:
export default {
resource: 'user.userActivity',
map() {
this.route('solved');
}
};
9 Likes