You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

routes.rb 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. ActionController::Routing::Routes.draw do |map|
  2. # Add your own custom routes here.
  3. # The priority is based upon order of creation: first created -> highest priority.
  4. # Here's a sample route:
  5. # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  6. # Keep in mind you can assign values other than :controller and :action
  7. map.home '', :controller => 'welcome', :conditions => {:method => :get}
  8. map.signin 'login', :controller => 'account', :action => 'login',
  9. :conditions => {:method => [:get, :post]}
  10. map.signout 'logout', :controller => 'account', :action => 'logout',
  11. :conditions => {:method => :get}
  12. map.connect 'account/register', :controller => 'account', :action => 'register',
  13. :conditions => {:method => [:get, :post]}
  14. map.connect 'account/lost_password', :controller => 'account', :action => 'lost_password',
  15. :conditions => {:method => [:get, :post]}
  16. map.connect 'account/activate', :controller => 'account', :action => 'activate',
  17. :conditions => {:method => :get}
  18. map.connect 'projects/:id/wiki', :controller => 'wikis',
  19. :action => 'edit', :conditions => {:method => :post}
  20. map.connect 'projects/:id/wiki/destroy', :controller => 'wikis',
  21. :action => 'destroy', :conditions => {:method => [:get, :post]}
  22. map.with_options :controller => 'messages' do |messages_routes|
  23. messages_routes.with_options :conditions => {:method => :get} do |messages_views|
  24. messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
  25. messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
  26. messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
  27. end
  28. messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
  29. messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
  30. messages_actions.connect 'boards/:board_id/topics/preview', :action => 'preview'
  31. messages_actions.connect 'boards/:board_id/topics/quote/:id', :action => 'quote'
  32. messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
  33. messages_actions.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
  34. messages_actions.connect 'boards/:board_id/topics/:id/destroy', :action => 'destroy'
  35. end
  36. end
  37. # Misc issue routes. TODO: move into resources
  38. map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes',
  39. :action => 'issues', :conditions => { :method => :get }
  40. # TODO: would look nicer as /issues/:id/preview
  41. map.preview_new_issue '/issues/preview/new/:project_id', :controller => 'previews',
  42. :action => 'issue'
  43. map.preview_edit_issue '/issues/preview/edit/:id', :controller => 'previews',
  44. :action => 'issue'
  45. map.issues_context_menu '/issues/context_menu',
  46. :controller => 'context_menus', :action => 'issues'
  47. map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
  48. map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new',
  49. :id => /\d+/, :conditions => { :method => :post }
  50. map.connect '/journals/diff/:id', :controller => 'journals', :action => 'diff',
  51. :id => /\d+/, :conditions => { :method => :get }
  52. map.connect '/journals/edit/:id', :controller => 'journals', :action => 'edit',
  53. :id => /\d+/, :conditions => { :method => [:get, :post] }
  54. map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes|
  55. gantts_routes.connect '/projects/:project_id/issues/gantt'
  56. gantts_routes.connect '/projects/:project_id/issues/gantt.:format'
  57. gantts_routes.connect '/issues/gantt.:format'
  58. end
  59. map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes|
  60. calendars_routes.connect '/projects/:project_id/issues/calendar'
  61. calendars_routes.connect '/issues/calendar'
  62. end
  63. map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
  64. reports.connect 'projects/:id/issues/report', :action => 'issue_report'
  65. reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
  66. end
  67. map.connect 'my/account', :controller => 'my', :action => 'account',
  68. :conditions => {:method => [:get, :post]}
  69. map.connect 'my/page', :controller => 'my', :action => 'page',
  70. :conditions => {:method => :get}
  71. # Redirects to my/page
  72. map.connect 'my', :controller => 'my', :action => 'index',
  73. :conditions => {:method => :get}
  74. map.connect 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key',
  75. :conditions => {:method => :post}
  76. map.connect 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key',
  77. :conditions => {:method => :post}
  78. map.connect 'my/password', :controller => 'my', :action => 'password',
  79. :conditions => {:method => [:get, :post]}
  80. map.connect 'my/page_layout', :controller => 'my', :action => 'page_layout',
  81. :conditions => {:method => :get}
  82. map.connect 'my/add_block', :controller => 'my', :action => 'add_block',
  83. :conditions => {:method => :post}
  84. map.connect 'my/remove_block', :controller => 'my', :action => 'remove_block',
  85. :conditions => {:method => :post}
  86. map.connect 'my/order_blocks', :controller => 'my', :action => 'order_blocks',
  87. :conditions => {:method => :post}
  88. map.with_options :controller => 'users' do |users|
  89. users.user_membership 'users/:id/memberships/:membership_id',
  90. :action => 'edit_membership',
  91. :conditions => {:method => :put}
  92. users.connect 'users/:id/memberships/:membership_id',
  93. :action => 'destroy_membership',
  94. :conditions => {:method => :delete}
  95. users.user_memberships 'users/:id/memberships',
  96. :action => 'edit_membership',
  97. :conditions => {:method => :post}
  98. end
  99. map.resources :users
  100. # For nice "roadmap" in the url for the index action
  101. map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
  102. map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
  103. map.connect 'news/:id/comments', :controller => 'comments',
  104. :action => 'create', :conditions => {:method => :post}
  105. map.connect 'news/:id/comments/:comment_id', :controller => 'comments',
  106. :action => 'destroy', :conditions => {:method => :delete}
  107. map.connect 'watchers/new', :controller=> 'watchers', :action => 'new',
  108. :conditions => {:method => :get}
  109. map.connect 'watchers', :controller=> 'watchers', :action => 'create',
  110. :conditions => {:method => :post}
  111. map.connect 'watchers/destroy', :controller=> 'watchers', :action => 'destroy',
  112. :conditions => {:method => :post}
  113. map.connect 'watchers/watch', :controller=> 'watchers', :action => 'watch',
  114. :conditions => {:method => :post}
  115. map.connect 'watchers/unwatch', :controller=> 'watchers', :action => 'unwatch',
  116. :conditions => {:method => :post}
  117. map.connect 'watchers/autocomplete_for_user', :controller=> 'watchers', :action => 'autocomplete_for_user',
  118. :conditions => {:method => :get}
  119. # TODO: port to be part of the resources route(s)
  120. map.with_options :conditions => {:method => :get} do |project_views|
  121. project_views.connect 'projects/:id/settings/:tab',
  122. :controller => 'projects', :action => 'settings'
  123. project_views.connect 'projects/:project_id/issues/:copy_from/copy',
  124. :controller => 'issues', :action => 'new'
  125. end
  126. map.resources :projects, :member => {
  127. :copy => [:get, :post],
  128. :settings => :get,
  129. :modules => :post,
  130. :archive => :post,
  131. :unarchive => :post
  132. } do |project|
  133. project.resource :enumerations, :controller => 'project_enumerations',
  134. :only => [:update, :destroy]
  135. # issue form update
  136. project.issue_form 'issues/new', :controller => 'issues',
  137. :action => 'new', :conditions => {:method => [:post, :put]}
  138. project.resources :issues, :only => [:index, :new, :create] do |issues|
  139. issues.resources :time_entries, :controller => 'timelog',
  140. :collection => {:report => :get}
  141. end
  142. project.resources :files, :only => [:index, :new, :create]
  143. project.resources :versions, :shallow => true,
  144. :collection => {:close_completed => :put},
  145. :member => {:status_by => :post}
  146. project.resources :news, :shallow => true
  147. project.resources :time_entries, :controller => 'timelog',
  148. :collection => {:report => :get}
  149. project.resources :queries, :only => [:new, :create]
  150. project.resources :issue_categories, :shallow => true
  151. project.resources :documents, :shallow => true, :member => {:add_attachment => :post}
  152. project.resources :boards
  153. project.resources :repositories, :shallow => true, :except => [:index, :show],
  154. :member => {:committers => [:get, :post]}
  155. project.resources :memberships, :shallow => true, :controller => 'members',
  156. :only => [:index, :show, :create, :update, :destroy],
  157. :collection => {:autocomplete => :get}
  158. project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
  159. project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
  160. project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil
  161. project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
  162. project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
  163. project.resources :wiki, :except => [:new, :create], :member => {
  164. :rename => [:get, :post],
  165. :history => :get,
  166. :preview => :any,
  167. :protect => :post,
  168. :add_attachment => :post
  169. }, :collection => {
  170. :export => :get,
  171. :date_index => :get
  172. }
  173. end
  174. map.connect 'news', :controller => 'news', :action => 'index'
  175. map.connect 'news.:format', :controller => 'news', :action => 'index'
  176. map.resources :queries, :except => [:show]
  177. map.resources :issues,
  178. :collection => {:bulk_edit => [:get, :post], :bulk_update => :post} do |issues|
  179. issues.resources :time_entries, :controller => 'timelog',
  180. :collection => {:report => :get}
  181. issues.resources :relations, :shallow => true,
  182. :controller => 'issue_relations',
  183. :only => [:index, :show, :create, :destroy]
  184. end
  185. # Bulk deletion
  186. map.connect '/issues', :controller => 'issues', :action => 'destroy',
  187. :conditions => {:method => :delete}
  188. map.connect '/time_entries/destroy',
  189. :controller => 'timelog', :action => 'destroy',
  190. :conditions => { :method => :delete }
  191. map.time_entries_context_menu '/time_entries/context_menu',
  192. :controller => 'context_menus', :action => 'time_entries'
  193. map.resources :time_entries, :controller => 'timelog',
  194. :collection => {:report => :get, :bulk_edit => :get, :bulk_update => :post}
  195. map.with_options :controller => 'activities', :action => 'index',
  196. :conditions => {:method => :get} do |activity|
  197. activity.connect 'projects/:id/activity'
  198. activity.connect 'projects/:id/activity.:format'
  199. activity.connect 'activity', :id => nil
  200. activity.connect 'activity.:format', :id => nil
  201. end
  202. map.with_options :controller => 'repositories' do |repositories|
  203. repositories.with_options :conditions => {:method => :get} do |repository_views|
  204. repository_views.connect 'projects/:id/repository',
  205. :action => 'show'
  206. repository_views.connect 'projects/:id/repository/:repository_id/statistics',
  207. :action => 'stats'
  208. repository_views.connect 'projects/:id/repository/:repository_id/graph',
  209. :action => 'graph'
  210. repository_views.connect 'projects/:id/repository/statistics',
  211. :action => 'stats'
  212. repository_views.connect 'projects/:id/repository/graph',
  213. :action => 'graph'
  214. repository_views.connect 'projects/:id/repository/:repository_id/revisions',
  215. :action => 'revisions'
  216. repository_views.connect 'projects/:id/repository/:repository_id/revisions.:format',
  217. :action => 'revisions'
  218. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev',
  219. :action => 'revision'
  220. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues',
  221. :action => 'add_related_issue', :conditions => {:method => :post}
  222. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id',
  223. :action => 'remove_related_issue', :conditions => {:method => :delete}
  224. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff',
  225. :action => 'diff'
  226. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff.:format',
  227. :action => 'diff'
  228. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/raw/*path',
  229. :action => 'entry', :format => 'raw'
  230. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/:action/*path',
  231. :requirements => {
  232. :action => /(browse|show|entry|changes|annotate|diff)/,
  233. :rev => /[a-z0-9\.\-_]+/
  234. }
  235. repository_views.connect 'projects/:id/repository/:repository_id/raw/*path',
  236. :action => 'entry', :format => 'raw'
  237. repository_views.connect 'projects/:id/repository/:repository_id/:action/*path',
  238. :requirements => { :action => /(browse|show|entry|changes|annotate|diff)/ }
  239. repository_views.connect 'projects/:id/repository/revisions',
  240. :action => 'revisions'
  241. repository_views.connect 'projects/:id/repository/revisions.:format',
  242. :action => 'revisions'
  243. repository_views.connect 'projects/:id/repository/revisions/:rev',
  244. :action => 'revision'
  245. repository_views.connect 'projects/:id/repository/revisions/:rev/issues',
  246. :action => 'add_related_issue', :conditions => {:method => :post}
  247. repository_views.connect 'projects/:id/repository/revisions/:rev/issues/:issue_id',
  248. :action => 'remove_related_issue', :conditions => {:method => :delete}
  249. repository_views.connect 'projects/:id/repository/revisions/:rev/diff',
  250. :action => 'diff'
  251. repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format',
  252. :action => 'diff'
  253. repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path',
  254. :action => 'entry', :format => 'raw'
  255. repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path',
  256. :requirements => {
  257. :action => /(browse|show|entry|changes|annotate|diff)/,
  258. :rev => /[a-z0-9\.\-_]+/
  259. }
  260. repository_views.connect 'projects/:id/repository/raw/*path',
  261. :action => 'entry', :format => 'raw'
  262. repository_views.connect 'projects/:id/repository/:action/*path',
  263. :requirements => { :action => /(browse|show|entry|changes|annotate|diff)/ }
  264. repository_views.connect 'projects/:id/repository/:repository_id',
  265. :action => 'show'
  266. end
  267. repositories.connect 'projects/:id/repository/revision',
  268. :action => 'revision',
  269. :conditions => {:method => [:get, :post]}
  270. end
  271. # additional routes for having the file name at the end of url
  272. map.connect 'attachments/:id/:filename', :controller => 'attachments',
  273. :action => 'show', :id => /\d+/, :filename => /.*/,
  274. :conditions => {:method => :get}
  275. map.connect 'attachments/download/:id/:filename', :controller => 'attachments',
  276. :action => 'download', :id => /\d+/, :filename => /.*/,
  277. :conditions => {:method => :get}
  278. map.connect 'attachments/download/:id', :controller => 'attachments',
  279. :action => 'download', :id => /\d+/,
  280. :conditions => {:method => :get}
  281. map.resources :attachments, :only => [:show, :destroy]
  282. map.resources :groups, :member => {:autocomplete_for_user => :get}
  283. map.group_users 'groups/:id/users', :controller => 'groups',
  284. :action => 'add_users', :id => /\d+/,
  285. :conditions => {:method => :post}
  286. map.group_user 'groups/:id/users/:user_id', :controller => 'groups',
  287. :action => 'remove_user', :id => /\d+/,
  288. :conditions => {:method => :delete}
  289. map.connect 'groups/destroy_membership/:id', :controller => 'groups',
  290. :action => 'destroy_membership', :id => /\d+/,
  291. :conditions => {:method => :post}
  292. map.connect 'groups/edit_membership/:id', :controller => 'groups',
  293. :action => 'edit_membership', :id => /\d+/,
  294. :conditions => {:method => :post}
  295. map.resources :trackers, :except => :show
  296. map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post}
  297. map.resources :custom_fields, :except => :show
  298. map.resources :roles, :except => :show, :collection => {:permissions => [:get, :post]}
  299. map.resources :enumerations, :except => :show
  300. map.connect 'search', :controller => 'search', :action => 'index', :conditions => {:method => :get}
  301. map.connect 'mail_handler', :controller => 'mail_handler',
  302. :action => 'index', :conditions => {:method => :post}
  303. map.connect 'admin', :controller => 'admin', :action => 'index',
  304. :conditions => {:method => :get}
  305. map.connect 'admin/projects', :controller => 'admin', :action => 'projects',
  306. :conditions => {:method => :get}
  307. map.connect 'admin/plugins', :controller => 'admin', :action => 'plugins',
  308. :conditions => {:method => :get}
  309. map.connect 'admin/info', :controller => 'admin', :action => 'info',
  310. :conditions => {:method => :get}
  311. map.connect 'admin/test_email', :controller => 'admin', :action => 'test_email',
  312. :conditions => {:method => :get}
  313. map.connect 'admin/default_configuration', :controller => 'admin',
  314. :action => 'default_configuration', :conditions => {:method => :post}
  315. # Used by AuthSourcesControllerTest
  316. # TODO : refactor *AuthSourcesController to remove these routes
  317. map.connect 'auth_sources', :controller => 'auth_sources',
  318. :action => 'index', :conditions => {:method => :get}
  319. map.connect 'auth_sources/new', :controller => 'auth_sources',
  320. :action => 'new', :conditions => {:method => :get}
  321. map.connect 'auth_sources/create', :controller => 'auth_sources',
  322. :action => 'create', :conditions => {:method => :post}
  323. map.connect 'auth_sources/destroy/:id', :controller => 'auth_sources',
  324. :action => 'destroy', :id => /\d+/, :conditions => {:method => :post}
  325. map.connect 'auth_sources/test_connection/:id', :controller => 'auth_sources',
  326. :action => 'test_connection', :conditions => {:method => :get}
  327. map.connect 'auth_sources/edit/:id', :controller => 'auth_sources',
  328. :action => 'edit', :id => /\d+/, :conditions => {:method => :get}
  329. map.connect 'auth_sources/update/:id', :controller => 'auth_sources',
  330. :action => 'update', :id => /\d+/, :conditions => {:method => :post}
  331. map.connect 'ldap_auth_sources', :controller => 'ldap_auth_sources',
  332. :action => 'index', :conditions => {:method => :get}
  333. map.connect 'ldap_auth_sources/new', :controller => 'ldap_auth_sources',
  334. :action => 'new', :conditions => {:method => :get}
  335. map.connect 'ldap_auth_sources/create', :controller => 'ldap_auth_sources',
  336. :action => 'create', :conditions => {:method => :post}
  337. map.connect 'ldap_auth_sources/destroy/:id', :controller => 'ldap_auth_sources',
  338. :action => 'destroy', :id => /\d+/, :conditions => {:method => :post}
  339. map.connect 'ldap_auth_sources/test_connection/:id', :controller => 'ldap_auth_sources',
  340. :action => 'test_connection', :conditions => {:method => :get}
  341. map.connect 'ldap_auth_sources/edit/:id', :controller => 'ldap_auth_sources',
  342. :action => 'edit', :id => /\d+/, :conditions => {:method => :get}
  343. map.connect 'ldap_auth_sources/update/:id', :controller => 'ldap_auth_sources',
  344. :action => 'update', :id => /\d+/, :conditions => {:method => :post}
  345. map.connect 'workflows', :controller => 'workflows',
  346. :action => 'index', :conditions => {:method => :get}
  347. map.connect 'workflows/edit', :controller => 'workflows',
  348. :action => 'edit', :conditions => {:method => [:get, :post]}
  349. map.connect 'workflows/copy', :controller => 'workflows',
  350. :action => 'copy', :conditions => {:method => [:get, :post]}
  351. map.connect 'settings', :controller => 'settings',
  352. :action => 'index', :conditions => {:method => :get}
  353. map.connect 'settings/edit', :controller => 'settings',
  354. :action => 'edit', :conditions => {:method => [:get, :post]}
  355. map.connect 'settings/plugin/:id', :controller => 'settings',
  356. :action => 'plugin', :conditions => {:method => [:get, :post]}
  357. map.with_options :controller => 'sys' do |sys|
  358. sys.connect 'sys/projects.:format',
  359. :action => 'projects',
  360. :conditions => {:method => :get}
  361. sys.connect 'sys/projects/:id/repository.:format',
  362. :action => 'create_project_repository',
  363. :conditions => {:method => :post}
  364. sys.connect 'sys/fetch_changesets',
  365. :action => 'fetch_changesets',
  366. :conditions => {:method => :get}
  367. end
  368. map.connect 'robots.txt', :controller => 'welcome',
  369. :action => 'robots', :conditions => {:method => :get}
  370. # Used for OpenID
  371. map.root :controller => 'account', :action => 'login'
  372. end