Commit 269dc4a43bd4b8e401cf8ce77af6de7ed1ef8290
1 parent
6c3c3a20
Exists in
master
and in
27 other branches
Routes rewritten
Showing
3 changed files
with
35 additions
and
36 deletions
Show diff stats
MIGRATION_ISSUES
@@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
22 | 22 | ||
23 | * check FIXME's in Gemfile | 23 | * check FIXME's in Gemfile |
24 | 24 | ||
25 | -* Finish rewriting config/routes.rb (look for __END__) | 25 | +* Check the FIXME in config/routes.rb |
26 | 26 | ||
27 | * rewrite conditional routing. See FIXME in lib/route_if.rb and re-implement using the Rails 3 mechanism - http://guides.rubyonrails.org/routing.html#advanced-constraints | 27 | * rewrite conditional routing. See FIXME in lib/route_if.rb and re-implement using the Rails 3 mechanism - http://guides.rubyonrails.org/routing.html#advanced-constraints |
28 | 28 |
config/routes.rb
@@ -53,67 +53,65 @@ Noosfero::Application.routes.draw do | @@ -53,67 +53,65 @@ Noosfero::Application.routes.draw do | ||
53 | # search | 53 | # search |
54 | match 'search/:action(/*category_path)', :controller => 'search' | 54 | match 'search/:action(/*category_path)', :controller => 'search' |
55 | 55 | ||
56 | -end # FIXME remove this line and the following and finish rewriting the routes | ||
57 | -__END__ | ||
58 | # events | 56 | # events |
59 | - map.events 'profile/:profile/events_by_day', :controller => 'events', :action => 'events_by_day', :profile => /#{Noosfero.identifier_format}/ | ||
60 | - map.events 'profile/:profile/events/:year/:month/:day', :controller => 'events', :action => 'events', :year => /\d*/, :month => /\d*/, :day => /\d*/, :profile => /#{Noosfero.identifier_format}/ | ||
61 | - map.events 'profile/:profile/events/:year/:month', :controller => 'events', :action => 'events', :year => /\d*/, :month => /\d*/, :profile => /#{Noosfero.identifier_format}/ | ||
62 | - map.events 'profile/:profile/events', :controller => 'events', :action => 'events', :profile => /#{Noosfero.identifier_format}/ | 57 | + match 'profile/:profile/events_by_day', :controller => 'events', :action => 'events_by_day', :profile => /#{Noosfero.identifier_format}/ |
58 | + match 'profile/:profile/events/:year/:month/:day', :controller => 'events', :action => 'events', :year => /\d*/, :month => /\d*/, :day => /\d*/, :profile => /#{Noosfero.identifier_format}/ | ||
59 | + match 'profile/:profile/events/:year/:month', :controller => 'events', :action => 'events', :year => /\d*/, :month => /\d*/, :profile => /#{Noosfero.identifier_format}/ | ||
60 | + match 'profile/:profile/events', :controller => 'events', :action => 'events', :profile => /#{Noosfero.identifier_format}/ | ||
63 | 61 | ||
64 | # catalog | 62 | # catalog |
65 | - map.catalog 'catalog/:profile', :controller => 'catalog', :action => 'index', :profile => /#{Noosfero.identifier_format}/ | 63 | + match 'catalog/:profile', :controller => 'catalog', :action => 'index', :profile => /#{Noosfero.identifier_format}/ |
66 | 64 | ||
67 | # invite | 65 | # invite |
68 | - map.invite 'profile/:profile/invite/friends', :controller => 'invite', :action => 'select_address_book', :profile => /#{Noosfero.identifier_format}/ | ||
69 | - map.invite 'profile/:profile/invite/:action', :controller => 'invite', :profile => /#{Noosfero.identifier_format}/ | 66 | + match 'profile/:profile/invite/friends', :controller => 'invite', :action => 'select_address_book', :profile => /#{Noosfero.identifier_format}/ |
67 | + match 'profile/:profile/invite/:action', :controller => 'invite', :profile => /#{Noosfero.identifier_format}/ | ||
70 | 68 | ||
71 | # feeds per tag | 69 | # feeds per tag |
72 | - map.tag_feed 'profile/:profile/tags/:id/feed', :controller => 'profile', :action =>'tag_feed', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ | 70 | + match 'profile/:profile/tags/:id/feed', :controller => 'profile', :action =>'tag_feed', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ |
73 | 71 | ||
74 | # profile tags | 72 | # profile tags |
75 | - map.tag 'profile/:profile/tags/:id', :controller => 'profile', :action => 'content_tagged', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ | ||
76 | - map.tag 'profile/:profile/tags', :controller => 'profile', :action => 'tags', :profile => /#{Noosfero.identifier_format}/ | 73 | + match 'profile/:profile/tags/:id', :controller => 'profile', :action => 'content_tagged', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ |
74 | + match 'profile/:profile/tags', :controller => 'profile', :action => 'tags', :profile => /#{Noosfero.identifier_format}/ | ||
77 | 75 | ||
78 | # profile search | 76 | # profile search |
79 | - map.profile_search 'profile/:profile/search', :controller => 'profile_search', :action => 'index', :profile => /#{Noosfero.identifier_format}/ | 77 | + match 'profile/:profile/search', :controller => 'profile_search', :action => 'index', :profile => /#{Noosfero.identifier_format}/ |
80 | 78 | ||
81 | # public profile information | 79 | # public profile information |
82 | - map.profile 'profile/:profile/:action/:id', :controller => 'profile', :action => 'index', :id => /[^\/]*/, :profile => /#{Noosfero.identifier_format}/ | 80 | + match 'profile/:profile/:action/:id', :controller => 'profile', :action => 'index', :id => /[^\/]*/, :profile => /#{Noosfero.identifier_format}/ |
83 | 81 | ||
84 | # contact | 82 | # contact |
85 | - map.contact 'contact/:profile/:action/:id', :controller => 'contact', :action => 'index', :id => /.*/, :profile => /#{Noosfero.identifier_format}/ | 83 | + match 'contact/:profile/:action/:id', :controller => 'contact', :action => 'index', :id => /.*/, :profile => /#{Noosfero.identifier_format}/ |
86 | 84 | ||
87 | # map balloon | 85 | # map balloon |
88 | - map.contact 'map_balloon/:action/:id', :controller => 'map_balloon', :id => /.*/ | 86 | + match 'map_balloon/:action/:id', :controller => 'map_balloon', :id => /.*/ |
89 | 87 | ||
90 | # chat | 88 | # chat |
91 | - map.chat 'chat/:action/:id', :controller => 'chat' | ||
92 | - map.chat 'chat/:action', :controller => 'chat' | 89 | + match 'chat/:action/:id', :controller => 'chat' |
90 | + match 'chat/:action', :controller => 'chat' | ||
93 | 91 | ||
94 | ###################################################### | 92 | ###################################################### |
95 | ## Controllers that are profile-specific (for profile admins ) | 93 | ## Controllers that are profile-specific (for profile admins ) |
96 | ###################################################### | 94 | ###################################################### |
97 | # profile customization - "My profile" | 95 | # profile customization - "My profile" |
98 | - map.myprofile 'myprofile/:profile', :controller => 'profile_editor', :action => 'index', :profile => /#{Noosfero.identifier_format}/ | ||
99 | - map.myprofile 'myprofile/:profile/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_in_directory('my_profile'), :profile => /#{Noosfero.identifier_format}/ | 96 | + match 'myprofile/:profile', :controller => 'profile_editor', :action => 'index', :profile => /#{Noosfero.identifier_format}/ |
97 | + match 'myprofile/:profile/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_in_directory('my_profile'), :profile => /#{Noosfero.identifier_format}/ | ||
100 | 98 | ||
101 | 99 | ||
102 | ###################################################### | 100 | ###################################################### |
103 | ## Controllers that are used by environment admin | 101 | ## Controllers that are used by environment admin |
104 | ###################################################### | 102 | ###################################################### |
105 | # administrative tasks for a environment | 103 | # administrative tasks for a environment |
106 | - map.admin 'admin', :controller => 'admin_panel' | ||
107 | - map.admin 'admin/:controller/:action.:format/:id', :controller => Noosfero.pattern_for_controllers_in_directory('admin') | ||
108 | - map.admin 'admin/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_in_directory('admin') | 104 | + match 'admin', :controller => 'admin_panel' |
105 | + match 'admin/:controller/:action.:format/:id', :controller => Noosfero.pattern_for_controllers_in_directory('admin') | ||
106 | + match 'admin/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_in_directory('admin') | ||
109 | 107 | ||
110 | 108 | ||
111 | ###################################################### | 109 | ###################################################### |
112 | ## Controllers that are used by system admin | 110 | ## Controllers that are used by system admin |
113 | ###################################################### | 111 | ###################################################### |
114 | # administrative tasks for a environment | 112 | # administrative tasks for a environment |
115 | - map.system 'system', :controller => 'system' | ||
116 | - map.system 'system/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_in_directory('system') | 113 | + match 'system', :controller => 'system' |
114 | + match 'system/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_in_directory('system') | ||
117 | 115 | ||
118 | ###################################################### | 116 | ###################################################### |
119 | # plugin routes | 117 | # plugin routes |
@@ -122,15 +120,16 @@ __END__ | @@ -122,15 +120,16 @@ __END__ | ||
122 | eval(IO.read(plugins_routes), binding, plugins_routes) | 120 | eval(IO.read(plugins_routes), binding, plugins_routes) |
123 | 121 | ||
124 | # cache stuff - hack | 122 | # cache stuff - hack |
125 | - map.cache 'public/:action/:id', :controller => 'public' | 123 | + match 'public/:action/:id', :controller => 'public' |
126 | 124 | ||
127 | - map.connect ':profile/edit_comment/:id/*page', :controller => 'content_viewer', :action => 'edit_comment', :profile => /#{Noosfero.identifier_format}/ | 125 | + match ':profile/edit_comment/:id/*page', :controller => 'content_viewer', :action => 'edit_comment', :profile => /#{Noosfero.identifier_format}/ |
128 | 126 | ||
129 | # match requests for profiles that don't have a custom domain | 127 | # match requests for profiles that don't have a custom domain |
130 | - map.homepage ':profile/*page', :controller => 'content_viewer', :action => 'view_page', :profile => /#{Noosfero.identifier_format}/, :conditions => { :if => lambda { |env| !Domain.hosting_profile_at(env[:host]) } } | 128 | + #FIXME probably this route is wrong |
129 | + match ':profile/*page', :controller => 'content_viewer', :action => 'view_page', :profile => /#{Noosfero.identifier_format}/, :conditions => { :if => lambda { |env| !Domain.hosting_profile_at(env[:host]) } } | ||
131 | 130 | ||
132 | 131 | ||
133 | # match requests for content in domains hosted for profiles | 132 | # match requests for content in domains hosted for profiles |
134 | - map.connect '*page', :controller => 'content_viewer', :action => 'view_page' | 133 | + match '*page', :controller => 'content_viewer', :action => 'view_page' |
135 | 134 | ||
136 | -end | 135 | -end |
136 | +end | ||
137 | \ No newline at end of file | 137 | \ No newline at end of file |
lib/noosfero/plugin/routes.rb
@@ -15,12 +15,12 @@ Dir.glob(File.join(Rails.root, plugins_root, '*', 'controllers')) do |controller | @@ -15,12 +15,12 @@ Dir.glob(File.join(Rails.root, plugins_root, '*', 'controllers')) do |controller | ||
15 | controllers_by_folder.each do |folder, controllers| | 15 | controllers_by_folder.each do |folder, controllers| |
16 | controllers.each do |controller| | 16 | controllers.each do |controller| |
17 | controller_name = controller.gsub("#{plugin_name}_plugin_",'') | 17 | controller_name = controller.gsub("#{plugin_name}_plugin_",'') |
18 | - map.connect "#{prefixes_by_folder[folder]}/#{plugin_name}/#{controller_name}/:action/:id", :controller => controller | 18 | + match "#{prefixes_by_folder[folder]}/#{plugin_name}/#{controller_name}/:action/:id", :controller => controller |
19 | end | 19 | end |
20 | end | 20 | end |
21 | 21 | ||
22 | - map.connect 'plugin/' + plugin_name + '/:action/:id', :controller => plugin_name + '_plugin' | ||
23 | - map.connect 'profile/:profile/plugin/' + plugin_name + '/:action/:id', :controller => plugin_name + '_plugin_profile' | ||
24 | - map.connect 'myprofile/:profile/plugin/' + plugin_name + '/:action/:id', :controller => plugin_name + '_plugin_myprofile' | ||
25 | - map.connect 'admin/plugin/' + plugin_name + '/:action/:id', :controller => plugin_name + '_plugin_admin' | 22 | + match 'plugin/' + plugin_name + '/:action/:id', :controller => plugin_name + '_plugin' |
23 | + match 'profile/:profile/plugin/' + plugin_name + '/:action/:id', :controller => plugin_name + '_plugin_profile' | ||
24 | + match 'myprofile/:profile/plugin/' + plugin_name + '/:action/:id', :controller => plugin_name + '_plugin_myprofile' | ||
25 | + match 'admin/plugin/' + plugin_name + '/:action/:id', :controller => plugin_name + '_plugin_admin' | ||
26 | end | 26 | end |