Commit fe6970675dffd912a793478cbfd8239b3f2f9140
1 parent
380faf7e
Exists in
master
and in
20 other branches
rails4: upgrade routes
Showing
2 changed files
with
61 additions
and
61 deletions
Show diff stats
config/routes.rb
... | ... | @@ -4,119 +4,119 @@ require 'environment_domain_constraint' |
4 | 4 | Noosfero::Application.routes.draw do |
5 | 5 | # The priority is based upon order of creation: first created -> highest priority. |
6 | 6 | # Sample of regular route: |
7 | - # map.connect 'products/:id', :controller => 'catalog', :action => 'view' | |
7 | + # map.connect 'products/:id', controller: 'catalog', action: 'view' | |
8 | 8 | # Keep in mind you can assign values other than :controller and :action |
9 | 9 | |
10 | 10 | # Sample of named route: |
11 | - # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' | |
12 | - # This route can be invoked with purchase_url(:id => product.id) | |
11 | + # map.purchase 'products/:id/purchase', controller: 'catalog', action: 'purchase' | |
12 | + # This route can be invoked with purchase_url(id: product.id) | |
13 | 13 | |
14 | 14 | ###################################################### |
15 | 15 | ## Public controllers |
16 | 16 | ###################################################### |
17 | 17 | |
18 | - match 'test/:controller(/:action(/:id))' , :controller => /.*test.*/ | |
18 | + match 'test/:controller(/:action(/:id))', controller: /.*test.*/, via: :all | |
19 | 19 | |
20 | 20 | # -- just remember to delete public/index.html. |
21 | 21 | # You can have the root of your site routed by hooking up '' |
22 | - root :to => 'home#index', :constraints => EnvironmentDomainConstraint.new | |
22 | + root to: 'home#index', constraints: EnvironmentDomainConstraint.new, via: :all | |
23 | 23 | |
24 | - match 'site(/:action)', :controller => 'home' | |
24 | + match 'site(/:action)', controller: 'home', via: :all | |
25 | 25 | |
26 | - match 'images(/*stuff)' => 'not_found#nothing' | |
27 | - match 'stylesheets(/*stuff)' => 'not_found#nothing' | |
28 | - match 'designs(/*stuff)' => 'not_found#nothing' | |
29 | - match 'articles(/*stuff)' => 'not_found#nothing' | |
30 | - match 'javascripts(/*stuff)' => 'not_found#nothing' | |
31 | - match 'thumbnails(/*stuff)' => 'not_found#nothing' | |
32 | - match 'user_themes(/*stuff)' => 'not_found#nothing' | |
26 | + match 'images(/*stuff)', to: 'not_found#nothing', via: :all | |
27 | + match 'stylesheets(/*stuff)', to: 'not_found#nothing', via: :all | |
28 | + match 'designs(/*stuff)', to: 'not_found#nothing', via: :all | |
29 | + match 'articles(/*stuff)', to: 'not_found#nothing', via: :all | |
30 | + match 'javascripts(/*stuff)', to: 'not_found#nothing', via: :all | |
31 | + match 'thumbnails(/*stuff)', to: 'not_found#nothing', via: :all | |
32 | + match 'user_themes(/*stuff)', to: 'not_found#nothing', via: :all | |
33 | 33 | |
34 | 34 | # embed controller |
35 | - match 'embed/:action/:id', :controller => 'embed', :id => /\d+/ | |
35 | + match 'embed/:action/:id', controller: 'embed', id: /\d+/, via: :all | |
36 | 36 | |
37 | 37 | # online documentation |
38 | - match 'doc' => 'doc#index', :as => :doc | |
39 | - match 'doc/:section' => 'doc#section', :as => :doc_section | |
40 | - match 'doc/:section/:topic' => 'doc#topic', :as => :doc_topic | |
38 | + match 'doc', to: 'doc#index', as: :doc, via: :all | |
39 | + match 'doc/:section', to: 'doc#section', as: :doc_section, via: :all | |
40 | + match 'doc/:section/:topic', to: 'doc#topic', as: :doc_topic, via: :all | |
41 | 41 | |
42 | 42 | # user account controller |
43 | - match 'account/new_password/:code' => 'account#new_password', :controller => 'account', :action => 'new_password' | |
44 | - match 'account(/:action)', :controller => 'account' | |
43 | + match 'account/new_password/:code', controller: 'account', action: 'new_password', via: :all | |
44 | + match 'account(/:action)', controller: 'account', via: :all | |
45 | 45 | |
46 | 46 | # enterprise registration |
47 | - match 'enterprise_registration(/:action)', :controller => 'enterprise_registration' | |
47 | + match 'enterprise_registration(/:action)', controller: 'enterprise_registration', via: :all | |
48 | 48 | |
49 | 49 | # tags |
50 | - match 'tag', :controller => 'search', :action => 'tags' | |
51 | - match 'tag/:tag', :controller => 'search', :action => 'tag', :tag => /.*/ | |
50 | + match 'tag', controller: 'search', action: 'tags', via: :all | |
51 | + match 'tag/:tag', controller: 'search', action: 'tag', tag: /.*/, via: :all | |
52 | 52 | |
53 | 53 | # categories index |
54 | - match 'cat/*category_path' => 'search#category_index', :as => :category | |
54 | + match 'cat/*category_path', to: 'search#category_index', as: :category, via: :all | |
55 | 55 | # search |
56 | - match 'search(/:action(/*category_path))', :controller => 'search' | |
56 | + match 'search(/:action(/*category_path))', controller: 'search', via: :all | |
57 | 57 | |
58 | 58 | # events |
59 | - match 'profile/:profile/events_by_day', :controller => 'events', :action => 'events_by_day', :profile => /#{Noosfero.identifier_format_in_url}/ | |
60 | - match 'profile/:profile/events_by_month', :controller => 'events', :action => 'events_by_month', :profile => /#{Noosfero.identifier_format_in_url}/ | |
61 | - match 'profile/:profile/events/:year/:month/:day', :controller => 'events', :action => 'events', :year => /\d*/, :month => /\d*/, :day => /\d*/, :profile => /#{Noosfero.identifier_format_in_url}/ | |
62 | - match 'profile/:profile/events/:year/:month', :controller => 'events', :action => 'events', :year => /\d*/, :month => /\d*/, :profile => /#{Noosfero.identifier_format_in_url}/ | |
63 | - match 'profile/:profile/events', :controller => 'events', :action => 'events', :profile => /#{Noosfero.identifier_format_in_url}/ | |
59 | + match 'profile/:profile/events_by_day', controller: 'events', action: 'events_by_day', profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
60 | + match 'profile/:profile/events_by_month', controller: 'events', action: 'events_by_month', profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
61 | + match 'profile/:profile/events/:year/:month/:day', controller: 'events', action: 'events', year: /\d*/, month: /\d*/, day: /\d*/, profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
62 | + match 'profile/:profile/events/:year/:month', controller: 'events', action: 'events', year: /\d*/, month: /\d*/, profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
63 | + match 'profile/:profile/events', controller: 'events', action: 'events', profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
64 | 64 | |
65 | 65 | # catalog |
66 | - match 'catalog/:profile', :controller => 'catalog', :action => 'index', :profile => /#{Noosfero.identifier_format_in_url}/, :as => :catalog | |
66 | + match 'catalog/:profile', controller: 'catalog', action: 'index', profile: /#{Noosfero.identifier_format_in_url}/, as: :catalog, via: :all | |
67 | 67 | |
68 | 68 | # invite |
69 | - match 'profile/:profile/invite/friends', :controller => 'invite', :action => 'invite_friends', :profile => /#{Noosfero.identifier_format_in_url}/ | |
70 | - match 'profile/:profile/invite/:action', :controller => 'invite', :profile => /#{Noosfero.identifier_format_in_url}/ | |
69 | + match 'profile/:profile/invite/friends', controller: 'invite', action: 'invite_friends', profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
70 | + match 'profile/:profile/invite/:action', controller: 'invite', profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
71 | 71 | |
72 | 72 | # feeds per tag |
73 | - match 'profile/:profile/tags/:id/feed', :controller => 'profile', :action =>'tag_feed', :id => /.+/, :profile => /#{Noosfero.identifier_format_in_url}/, :as => :tag_feed | |
73 | + match 'profile/:profile/tags/:id/feed', controller: 'profile', action:'tag_feed', id: /.+/, profile: /#{Noosfero.identifier_format_in_url}/, as: :tag_feed, via: :all | |
74 | 74 | |
75 | 75 | # profile tags |
76 | - match 'profile/:profile/tags/:id', :controller => 'profile', :action => 'content_tagged', :id => /.+/, :profile => /#{Noosfero.identifier_format_in_url}/ | |
77 | - match 'profile/:profile/tags(/:id)', :controller => 'profile', :action => 'tags', :profile => /#{Noosfero.identifier_format_in_url}/ | |
76 | + match 'profile/:profile/tags/:id', controller: 'profile', action: 'content_tagged', id: /.+/, profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
77 | + match 'profile/:profile/tags(/:id)', controller: 'profile', action: 'tags', profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
78 | 78 | |
79 | 79 | # profile search |
80 | - match 'profile/:profile/search', :controller => 'profile_search', :action => 'index', :profile => /#{Noosfero.identifier_format_in_url}/ | |
80 | + match 'profile/:profile/search', controller: 'profile_search', action: 'index', profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
81 | 81 | |
82 | 82 | # comments |
83 | - match 'profile/:profile/comment/:action/:id', :controller => 'comment', :profile => /#{Noosfero.identifier_format_in_url}/ | |
83 | + match 'profile/:profile/comment/:action/:id', controller: 'comment', profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
84 | 84 | |
85 | 85 | # public profile information |
86 | - match 'profile/:profile(/:action(/:id))', :controller => 'profile', :action => 'index', :id => /[^\/]*/, :profile => /#{Noosfero.identifier_format_in_url}/, :as => :profile | |
86 | + match 'profile/:profile(/:action(/:id))', controller: 'profile', action: 'index', id: /[^\/]*/, profile: /#{Noosfero.identifier_format_in_url}/, as: :profile, via: :all | |
87 | 87 | |
88 | 88 | # contact |
89 | - match 'contact/:profile/:action(/:id)', :controller => 'contact', :action => 'index', :id => /.*/, :profile => /#{Noosfero.identifier_format_in_url}/ | |
89 | + match 'contact/:profile/:action(/:id)', controller: 'contact', action: 'index', id: /.*/, profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
90 | 90 | |
91 | 91 | # map balloon |
92 | - match 'map_balloon/:action/:id', :controller => 'map_balloon', :id => /.*/ | |
92 | + match 'map_balloon/:action/:id', controller: 'map_balloon', id: /.*/, via: :all | |
93 | 93 | |
94 | 94 | # chat |
95 | - match 'chat(/:action(/:id))', :controller => 'chat' | |
95 | + match 'chat(/:action(/:id))', controller: 'chat', via: :all | |
96 | 96 | |
97 | 97 | ###################################################### |
98 | 98 | ## Controllers that are profile-specific (for profile admins ) |
99 | 99 | ###################################################### |
100 | 100 | # profile customization - "My profile" |
101 | - match 'myprofile/:profile', :controller => 'profile_editor', :action => 'index', :profile => /#{Noosfero.identifier_format_in_url}/ | |
102 | - match 'myprofile/:profile/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('my_profile'), :profile => /#{Noosfero.identifier_format_in_url}/, :as => :myprofile | |
101 | + match 'myprofile/:profile', controller: 'profile_editor', action: 'index', profile: /#{Noosfero.identifier_format_in_url}/, via: :all | |
102 | + match 'myprofile/:profile/:controller(/:action(/:id))', controller: Noosfero.pattern_for_controllers_in_directory('my_profile'), profile: /#{Noosfero.identifier_format_in_url}/, as: :myprofile, via: :all | |
103 | 103 | |
104 | 104 | |
105 | 105 | ###################################################### |
106 | 106 | ## Controllers that are used by environment admin |
107 | 107 | ###################################################### |
108 | 108 | # administrative tasks for a environment |
109 | - match 'admin', :controller => 'admin_panel', :action => :index | |
110 | - match 'admin/:controller(/:action((.:format)/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('admin') | |
111 | - match 'admin/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('admin') | |
109 | + match 'admin', controller: 'admin_panel', action: :index, via: :all | |
110 | + match 'admin/:controller(/:action((.:format)/:id))', controller: Noosfero.pattern_for_controllers_in_directory('admin'), via: :all | |
111 | + match 'admin/:controller(/:action(/:id))', controller: Noosfero.pattern_for_controllers_in_directory('admin'), via: :all | |
112 | 112 | |
113 | 113 | |
114 | 114 | ###################################################### |
115 | 115 | ## Controllers that are used by system admin |
116 | 116 | ###################################################### |
117 | 117 | # administrative tasks for a environment |
118 | - match 'system', :controller => 'system' | |
119 | - match 'system/:controller(/:action(/:id))', :controller => Noosfero.pattern_for_controllers_in_directory('system') | |
118 | + match 'system', controller: 'system', via: :all | |
119 | + match 'system/:controller(/:action(/:id))', controller: Noosfero.pattern_for_controllers_in_directory('system'), via: :all | |
120 | 120 | |
121 | 121 | ###################################################### |
122 | 122 | # plugin routes |
... | ... | @@ -125,19 +125,19 @@ Noosfero::Application.routes.draw do |
125 | 125 | eval(IO.read(plugins_routes), binding, plugins_routes) |
126 | 126 | |
127 | 127 | # cache stuff - hack |
128 | - match 'public/:action/:id', :controller => 'public' | |
128 | + match 'public/:action/:id', controller: 'public', via: :all | |
129 | 129 | |
130 | - match ':profile/*page/versions', :controller => 'content_viewer', :action => 'article_versions', :profile => /#{Noosfero.identifier_format_in_url}/, :constraints => EnvironmentDomainConstraint.new | |
131 | - match '*page/versions', :controller => 'content_viewer', :action => 'article_versions' | |
130 | + match ':profile/*page/versions', controller: 'content_viewer', action: 'article_versions', profile: /#{Noosfero.identifier_format_in_url}/, constraints: EnvironmentDomainConstraint.new, via: :all | |
131 | + match '*page/versions', controller: 'content_viewer', action: 'article_versions', via: :all | |
132 | 132 | |
133 | - match ':profile/*page/versions_diff', :controller => 'content_viewer', :action => 'versions_diff', :profile => /#{Noosfero.identifier_format_in_url}/, :constraints => EnvironmentDomainConstraint.new | |
134 | - match '*page/versions_diff', :controller => 'content_viewer', :action => 'versions_diff' | |
133 | + match ':profile/*page/versions_diff', controller: 'content_viewer', action: 'versions_diff', profile: /#{Noosfero.identifier_format_in_url}/, constraints: EnvironmentDomainConstraint.new, via: :all | |
134 | + match '*page/versions_diff', controller: 'content_viewer', action: 'versions_diff', via: :all | |
135 | 135 | |
136 | 136 | # match requests for profiles that don't have a custom domain |
137 | - match ':profile(/*page)', :controller => 'content_viewer', :action => 'view_page', :profile => /#{Noosfero.identifier_format_in_url}/, :constraints => EnvironmentDomainConstraint.new | |
137 | + match ':profile(/*page)', controller: 'content_viewer', action: 'view_page', profile: /#{Noosfero.identifier_format_in_url}/, constraints: EnvironmentDomainConstraint.new, via: :all | |
138 | 138 | |
139 | 139 | # match requests for content in domains hosted for profiles |
140 | - match '/(*page)', :controller => 'content_viewer', :action => 'view_page' | |
140 | + match '/(*page)', controller: 'content_viewer', action: 'view_page', via: :all | |
141 | 141 | |
142 | 142 | |
143 | 143 | end | ... | ... |
lib/noosfero/plugin/routes.rb
... | ... | @@ -19,15 +19,15 @@ Dir.glob(Rails.root.join(plugins_root, '*', 'controllers')) do |controllers_dir| |
19 | 19 | controllers.each do |controller| |
20 | 20 | controller_name = controller.gsub("#{plugin_name}_plugin_",'') |
21 | 21 | if %w[profile myprofile].include?(folder.to_s) |
22 | - match "#{prefixes_by_folder[folder]}/#{plugin_name}/#{controller_name}(/:action(/:id))", :controller => controller, :profile => /#{Noosfero.identifier_format}/ | |
22 | + match "#{prefixes_by_folder[folder]}/#{plugin_name}/#{controller_name}(/:action(/:id))", controller: controller, profile: /#{Noosfero.identifier_format}/, via: :all | |
23 | 23 | else |
24 | - match "#{prefixes_by_folder[folder]}/#{plugin_name}/#{controller_name}(/:action(/:id))", :controller => controller | |
24 | + match "#{prefixes_by_folder[folder]}/#{plugin_name}/#{controller_name}(/:action(/:id))", controller: controller, via: :all | |
25 | 25 | end |
26 | 26 | end |
27 | 27 | end |
28 | 28 | |
29 | - match 'plugin/' + plugin_name + '(/:action(/:id))', :controller => plugin_name + '_plugin' | |
30 | - match 'profile/:profile/plugin/' + plugin_name + '(/:action(/:id))', :controller => plugin_name + '_plugin_profile', :profile => /#{Noosfero.identifier_format}/ | |
31 | - match 'myprofile/:profile/plugin/' + plugin_name + '(/:action(/:id))', :controller => plugin_name + '_plugin_myprofile', :profile => /#{Noosfero.identifier_format}/ | |
32 | - match 'admin/plugin/' + plugin_name + '(/:action(/:id))', :controller => plugin_name + '_plugin_admin' | |
29 | + match 'plugin/' + plugin_name + '(/:action(/:id))', controller: plugin_name + '_plugin', via: :all | |
30 | + match 'profile/:profile/plugin/' + plugin_name + '(/:action(/:id))', controller: plugin_name + '_plugin_profile', profile: /#{Noosfero.identifier_format}/, via: :all | |
31 | + match 'myprofile/:profile/plugin/' + plugin_name + '(/:action(/:id))', controller: plugin_name + '_plugin_myprofile', profile: /#{Noosfero.identifier_format}/, via: :all | |
32 | + match 'admin/plugin/' + plugin_name + '(/:action(/:id))', controller: plugin_name + '_plugin_admin', via: :all | |
33 | 33 | end | ... | ... |