comparison config/routes.rb @ 1337:077b8890835a cannam

Merge from live branch
author Chris Cannam
date Thu, 20 Jun 2013 13:14:02 +0100
parents 9397280c138c
children 3db88d605fa7
comparison
equal deleted inserted replaced
1304:6137548ba453 1337:077b8890835a
1 ActionController::Routing::Routes.draw do |map| 1 # Redmine - project management software
2 # Add your own custom routes here. 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 # The priority is based upon order of creation: first created -> highest priority. 3 #
4 4 # This program is free software; you can redistribute it and/or
5 # Here's a sample route: 5 # modify it under the terms of the GNU General Public License
6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view' 6 # as published by the Free Software Foundation; either version 2
7 # Keep in mind you can assign values other than :controller and :action 7 # of the License, or (at your option) any later version.
8 8 #
9 map.home '', :controller => 'welcome' 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 map.signin 'login', :controller => 'account', :action => 'login' 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 map.signout 'logout', :controller => 'account', :action => 'logout' 12 # GNU General Public License for more details.
13 13 #
14 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow' 14 # You should have received a copy of the GNU General Public License
15 map.connect 'help/:ctrl/:page', :controller => 'help' 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 map.with_options :controller => 'time_entry_reports', :action => 'report',:conditions => {:method => :get} do |time_report| 17
18 time_report.connect 'projects/:project_id/issues/:issue_id/time_entries/report' 18 RedmineApp::Application.routes.draw do
19 time_report.connect 'projects/:project_id/issues/:issue_id/time_entries/report.:format' 19 root :to => 'welcome#index', :as => 'home'
20 time_report.connect 'projects/:project_id/time_entries/report' 20
21 time_report.connect 'projects/:project_id/time_entries/report.:format' 21 match 'login', :to => 'account#login', :as => 'signin'
22 time_report.connect 'time_entries/report' 22 match 'logout', :to => 'account#logout', :as => 'signout'
23 time_report.connect 'time_entries/report.:format' 23 match 'account/register', :to => 'account#register', :via => [:get, :post], :as => 'register'
24 end 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 map.bulk_edit_time_entry 'time_entries/bulk_edit', 26
27 :controller => 'timelog', :action => 'bulk_edit', :conditions => { :method => :get } 27 match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news'
28 map.bulk_update_time_entry 'time_entries/bulk_edit', 28 match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue'
29 :controller => 'timelog', :action => 'bulk_update', :conditions => { :method => :post } 29 match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue'
30 map.time_entries_context_menu '/time_entries/context_menu', 30 match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue'
31 :controller => 'context_menus', :action => 'time_entries' 31
32 # TODO: wasteful since this is also nested under issues, projects, and projects/issues 32 match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post
33 map.resources :time_entries, :controller => 'timelog' 33 match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post]
34 34
35 map.connect 'explore', :controller => 'projects', :action => 'explore' 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 map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} 37 match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post]
38 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get} 38 get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
39 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post} 39
40 40 post 'boards/:board_id/topics/preview', :to => 'messages#preview'
41 map.with_options :controller => 'messages' do |messages_routes| 41 post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply'
42 messages_routes.with_options :conditions => {:method => :get} do |messages_views| 42 post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
43 messages_views.connect 'boards/:board_id/topics/new', :action => 'new' 43 post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy'
44 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
45 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
46 end
47 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
48 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
49 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
50 messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
51 end
52 end
53
54 map.with_options :controller => 'boards' do |board_routes|
55 board_routes.with_options :conditions => {:method => :get} do |board_views|
56 board_views.connect 'projects/:project_id/boards', :action => 'index'
57 board_views.connect 'projects/:project_id/boards/new', :action => 'new'
58 board_views.connect 'projects/:project_id/boards/:id', :action => 'show'
59 board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show'
60 board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit'
61 end
62 board_routes.with_options :conditions => {:method => :post} do |board_actions|
63 board_actions.connect 'projects/:project_id/boards', :action => 'new'
64 board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/
65 end
66 end
67
68 map.with_options :controller => 'documents' do |document_routes|
69 document_routes.with_options :conditions => {:method => :get} do |document_views|
70 document_views.connect 'projects/:project_id/documents', :action => 'index'
71 document_views.connect 'projects/:project_id/documents/new', :action => 'new'
72 document_views.connect 'documents/:id', :action => 'show'
73 document_views.connect 'documents/:id/edit', :action => 'edit'
74 end
75 document_routes.with_options :conditions => {:method => :post} do |document_actions|
76 document_actions.connect 'projects/:project_id/documents', :action => 'new'
77 document_actions.connect 'documents/:id/:action', :action => /destroy|edit/
78 end
79 end
80
81 map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
82 map.resources :queries, :except => [:show]
83 44
84 # Misc issue routes. TODO: move into resources 45 # Misc issue routes. TODO: move into resources
85 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues', :conditions => { :method => :get } 46 match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues'
86 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview 47 match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu'
87 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues' 48 match '/issues/changes', :to => 'journals#index', :as => 'issue_changes'
88 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index' 49 match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue'
89 map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get } 50
90 map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post } 51 match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get
91 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post } 52 match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post]
92 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy 53
93 54 match '/projects/:project_id/issues/gantt', :to => 'gantts#show'
94 map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes| 55 match '/issues/gantt', :to => 'gantts#show'
95 gantts_routes.connect '/projects/:project_id/issues/gantt' 56
96 gantts_routes.connect '/projects/:project_id/issues/gantt.:format' 57 match '/projects/:project_id/issues/calendar', :to => 'calendars#show'
97 gantts_routes.connect '/issues/gantt.:format' 58 match '/issues/calendar', :to => 'calendars#show'
98 end 59
99 60 match 'projects/:id/issues/report', :to => 'reports#issue_report', :via => :get
100 map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes| 61 match 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :via => :get
101 calendars_routes.connect '/projects/:project_id/issues/calendar' 62
102 calendars_routes.connect '/issues/calendar' 63 match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post]
103 end 64 match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]
104 65 match 'my/page', :controller => 'my', :action => 'page', :via => :get
105 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports| 66 match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page
106 reports.connect 'projects/:id/issues/report', :action => 'issue_report' 67 match 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', :via => :post
107 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details' 68 match 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', :via => :post
108 end 69 match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post]
109 70 match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get
110 # Following two routes conflict with the resources because #index allows POST 71 match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post
111 map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post } 72 match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post
112 map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post } 73 match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post
113 74
114 map.resources :issues, :member => { :edit => :post }, :collection => {} do |issues| 75 resources :users
115 issues.resources :time_entries, :controller => 'timelog' 76 match 'users/:id/memberships/:membership_id', :to => 'users#edit_membership', :via => :put, :as => 'user_membership'
116 issues.resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy] 77 match 'users/:id/memberships/:membership_id', :to => 'users#destroy_membership', :via => :delete
117 end 78 match 'users/:id/memberships', :to => 'users#edit_membership', :via => :post, :as => 'user_memberships'
118 79
119 map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post } do |issues| 80 match 'watchers/new', :controller=> 'watchers', :action => 'new', :via => :get
120 issues.resources :time_entries, :controller => 'timelog' 81 match 'watchers', :controller=> 'watchers', :action => 'create', :via => :post
121 end 82 match 'watchers/append', :controller=> 'watchers', :action => 'append', :via => :post
122 83 match 'watchers/destroy', :controller=> 'watchers', :action => 'destroy', :via => :post
123 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new' 84 match 'watchers/watch', :controller=> 'watchers', :action => 'watch', :via => :post
124 85 match 'watchers/unwatch', :controller=> 'watchers', :action => 'unwatch', :via => :post
125 map.with_options :controller => 'users' do |users| 86 match 'watchers/autocomplete_for_user', :controller=> 'watchers', :action => 'autocomplete_for_user', :via => :get
126 users.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil, :conditions => {:method => :get} 87
127 88 match 'projects/:id/settings/:tab', :to => "projects#settings"
128 users.with_options :conditions => {:method => :post} do |user_actions| 89 match 'projects/:id/overview', :to => "projects#overview"
129 user_actions.connect 'users/:id/memberships', :action => 'edit_membership' 90
130 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership' 91 resources :projects do
131 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership' 92 member do
132 end 93 get 'settings'
133 end 94 post 'modules'
134 95 post 'archive'
135 map.resources :users, :member => { 96 post 'unarchive'
136 :edit_membership => :post, 97 post 'close'
137 :destroy_membership => :post 98 post 'reopen'
138 } 99 match 'copy', :via => [:get, :post]
139 100 end
140 # For nice "roadmap" in the url for the index action 101
141 map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index' 102 resources :members, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
142 103 collection do
143 map.all_news 'news', :controller => 'news', :action => 'index' 104 get 'autocomplete'
144 map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index' 105 end
145 map.preview_news '/news/preview', :controller => 'previews', :action => 'news' 106 end
146 map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post} 107 resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
147 map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete} 108 collection do
148 109 get 'autocomplete'
149 map.resources :projects, :member => { 110 end
150 :copy => [:get, :post], 111 end
151 :settings => :get, 112
152 :modules => :post, 113 resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy]
153 :overview => :post, 114
154 :archive => :post, 115 match 'issues/:copy_from/copy', :to => 'issues#new'
155 :unarchive => :post 116 resources :issues, :only => [:index, :new, :create] do
156 } do |project| 117 resources :time_entries, :controller => 'timelog' do
157 project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy] 118 collection do
158 project.resources :files, :only => [:index, :new, :create] 119 get 'report'
159 project.resources :versions, :shallow => true, :collection => {:close_completed => :put}, :member => {:status_by => :post} 120 end
160 project.resources :news, :shallow => true 121 end
161 project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id' 122 end
162 project.resources :queries, :only => [:new, :create] 123 # issue form update
163 project.resources :issue_categories, :shallow => true 124 match 'issues/new', :controller => 'issues', :action => 'new', :via => [:put, :post], :as => 'issue_form'
164 125
165 project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get} 126 resources :files, :only => [:index, :new, :create]
166 project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get} 127
167 project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil 128 resources :versions, :except => [:index, :show, :edit, :update, :destroy] do
168 project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff' 129 collection do
169 project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate' 130 put 'close_completed'
170 project.resources :wiki, :except => [:new, :create], :member => { 131 end
171 :rename => [:get, :post], 132 end
172 :history => :get, 133 match 'versions.:format', :to => 'versions#index'
173 :preview => :any, 134 match 'roadmap', :to => 'versions#index', :format => false
174 :protect => :post, 135 match 'versions', :to => 'versions#index'
175 :add_attachment => :post 136
176 }, :collection => { 137 resources :news, :except => [:show, :edit, :update, :destroy]
177 :export => :get, 138 resources :time_entries, :controller => 'timelog' do
178 :date_index => :get 139 get 'report', :on => :collection
179 } 140 end
180 141 resources :queries, :only => [:new, :create]
181 end 142 resources :issue_categories, :shallow => true
182 143 resources :documents, :except => [:show, :edit, :update, :destroy]
183 # Destroy uses a get request to prompt the user before the actual DELETE request 144 resources :boards
184 map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get} 145 resources :repositories, :shallow => true, :except => [:index, :show] do
146 member do
147 match 'committers', :via => [:get, :post]
148 end
149 end
150
151 match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
152 resources :wiki, :except => [:index, :new, :create] do
153 member do
154 get 'rename'
155 post 'rename'
156 get 'history'
157 get 'diff'
158 match 'preview', :via => [:post, :put]
159 post 'protect'
160 post 'add_attachment'
161 end
162 collection do
163 get 'export'
164 get 'date_index'
165 end
166 end
167 match 'wiki', :controller => 'wiki', :action => 'show', :via => :get
168 get 'wiki/:id/:version', :to => 'wiki#show'
169 delete 'wiki/:id/:version', :to => 'wiki#destroy_version'
170 get 'wiki/:id/:version/annotate', :to => 'wiki#annotate'
171 get 'wiki/:id/:version/diff', :to => 'wiki#diff'
172 end
173
174 resources :issues do
175 collection do
176 match 'bulk_edit', :via => [:get, :post]
177 post 'bulk_update'
178 end
179 resources :time_entries, :controller => 'timelog' do
180 collection do
181 get 'report'
182 end
183 end
184 resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
185 end
186 match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete
187
188 # changed this route to ensure compatibility with Rails 3 --lf.20130109
189 match 'explore' => 'projects#explore'
190
191 resources :queries, :except => [:show]
192
193 resources :news, :only => [:index, :show, :edit, :update, :destroy]
194 match '/news/:id/comments', :to => 'comments#create', :via => :post
195 match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete
196
197 resources :versions, :only => [:show, :edit, :update, :destroy] do
198 post 'status_by', :on => :member
199 end
200
201 resources :documents, :only => [:show, :edit, :update, :destroy] do
202 post 'add_attachment', :on => :member
203 end
204
205 match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu
206
207 resources :time_entries, :controller => 'timelog', :except => :destroy do
208 collection do
209 get 'report'
210 get 'bulk_edit'
211 post 'bulk_update'
212 end
213 end
214 match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/
215 # TODO: delete /time_entries for bulk deletion
216 match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete
185 217
186 # TODO: port to be part of the resources route(s) 218 # TODO: port to be part of the resources route(s)
187 map.with_options :controller => 'projects' do |project_mapper| 219 match 'projects/:id/settings/:tab', :to => 'projects#settings', :via => :get
188 project_mapper.with_options :conditions => {:method => :get} do |project_views| 220
189 project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings' 221 get 'projects/:id/activity', :to => 'activities#index'
190 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new' 222 get 'projects/:id/activity.:format', :to => 'activities#index'
191 end 223 get 'activity', :to => 'activities#index'
192 end 224
193 225 # repositories routes
194 map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity| 226 get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
195 activity.connect 'projects/:id/activity' 227 get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
196 activity.connect 'projects/:id/activity.:format' 228
197 activity.connect 'activity', :id => nil 229 get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))',
198 activity.connect 'activity.:format', :id => nil 230 :to => 'repositories#changes'
199 end 231
200 232 get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
201 map.with_options :controller => 'repositories' do |repositories| 233 get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
202 repositories.with_options :conditions => {:method => :get} do |repository_views| 234 post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
203 repository_views.connect 'projects/:id/repository', :action => 'show' 235 delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
204 repository_views.connect 'projects/:id/repository/edit', :action => 'edit' 236 get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
205 repository_views.connect 'projects/:id/repository/statistics', :action => 'stats' 237 get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))',
206 repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions' 238 :controller => 'repositories',
207 repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions' 239 :format => false,
208 repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision' 240 :constraints => {
209 repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff' 241 :action => /(browse|show|entry|raw|annotate|diff)/,
210 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff' 242 :rev => /[a-z0-9\.\-_]+/
211 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ } 243 }
212 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ } 244
213 repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw' 245 get 'projects/:id/repository/statistics', :to => 'repositories#stats'
214 # TODO: why the following route is required? 246 get 'projects/:id/repository/graph', :to => 'repositories#graph'
215 repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry' 247
216 repository_views.connect 'projects/:id/repository/:action/*path' 248 get 'projects/:id/repository/changes(/*path(.:ext))',
217 end 249 :to => 'repositories#changes'
218 250
219 repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post} 251 get 'projects/:id/repository/revisions', :to => 'repositories#revisions'
220 end 252 get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision'
221 253 get 'projects/:id/repository/revision', :to => 'repositories#revision'
222 map.resources :attachments, :only => [:show, :destroy] 254 post 'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue'
255 delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
256 get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))',
257 :controller => 'repositories',
258 :format => false,
259 :constraints => {
260 :action => /(browse|show|entry|raw|annotate|diff)/,
261 :rev => /[a-z0-9\.\-_]+/
262 }
263 get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))',
264 :controller => 'repositories',
265 :action => /(browse|show|entry|raw|changes|annotate|diff)/
266 get 'projects/:id/repository/:action(/*path(.:ext))',
267 :controller => 'repositories',
268 :action => /(browse|show|entry|raw|changes|annotate|diff)/
269
270 get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
271 get 'projects/:id/repository', :to => 'repositories#show', :path => nil
272
223 # additional routes for having the file name at the end of url 273 # additional routes for having the file name at the end of url
224 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ 274 match 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/, :via => :get
225 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ 275 match 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/, :via => :get
226 276 match 'attachments/download/:id', :controller => 'attachments', :action => 'download', :id => /\d+/, :via => :get
227 map.resources :groups, :member => {:autocomplete_for_user => :get} 277 match 'attachments/toggle_active/:id', :controller => 'attachments', :action => 'toggle_active', :id => /\d+/, :via => :get
228 map.group_users 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :conditions => {:method => :post} 278 match 'attachments/thumbnail/:id(/:size)', :controller => 'attachments', :action => 'thumbnail', :id => /\d+/, :via => :get, :size => /\d+/
229 map.group_user 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :conditions => {:method => :delete} 279 resources :attachments, :only => [:show, :destroy]
230 280
231 map.resources :trackers, :except => :show 281 resources :groups do
232 map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post} 282 member do
233 283 get 'autocomplete_for_user'
234 #left old routes at the bottom for backwards compat 284 end
235 map.connect 'projects/:project_id/issues/:action', :controller => 'issues' 285 end
236 map.connect 'projects/:project_id/members/:action', :controller => 'members' 286
237 map.connect 'projects/:project_id/documents/:action', :controller => 'documents' 287 match 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :via => :post, :as => 'group_users'
238 map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' 288 match 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :via => :delete, :as => 'group_user'
239 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' 289 match 'groups/destroy_membership/:id', :controller => 'groups', :action => 'destroy_membership', :id => /\d+/, :via => :post
240 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki' 290 match 'groups/edit_membership/:id', :controller => 'groups', :action => 'edit_membership', :id => /\d+/, :via => :post
241 map.connect 'projects/:project_id/news/:action', :controller => 'news' 291
242 map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/ 292 resources :trackers, :except => :show do
243 map.with_options :controller => 'repositories' do |omap| 293 collection do
244 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse' 294 match 'fields', :via => [:get, :post]
245 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes' 295 end
246 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff' 296 end
247 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry' 297 resources :issue_statuses, :except => :show do
248 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate' 298 collection do
249 omap.connect 'repositories/revision/:id/:rev', :action => 'revision' 299 post 'update_issue_done_ratio'
250 end 300 end
251 301 end
252 map.with_options :controller => 'sys' do |sys| 302 resources :custom_fields, :except => :show
253 sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get} 303 resources :roles do
254 sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post} 304 collection do
255 sys.connect 'sys/projects/:id/external_repository.:format', :action => 'get_external_repo_url', :conditions => {:method => :get} 305 match 'permissions', :via => [:get, :post]
256 sys.connect 'sys/projects/:id/embedded.:format', :action => 'set_embedded_active', :conditions => { :method => :post } 306 end
257 sys.connect 'sys/projects/:id/repository_cache.:format', :action => 'clear_repository_cache', :conditions => {:method => :post} 307 end
258 end 308 resources :enumerations, :except => :show
259 309 match 'enumerations/:type', :to => 'enumerations#index', :via => :get
260 # Install the default route as the lowest priority. 310
261 map.connect ':controller/:action/:id' 311 get 'projects/:id/search', :controller => 'search', :action => 'index'
262 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots' 312 get 'search', :controller => 'search', :action => 'index'
263 # Used for OpenID 313
264 map.root :controller => 'account', :action => 'login' 314 match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post
315
316 match 'admin', :controller => 'admin', :action => 'index', :via => :get
317 match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
318 match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
319 match 'admin/info', :controller => 'admin', :action => 'info', :via => :get
320 match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get
321 match 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :via => :post
322
323 resources :auth_sources do
324 member do
325 get 'test_connection'
326 end
327 end
328
329 match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
330 match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post]
331 match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post]
332 match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post]
333 match 'settings', :controller => 'settings', :action => 'index', :via => :get
334 match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post]
335 match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post]
336
337 match 'sys/projects', :to => 'sys#projects', :via => :get
338 match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post
339 match 'sys/projects/:id/embedded.:format', :controller => 'sys', :action => 'set_embedded_active', :conditions => { :method => :post }
340 match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => :get
341
342 match 'uploads', :to => 'attachments#upload', :via => :post
343
344 get 'robots.txt', :to => 'welcome#robots'
345
346 Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
347 file = File.join(plugin_dir, "config/routes.rb")
348 if File.exists?(file)
349 begin
350 instance_eval File.read(file)
351 rescue Exception => e
352 puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
353 exit 1
354 end
355 end
356 end
265 end 357 end