##// END OF EJS Templates
Routes cleanup....
Jean-Philippe Lang -
r7909:77fc1132731d
parent child
Show More
@@ -1,212 +1,211
1 1 ActionController::Routing::Routes.draw do |map|
2 2 # Add your own custom routes here.
3 3 # The priority is based upon order of creation: first created -> highest priority.
4 4
5 5 # Here's a sample route:
6 6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
7 7 # Keep in mind you can assign values other than :controller and :action
8 8
9 9 map.home '', :controller => 'welcome'
10 10
11 11 map.signin 'login', :controller => 'account', :action => 'login'
12 12 map.signout 'logout', :controller => 'account', :action => 'logout'
13 13
14 14 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
15 15 map.connect 'help/:ctrl/:page', :controller => 'help'
16 16
17 17 map.time_entries_context_menu '/time_entries/context_menu',
18 18 :controller => 'context_menus', :action => 'time_entries'
19 19
20 20 map.resources :time_entries, :controller => 'timelog', :collection => {:report => :get, :bulk_edit => :get, :bulk_update => :post}
21 21
22 22 map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
23 23 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
24 24 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
25 25
26 26 map.with_options :controller => 'messages' do |messages_routes|
27 27 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
28 28 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
29 29 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
30 30 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
31 31 end
32 32 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
33 33 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
34 34 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
35 35 messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
36 36 end
37 37 end
38 38
39 39 map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
40 40 map.resources :queries, :except => [:show]
41 41
42 42 # Misc issue routes. TODO: move into resources
43 43 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
44 44 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview
45 45 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
46 46 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
47 47 map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get }
48 48 map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post }
49 49 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
50 50 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
51 51
52 52 map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes|
53 53 gantts_routes.connect '/projects/:project_id/issues/gantt'
54 54 gantts_routes.connect '/projects/:project_id/issues/gantt.:format'
55 55 gantts_routes.connect '/issues/gantt.:format'
56 56 end
57 57
58 58 map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes|
59 59 calendars_routes.connect '/projects/:project_id/issues/calendar'
60 60 calendars_routes.connect '/issues/calendar'
61 61 end
62 62
63 63 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
64 64 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
65 65 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
66 66 end
67 67
68 68 map.resources :issues do |issues|
69 69 issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get}
70 70 issues.resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
71 71 end
72 72
73 73 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
74 74
75 75 map.with_options :controller => 'users' do |users|
76 76 users.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil, :conditions => {:method => :get}
77 77
78 78 users.with_options :conditions => {:method => :post} do |user_actions|
79 79 user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
80 80 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
81 81 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
82 82 end
83 83 end
84 84
85 85 map.resources :users, :member => {
86 86 :edit_membership => :post,
87 87 :destroy_membership => :post
88 88 }
89 89
90 90 # For nice "roadmap" in the url for the index action
91 91 map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
92 92
93 93 map.all_news 'news', :controller => 'news', :action => 'index'
94 94 map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index'
95 95 map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
96 96 map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post}
97 97 map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete}
98 98
99 99 map.resources :projects, :member => {
100 100 :copy => [:get, :post],
101 101 :settings => :get,
102 102 :modules => :post,
103 103 :archive => :post,
104 104 :unarchive => :post
105 105 } do |project|
106 106 project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy]
107 107 project.resources :issues, :only => [:index, :new, :create] do |issues|
108 108 issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get}
109 109 end
110 110 project.resources :files, :only => [:index, :new, :create]
111 111 project.resources :versions, :shallow => true, :collection => {:close_completed => :put}, :member => {:status_by => :post}
112 112 project.resources :news, :shallow => true
113 113 project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id', :collection => {:report => :get}
114 114 project.resources :queries, :only => [:new, :create]
115 115 project.resources :issue_categories, :shallow => true
116 116 project.resources :documents, :shallow => true, :member => {:add_attachment => :post}
117 117 project.resources :boards
118 118
119 119 project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
120 120 project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
121 121 project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil
122 122 project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
123 123 project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
124 124 project.resources :wiki, :except => [:new, :create], :member => {
125 125 :rename => [:get, :post],
126 126 :history => :get,
127 127 :preview => :any,
128 128 :protect => :post,
129 129 :add_attachment => :post
130 130 }, :collection => {
131 131 :export => :get,
132 132 :date_index => :get
133 133 }
134 134
135 135 end
136 136
137 137 # Destroy uses a get request to prompt the user before the actual DELETE request
138 138 map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get}
139 139
140 140 # TODO: port to be part of the resources route(s)
141 141 map.with_options :controller => 'projects' do |project_mapper|
142 142 project_mapper.with_options :conditions => {:method => :get} do |project_views|
143 143 project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings'
144 144 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
145 145 end
146 146 end
147 147
148 148 map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
149 149 activity.connect 'projects/:id/activity'
150 150 activity.connect 'projects/:id/activity.:format'
151 151 activity.connect 'activity', :id => nil
152 152 activity.connect 'activity.:format', :id => nil
153 153 end
154 154
155 155 map.with_options :controller => 'repositories' do |repositories|
156 156 repositories.with_options :conditions => {:method => :get} do |repository_views|
157 157 repository_views.connect 'projects/:id/repository', :action => 'show'
158 158 repository_views.connect 'projects/:id/repository/edit', :action => 'edit'
159 159 repository_views.connect 'projects/:id/repository/statistics', :action => 'stats'
160 160 repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions'
161 161 repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
162 162 repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
163 163 repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
164 164 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
165 165 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
166 166 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
167 167 repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw'
168 168 # TODO: why the following route is required?
169 169 repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry'
170 170 repository_views.connect 'projects/:id/repository/:action/*path'
171 171 end
172 172
173 173 repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post}
174 174 end
175 175
176 176 map.resources :attachments, :only => [:show, :destroy]
177 177 # additional routes for having the file name at the end of url
178 178 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
179 179 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
180 180
181 181 map.resources :groups, :member => {:autocomplete_for_user => :get}
182 182 map.group_users 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :conditions => {:method => :post}
183 183 map.group_user 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :conditions => {:method => :delete}
184 184
185 185 map.resources :trackers, :except => :show
186 186 map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post}
187 187
188 188 #left old routes at the bottom for backwards compat
189 189 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
190 190 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
191 191 map.connect 'projects/:project_id/news/:action', :controller => 'news'
192 map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
193 192 map.with_options :controller => 'repositories' do |omap|
194 193 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
195 194 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
196 195 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
197 196 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
198 197 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
199 198 omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
200 199 end
201 200
202 201 map.with_options :controller => 'sys' do |sys|
203 202 sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get}
204 203 sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post}
205 204 end
206 205
207 206 # Install the default route as the lowest priority.
208 207 map.connect ':controller/:action/:id'
209 208 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
210 209 # Used for OpenID
211 210 map.root :controller => 'account', :action => 'login'
212 211 end
General Comments 0
You need to be logged in to leave comments. Login now