##// END OF EJS Templates
Routes cleanup....
Jean-Philippe Lang -
r10751:cf66561b1ef5
parent child
Show More
@@ -1,346 +1,341
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 RedmineApp::Application.routes.draw do
19 19 root :to => 'welcome#index', :as => 'home'
20 20
21 21 match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post]
22 22 match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post]
23 23 match 'account/register', :to => 'account#register', :via => [:get, :post], :as => 'register'
24 24 match 'account/lost_password', :to => 'account#lost_password', :via => [:get, :post], :as => 'lost_password'
25 25 match 'account/activate', :to => 'account#activate', :via => :get
26 26
27 27 match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news', :via => [:get, :post]
28 28 match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post]
29 29 match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post]
30 30 match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post]
31 31
32 32 match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post
33 33 match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post]
34 34
35 35 match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post]
36 36 get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message'
37 37 match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post]
38 38 get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
39 39
40 40 post 'boards/:board_id/topics/preview', :to => 'messages#preview'
41 41 post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply'
42 42 post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
43 43 post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy'
44 44
45 45 # Misc issue routes. TODO: move into resources
46 46 match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues'
47 47 match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu', :via => [:get, :post]
48 48 match '/issues/changes', :to => 'journals#index', :as => 'issue_changes', :via => :get
49 49 match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue'
50 50
51 51 match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get
52 52 match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post]
53 53
54 54 get '/projects/:project_id/issues/gantt', :to => 'gantts#show'
55 55 get '/issues/gantt', :to => 'gantts#show'
56 56
57 57 get '/projects/:project_id/issues/calendar', :to => 'calendars#show'
58 58 get '/issues/calendar', :to => 'calendars#show'
59 59
60 60 match 'projects/:id/issues/report', :to => 'reports#issue_report', :via => :get
61 61 match 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :via => :get
62 62
63 63 match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post]
64 64 match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]
65 65 match 'my/page', :controller => 'my', :action => 'page', :via => :get
66 66 match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page
67 67 match 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', :via => :post
68 68 match 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', :via => :post
69 69 match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post]
70 70 match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get
71 71 match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post
72 72 match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post
73 73 match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post
74 74
75 75 resources :users
76 76 match 'users/:id/memberships/:membership_id', :to => 'users#edit_membership', :via => :put, :as => 'user_membership'
77 77 match 'users/:id/memberships/:membership_id', :to => 'users#destroy_membership', :via => :delete
78 78 match 'users/:id/memberships', :to => 'users#edit_membership', :via => :post, :as => 'user_memberships'
79 79
80 80 match 'watchers/new', :controller=> 'watchers', :action => 'new', :via => :get
81 81 match 'watchers', :controller=> 'watchers', :action => 'create', :via => :post
82 82 match 'watchers/append', :controller=> 'watchers', :action => 'append', :via => :post
83 83 match 'watchers/destroy', :controller=> 'watchers', :action => 'destroy', :via => :post
84 84 match 'watchers/watch', :controller=> 'watchers', :action => 'watch', :via => :post
85 85 match 'watchers/unwatch', :controller=> 'watchers', :action => 'unwatch', :via => :post
86 86 match 'watchers/autocomplete_for_user', :controller=> 'watchers', :action => 'autocomplete_for_user', :via => :get
87 87
88 get 'projects/:id/settings/:tab', :to => "projects#settings"
89
90 88 resources :projects do
91 89 member do
92 get 'settings'
90 get 'settings(/:tab)', :action => 'settings', :as => 'settings'
93 91 post 'modules'
94 92 post 'archive'
95 93 post 'unarchive'
96 94 post 'close'
97 95 post 'reopen'
98 96 match 'copy', :via => [:get, :post]
99 97 end
100 98
101 99 resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
102 100 collection do
103 101 get 'autocomplete'
104 102 end
105 103 end
106 104
107 105 resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy]
108 106
109 107 get 'issues/:copy_from/copy', :to => 'issues#new'
110 108 resources :issues, :only => [:index, :new, :create] do
111 109 resources :time_entries, :controller => 'timelog' do
112 110 collection do
113 111 get 'report'
114 112 end
115 113 end
116 114 end
117 115 # issue form update
118 116 match 'issues/new', :controller => 'issues', :action => 'new', :via => [:put, :post], :as => 'issue_form'
119 117
120 118 resources :files, :only => [:index, :new, :create]
121 119
122 120 resources :versions, :except => [:index, :show, :edit, :update, :destroy] do
123 121 collection do
124 122 put 'close_completed'
125 123 end
126 124 end
127 125 get 'versions.:format', :to => 'versions#index'
128 126 get 'roadmap', :to => 'versions#index', :format => false
129 127 get 'versions', :to => 'versions#index'
130 128
131 129 resources :news, :except => [:show, :edit, :update, :destroy]
132 130 resources :time_entries, :controller => 'timelog' do
133 131 get 'report', :on => :collection
134 132 end
135 133 resources :queries, :only => [:new, :create]
136 134 resources :issue_categories, :shallow => true
137 135 resources :documents, :except => [:show, :edit, :update, :destroy]
138 136 resources :boards
139 137 resources :repositories, :shallow => true, :except => [:index, :show] do
140 138 member do
141 139 match 'committers', :via => [:get, :post]
142 140 end
143 141 end
144 142
145 143 match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
146 144 resources :wiki, :except => [:index, :new, :create] do
147 145 member do
148 146 get 'rename'
149 147 post 'rename'
150 148 get 'history'
151 149 get 'diff'
152 150 match 'preview', :via => [:post, :put]
153 151 post 'protect'
154 152 post 'add_attachment'
155 153 end
156 154 collection do
157 155 get 'export'
158 156 get 'date_index'
159 157 end
160 158 end
161 159 match 'wiki', :controller => 'wiki', :action => 'show', :via => :get
162 160 get 'wiki/:id/:version', :to => 'wiki#show'
163 161 delete 'wiki/:id/:version', :to => 'wiki#destroy_version'
164 162 get 'wiki/:id/:version/annotate', :to => 'wiki#annotate'
165 163 get 'wiki/:id/:version/diff', :to => 'wiki#diff'
166 164 end
167 165
168 166 resources :issues do
169 167 collection do
170 168 match 'bulk_edit', :via => [:get, :post]
171 169 post 'bulk_update'
172 170 end
173 171 resources :time_entries, :controller => 'timelog' do
174 172 collection do
175 173 get 'report'
176 174 end
177 175 end
178 176 resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
179 177 end
180 178 match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete
181 179
182 180 resources :queries, :except => [:show]
183 181
184 182 resources :news, :only => [:index, :show, :edit, :update, :destroy]
185 183 match '/news/:id/comments', :to => 'comments#create', :via => :post
186 184 match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete
187 185
188 186 resources :versions, :only => [:show, :edit, :update, :destroy] do
189 187 post 'status_by', :on => :member
190 188 end
191 189
192 190 resources :documents, :only => [:show, :edit, :update, :destroy] do
193 191 post 'add_attachment', :on => :member
194 192 end
195 193
196 194 match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu, :via => [:get, :post]
197 195
198 196 resources :time_entries, :controller => 'timelog', :except => :destroy do
199 197 collection do
200 198 get 'report'
201 199 get 'bulk_edit'
202 200 post 'bulk_update'
203 201 end
204 202 end
205 203 match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/
206 204 # TODO: delete /time_entries for bulk deletion
207 205 match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete
208 206
209 # TODO: port to be part of the resources route(s)
210 match 'projects/:id/settings/:tab', :to => 'projects#settings', :via => :get
211
212 207 get 'projects/:id/activity', :to => 'activities#index'
213 208 get 'projects/:id/activity.:format', :to => 'activities#index'
214 209 get 'activity', :to => 'activities#index'
215 210
216 211 # repositories routes
217 212 get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
218 213 get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
219 214
220 215 get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))',
221 216 :to => 'repositories#changes'
222 217
223 218 get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
224 219 get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
225 220 post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
226 221 delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
227 222 get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
228 223 get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))',
229 224 :controller => 'repositories',
230 225 :format => false,
231 226 :constraints => {
232 227 :action => /(browse|show|entry|raw|annotate|diff)/,
233 228 :rev => /[a-z0-9\.\-_]+/
234 229 }
235 230
236 231 get 'projects/:id/repository/statistics', :to => 'repositories#stats'
237 232 get 'projects/:id/repository/graph', :to => 'repositories#graph'
238 233
239 234 get 'projects/:id/repository/changes(/*path(.:ext))',
240 235 :to => 'repositories#changes'
241 236
242 237 get 'projects/:id/repository/revisions', :to => 'repositories#revisions'
243 238 get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision'
244 239 get 'projects/:id/repository/revision', :to => 'repositories#revision'
245 240 post 'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue'
246 241 delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
247 242 get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))',
248 243 :controller => 'repositories',
249 244 :format => false,
250 245 :constraints => {
251 246 :action => /(browse|show|entry|raw|annotate|diff)/,
252 247 :rev => /[a-z0-9\.\-_]+/
253 248 }
254 249 get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))',
255 250 :controller => 'repositories',
256 251 :action => /(browse|show|entry|raw|changes|annotate|diff)/
257 252 get 'projects/:id/repository/:action(/*path(.:ext))',
258 253 :controller => 'repositories',
259 254 :action => /(browse|show|entry|raw|changes|annotate|diff)/
260 255
261 256 get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
262 257 get 'projects/:id/repository', :to => 'repositories#show', :path => nil
263 258
264 259 # additional routes for having the file name at the end of url
265 260 match 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/, :via => :get
266 261 match 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/, :via => :get
267 262 match 'attachments/download/:id', :controller => 'attachments', :action => 'download', :id => /\d+/, :via => :get
268 263 match 'attachments/thumbnail/:id(/:size)', :controller => 'attachments', :action => 'thumbnail', :id => /\d+/, :via => :get, :size => /\d+/
269 264 resources :attachments, :only => [:show, :destroy]
270 265
271 266 resources :groups do
272 267 member do
273 268 get 'autocomplete_for_user'
274 269 end
275 270 end
276 271
277 272 match 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :via => :post, :as => 'group_users'
278 273 match 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :via => :delete, :as => 'group_user'
279 274 match 'groups/destroy_membership/:id', :controller => 'groups', :action => 'destroy_membership', :id => /\d+/, :via => :post
280 275 match 'groups/edit_membership/:id', :controller => 'groups', :action => 'edit_membership', :id => /\d+/, :via => :post
281 276
282 277 resources :trackers, :except => :show do
283 278 collection do
284 279 match 'fields', :via => [:get, :post]
285 280 end
286 281 end
287 282 resources :issue_statuses, :except => :show do
288 283 collection do
289 284 post 'update_issue_done_ratio'
290 285 end
291 286 end
292 287 resources :custom_fields, :except => :show
293 288 resources :roles do
294 289 collection do
295 290 match 'permissions', :via => [:get, :post]
296 291 end
297 292 end
298 293 resources :enumerations, :except => :show
299 294 match 'enumerations/:type', :to => 'enumerations#index', :via => :get
300 295
301 296 get 'projects/:id/search', :controller => 'search', :action => 'index'
302 297 get 'search', :controller => 'search', :action => 'index'
303 298
304 299 match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post
305 300
306 301 match 'admin', :controller => 'admin', :action => 'index', :via => :get
307 302 match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
308 303 match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
309 304 match 'admin/info', :controller => 'admin', :action => 'info', :via => :get
310 305 match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get
311 306 match 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :via => :post
312 307
313 308 resources :auth_sources do
314 309 member do
315 310 get 'test_connection', :as => 'try_connection'
316 311 end
317 312 end
318 313
319 314 match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
320 315 match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post]
321 316 match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post]
322 317 match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post]
323 318 match 'settings', :controller => 'settings', :action => 'index', :via => :get
324 319 match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post]
325 320 match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post]
326 321
327 322 match 'sys/projects', :to => 'sys#projects', :via => :get
328 323 match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post
329 324 match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => :get
330 325
331 326 match 'uploads', :to => 'attachments#upload', :via => :post
332 327
333 328 get 'robots.txt', :to => 'welcome#robots'
334 329
335 330 Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
336 331 file = File.join(plugin_dir, "config/routes.rb")
337 332 if File.exists?(file)
338 333 begin
339 334 instance_eval File.read(file)
340 335 rescue Exception => e
341 336 puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
342 337 exit 1
343 338 end
344 339 end
345 340 end
346 341 end
General Comments 0
You need to be logged in to leave comments. Login now