Author: Braulio Bhavamitra <braulio@prout.io>
routes: remake profile optional
config/routes/myprofile/30_myprofile.rb | 4 ++-- config/routes/profile/21_profile.rb | 26 +++++++++++++------------- config/routes/profile/23_profile.rb | 6 +++---
diff --git a/config/routes/myprofile/30_myprofile.rb b/config/routes/myprofile/30_myprofile.rb index a4d3a684c582bf612e26690cac9be41e6d3af42d..aa74c01950738a75c6e0ef69400d92e962e6ef22 100644 --- a/config/routes/myprofile/30_myprofile.rb +++ b/config/routes/myprofile/30_myprofile.rb @@ -1,6 +1,6 @@ Noosfero::Application.routes.draw do - match 'myprofile/:profile', controller: :profile_editor, action: :index, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all - match 'myprofile/:profile/:controller(/:action(/:id))', controller: Noosfero.pattern_for_controllers_in_directory('my_profile'), profile: /#{Noosfero.identifier_format_in_url}/i, as: :myprofile, via: :all + match 'myprofile(/:profile)', controller: :profile_editor, action: :index, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all + match 'myprofile(/:profile)/:controller(/:action(/:id))', controller: Noosfero.pattern_for_controllers_in_directory('my_profile'), profile: /#{Noosfero.identifier_format_in_url}/i, as: :myprofile, via: :all end diff --git a/config/routes/profile/21_profile.rb b/config/routes/profile/21_profile.rb index 4dc906ededd44697b7bde9d0a62fd75b7ca66041..5d70301e0b44821711faea448c05fe77912261ba 100644 --- a/config/routes/profile/21_profile.rb +++ b/config/routes/profile/21_profile.rb @@ -4,31 +4,31 @@ match ':profile/about', controller: :profile, action: :about, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all match ':profile/activities', controller: :profile, action: :activities, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all # events - match 'profile/:profile/events_by_day', controller: :events, action: :events_by_day, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all - match 'profile/:profile/events_by_month', controller: :events, action: :events_by_month, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all - match 'profile/:profile/events/:year/:month/:day', controller: :events, action: :events, year: /\d*/, month: /\d*/, day: /\d*/, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all - match 'profile/:profile/events/:year/:month', controller: :events, action: :events, year: /\d*/, month: /\d*/, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all - match 'profile/:profile/events', controller: :events, action: :events, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all + match 'profile(/:profile)/events_by_day', controller: :events, action: :events_by_day, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all + match 'profile(/:profile)/events_by_month', controller: :events, action: :events_by_month, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all + match 'profile(/:profile)/events/:year/:month/:day', controller: :events, action: :events, year: /\d*/, month: /\d*/, day: /\d*/, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all + match 'profile(/:profile)/events/:year/:month', controller: :events, action: :events, year: /\d*/, month: /\d*/, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all + match 'profile(/:profile)/events', controller: :events, action: :events, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all # invite - match 'profile/:profile/invite/friends', controller: :invite, action: :invite_friends, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all - match 'profile/:profile/invite/:action', controller: :invite, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all + match 'profile(/:profile)/invite/friends', controller: :invite, action: :invite_friends, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all + match 'profile(/:profile)/invite/:action', controller: :invite, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all # feeds per tag - match 'profile/:profile/tags/:id/feed', controller: :profile, action: :tag_feed, id: /.+/, profile: /#{Noosfero.identifier_format_in_url}/i, as: :tag_feed, via: :all + match 'profile(/:profile)/tags/:id/feed', controller: :profile, action: :tag_feed, id: /.+/, profile: /#{Noosfero.identifier_format_in_url}/i, as: :tag_feed, via: :all # profile tags - match 'profile/:profile/tags/:id', controller: :profile, action: :content_tagged, id: /.+/, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all - match 'profile/:profile/tags(/:id)', controller: :profile, action: :tags, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all + match 'profile(/:profile)/tags/:id', controller: :profile, action: :content_tagged, id: /.+/, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all + match 'profile(/:profile)/tags(/:id)', controller: :profile, action: :tags, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all # profile search - match 'profile/:profile/search', controller: :profile_search, action: :index, profile: /#{Noosfero.identifier_format_in_url}/i, + match 'profile(/:profile)/search', controller: :profile_search, action: :index, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all, as: :profile_search # comments - match 'profile/:profile/comment/:action/:id', controller: :comment, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all + match 'profile(/:profile)/comment/:action/:id', controller: :comment, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all # public profile information - match 'profile/:profile(/:action(/:id))', controller: :profile, action: :index, id: /[^\/]*/, profile: /#{Noosfero.identifier_format_in_url}/i, as: :profile, via: :all + match 'profile(/:profile)(/:action(/:id))', controller: :profile, action: :index, id: /[^\/]*/, profile: /#{Noosfero.identifier_format_in_url}/i, as: :profile, via: :all end diff --git a/config/routes/profile/23_profile.rb b/config/routes/profile/23_profile.rb index 4e3456e7ee0e658fea87eb199df4afa2177be057..3f65fa7d03414f70bbeee9f1c517173e172f47b4 100644 --- a/config/routes/profile/23_profile.rb +++ b/config/routes/profile/23_profile.rb @@ -2,9 +2,9 @@ Noosfero::Application.routes.draw do ## # Keep products URL compatibility - get 'catalog/:profile', to: redirect{ |params, request| "/profile/#{request.params[:profile]}/plugin/products/catalog" } - get 'profile/:profile/catalog', to: redirect{ |params, request| "/profile/#{request.params[:profile]}/plugin/products/catalog" } - get 'myprofile/:profile/manage_products(/:action(/:id))', to: (redirect do |params, request| + get 'catalog(/:profile)', to: redirect{ |params, request| "/profile/#{request.params[:profile]}/plugin/products/catalog" } + get 'profile(/:profile)/catalog', to: redirect{ |params, request| "/profile/#{request.params[:profile]}/plugin/products/catalog" } + get 'myprofile(/:profile)/manage_products(/:action(/:id))', to: (redirect do |params, request| "/profile/#{request.params[:profile]}/plugin/products/page/#{request.params[:action]}/#{request.params[:id]}" end)