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 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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/account/destroy', :controller => 'my', :action => 'destroy',
  70. :conditions => {:method => [:get, :post]}
  71. map.connect 'my/page', :controller => 'my', :action => 'page',
  72. :conditions => {:method => :get}
  73. # Redirects to my/page
  74. map.connect 'my', :controller => 'my', :action => 'index',
  75. :conditions => {:method => :get}
  76. map.connect 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key',
  77. :conditions => {:method => :post}
  78. map.connect 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key',
  79. :conditions => {:method => :post}
  80. map.connect 'my/password', :controller => 'my', :action => 'password',
  81. :conditions => {:method => [:get, :post]}
  82. map.connect 'my/page_layout', :controller => 'my', :action => 'page_layout',
  83. :conditions => {:method => :get}
  84. map.connect 'my/add_block', :controller => 'my', :action => 'add_block',
  85. :conditions => {:method => :post}
  86. map.connect 'my/remove_block', :controller => 'my', :action => 'remove_block',
  87. :conditions => {:method => :post}
  88. map.connect 'my/order_blocks', :controller => 'my', :action => 'order_blocks',
  89. :conditions => {:method => :post}
  90. map.with_options :controller => 'users' do |users|
  91. users.user_membership 'users/:id/memberships/:membership_id',
  92. :action => 'edit_membership',
  93. :conditions => {:method => :put}
  94. users.connect 'users/:id/memberships/:membership_id',
  95. :action => 'destroy_membership',
  96. :conditions => {:method => :delete}
  97. users.user_memberships 'users/:id/memberships',
  98. :action => 'edit_membership',
  99. :conditions => {:method => :post}
  100. end
  101. map.resources :users
  102. # For nice "roadmap" in the url for the index action
  103. map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
  104. map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
  105. map.connect 'news/:id/comments', :controller => 'comments',
  106. :action => 'create', :conditions => {:method => :post}
  107. map.connect 'news/:id/comments/:comment_id', :controller => 'comments',
  108. :action => 'destroy', :conditions => {:method => :delete}
  109. map.connect 'watchers/new', :controller=> 'watchers', :action => 'new',
  110. :conditions => {:method => :get}
  111. map.connect 'watchers', :controller=> 'watchers', :action => 'create',
  112. :conditions => {:method => :post}
  113. map.connect 'watchers/append', :controller=> 'watchers', :action => 'append',
  114. :conditions => {:method => :post}
  115. map.connect 'watchers/destroy', :controller=> 'watchers', :action => 'destroy',
  116. :conditions => {:method => :post}
  117. map.connect 'watchers/watch', :controller=> 'watchers', :action => 'watch',
  118. :conditions => {:method => :post}
  119. map.connect 'watchers/unwatch', :controller=> 'watchers', :action => 'unwatch',
  120. :conditions => {:method => :post}
  121. map.connect 'watchers/autocomplete_for_user', :controller=> 'watchers', :action => 'autocomplete_for_user',
  122. :conditions => {:method => :get}
  123. # TODO: port to be part of the resources route(s)
  124. map.with_options :conditions => {:method => :get} do |project_views|
  125. project_views.connect 'projects/:id/settings/:tab',
  126. :controller => 'projects', :action => 'settings'
  127. project_views.connect 'projects/:project_id/issues/:copy_from/copy',
  128. :controller => 'issues', :action => 'new'
  129. end
  130. map.resources :projects, :member => {
  131. :copy => [:get, :post],
  132. :settings => :get,
  133. :modules => :post,
  134. :archive => :post,
  135. :unarchive => :post
  136. } do |project|
  137. project.resource :enumerations, :controller => 'project_enumerations',
  138. :only => [:update, :destroy]
  139. # issue form update
  140. project.issue_form 'issues/new', :controller => 'issues',
  141. :action => 'new', :conditions => {:method => [:post, :put]}
  142. project.resources :issues, :only => [:index, :new, :create] do |issues|
  143. issues.resources :time_entries, :controller => 'timelog',
  144. :collection => {:report => :get}
  145. end
  146. project.resources :files, :only => [:index, :new, :create]
  147. project.resources :versions, :shallow => true,
  148. :collection => {:close_completed => :put},
  149. :member => {:status_by => :post}
  150. project.resources :news, :shallow => true
  151. project.resources :time_entries, :controller => 'timelog',
  152. :collection => {:report => :get}
  153. project.resources :queries, :only => [:new, :create]
  154. project.resources :issue_categories, :shallow => true
  155. project.resources :documents, :shallow => true, :member => {:add_attachment => :post}
  156. project.resources :boards
  157. project.resources :repositories, :shallow => true, :except => [:index, :show],
  158. :member => {:committers => [:get, :post]}
  159. project.resources :memberships, :shallow => true, :controller => 'members',
  160. :only => [:index, :show, :create, :update, :destroy],
  161. :collection => {:autocomplete => :get}
  162. project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
  163. project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
  164. project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil
  165. project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
  166. project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
  167. project.resources :wiki, :except => [:new, :create], :member => {
  168. :rename => [:get, :post],
  169. :history => :get,
  170. :preview => :any,
  171. :protect => :post,
  172. :add_attachment => :post
  173. }, :collection => {
  174. :export => :get,
  175. :date_index => :get
  176. }
  177. end
  178. map.connect 'news', :controller => 'news', :action => 'index'
  179. map.connect 'news.:format', :controller => 'news', :action => 'index'
  180. map.resources :queries, :except => [:show]
  181. map.resources :issues,
  182. :collection => {:bulk_edit => [:get, :post], :bulk_update => :post} do |issues|
  183. issues.resources :time_entries, :controller => 'timelog',
  184. :collection => {:report => :get}
  185. issues.resources :relations, :shallow => true,
  186. :controller => 'issue_relations',
  187. :only => [:index, :show, :create, :destroy]
  188. end
  189. # Bulk deletion
  190. map.connect '/issues', :controller => 'issues', :action => 'destroy',
  191. :conditions => {:method => :delete}
  192. map.connect '/time_entries/destroy',
  193. :controller => 'timelog', :action => 'destroy',
  194. :conditions => { :method => :delete }
  195. map.time_entries_context_menu '/time_entries/context_menu',
  196. :controller => 'context_menus', :action => 'time_entries'
  197. map.resources :time_entries, :controller => 'timelog',
  198. :collection => {:report => :get, :bulk_edit => :get, :bulk_update => :post}
  199. map.with_options :controller => 'activities', :action => 'index',
  200. :conditions => {:method => :get} do |activity|
  201. activity.connect 'projects/:id/activity'
  202. activity.connect 'projects/:id/activity.:format'
  203. activity.connect 'activity', :id => nil
  204. activity.connect 'activity.:format', :id => nil
  205. end
  206. map.with_options :controller => 'repositories' do |repositories|
  207. repositories.with_options :conditions => {:method => :get} do |repository_views|
  208. repository_views.connect 'projects/:id/repository',
  209. :action => 'show'
  210. repository_views.connect 'projects/:id/repository/:repository_id/statistics',
  211. :action => 'stats'
  212. repository_views.connect 'projects/:id/repository/:repository_id/graph',
  213. :action => 'graph'
  214. repository_views.connect 'projects/:id/repository/statistics',
  215. :action => 'stats'
  216. repository_views.connect 'projects/:id/repository/graph',
  217. :action => 'graph'
  218. repository_views.connect 'projects/:id/repository/:repository_id/revisions',
  219. :action => 'revisions'
  220. repository_views.connect 'projects/:id/repository/:repository_id/revisions.:format',
  221. :action => 'revisions'
  222. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev',
  223. :action => 'revision'
  224. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues',
  225. :action => 'add_related_issue', :conditions => {:method => :post}
  226. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id',
  227. :action => 'remove_related_issue', :conditions => {:method => :delete}
  228. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff',
  229. :action => 'diff'
  230. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff.:format',
  231. :action => 'diff'
  232. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/raw/*path',
  233. :action => 'entry', :format => 'raw'
  234. repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/:action/*path',
  235. :requirements => {
  236. :action => /(browse|show|entry|changes|annotate|diff)/,
  237. :rev => /[a-z0-9\.\-_]+/
  238. }
  239. repository_views.connect 'projects/:id/repository/:repository_id/raw/*path',
  240. :action => 'entry', :format => 'raw'
  241. repository_views.connect 'projects/:id/repository/:repository_id/:action/*path',
  242. :requirements => { :action => /(browse|entry|changes|annotate|diff)/ }
  243. repository_views.connect 'projects/:id/repository/:repository_id/show/*path',
  244. :requirements => { :path => /.+/ }
  245. repository_views.connect 'projects/:id/repository/:repository_id/revision',
  246. :action => 'revision'
  247. repository_views.connect 'projects/:id/repository/revisions',
  248. :action => 'revisions'
  249. repository_views.connect 'projects/:id/repository/revisions.:format',
  250. :action => 'revisions'
  251. repository_views.connect 'projects/:id/repository/revisions/:rev',
  252. :action => 'revision'
  253. repository_views.connect 'projects/:id/repository/revisions/:rev/issues',
  254. :action => 'add_related_issue', :conditions => {:method => :post}
  255. repository_views.connect 'projects/:id/repository/revisions/:rev/issues/:issue_id',
  256. :action => 'remove_related_issue', :conditions => {:method => :delete}
  257. repository_views.connect 'projects/:id/repository/revisions/:rev/diff',
  258. :action => 'diff'
  259. repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format',
  260. :action => 'diff'
  261. repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path',
  262. :action => 'entry', :format => 'raw'
  263. repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path',
  264. :requirements => {
  265. :action => /(browse|show|entry|changes|annotate|diff)/,
  266. :rev => /[a-z0-9\.\-_]+/
  267. }
  268. repository_views.connect 'projects/:id/repository/raw/*path',
  269. :action => 'entry', :format => 'raw'
  270. repository_views.connect 'projects/:id/repository/:action/*path',
  271. :requirements => { :action => /(browse|show|entry|changes|annotate|diff)/ }
  272. repository_views.connect 'projects/:id/repository/revision',
  273. :action => 'revision'
  274. repository_views.connect 'projects/:id/repository/:repository_id',
  275. :action => 'show'
  276. end
  277. end
  278. # additional routes for having the file name at the end of url
  279. map.connect 'attachments/:id/:filename', :controller => 'attachments',
  280. :action => 'show', :id => /\d+/, :filename => /.*/,
  281. :conditions => {:method => :get}
  282. map.connect 'attachments/download/:id/:filename', :controller => 'attachments',
  283. :action => 'download', :id => /\d+/, :filename => /.*/,
  284. :conditions => {:method => :get}
  285. map.connect 'attachments/download/:id', :controller => 'attachments',
  286. :action => 'download', :id => /\d+/,
  287. :conditions => {:method => :get}
  288. map.resources :attachments, :only => [:show, :destroy]
  289. map.resources :groups, :member => {:autocomplete_for_user => :get}
  290. map.group_users 'groups/:id/users', :controller => 'groups',
  291. :action => 'add_users', :id => /\d+/,
  292. :conditions => {:method => :post}
  293. map.group_user 'groups/:id/users/:user_id', :controller => 'groups',
  294. :action => 'remove_user', :id => /\d+/,
  295. :conditions => {:method => :delete}
  296. map.connect 'groups/destroy_membership/:id', :controller => 'groups',
  297. :action => 'destroy_membership', :id => /\d+/,
  298. :conditions => {:method => :post}
  299. map.connect 'groups/edit_membership/:id', :controller => 'groups',
  300. :action => 'edit_membership', :id => /\d+/,
  301. :conditions => {:method => :post}
  302. map.resources :trackers, :except => :show
  303. map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post}
  304. map.resources :custom_fields, :except => :show
  305. map.resources :roles, :except => :show, :collection => {:permissions => [:get, :post]}
  306. map.resources :enumerations, :except => :show
  307. map.connect 'projects/:id/search', :controller => 'search', :action => 'index', :conditions => {:method => :get}
  308. map.connect 'search', :controller => 'search', :action => 'index', :conditions => {:method => :get}
  309. map.connect 'mail_handler', :controller => 'mail_handler',
  310. :action => 'index', :conditions => {:method => :post}
  311. map.connect 'admin', :controller => 'admin', :action => 'index',
  312. :conditions => {:method => :get}
  313. map.connect 'admin/projects', :controller => 'admin', :action => 'projects',
  314. :conditions => {:method => :get}
  315. map.connect 'admin/plugins', :controller => 'admin', :action => 'plugins',
  316. :conditions => {:method => :get}
  317. map.connect 'admin/info', :controller => 'admin', :action => 'info',
  318. :conditions => {:method => :get}
  319. map.connect 'admin/test_email', :controller => 'admin', :action => 'test_email',
  320. :conditions => {:method => :get}
  321. map.connect 'admin/default_configuration', :controller => 'admin',
  322. :action => 'default_configuration', :conditions => {:method => :post}
  323. map.resources :auth_sources, :member => {:test_connection => :get}
  324. map.connect 'workflows', :controller => 'workflows',
  325. :action => 'index', :conditions => {:method => :get}
  326. map.connect 'workflows/edit', :controller => 'workflows',
  327. :action => 'edit', :conditions => {:method => [:get, :post]}
  328. map.connect 'workflows/copy', :controller => 'workflows',
  329. :action => 'copy', :conditions => {:method => [:get, :post]}
  330. map.connect 'settings', :controller => 'settings',
  331. :action => 'index', :conditions => {:method => :get}
  332. map.connect 'settings/edit', :controller => 'settings',
  333. :action => 'edit', :conditions => {:method => [:get, :post]}
  334. map.connect 'settings/plugin/:id', :controller => 'settings',
  335. :action => 'plugin', :conditions => {:method => [:get, :post]}
  336. map.with_options :controller => 'sys' do |sys|
  337. sys.connect 'sys/projects.:format',
  338. :action => 'projects',
  339. :conditions => {:method => :get}
  340. sys.connect 'sys/projects/:id/repository.:format',
  341. :action => 'create_project_repository',
  342. :conditions => {:method => :post}
  343. sys.connect 'sys/fetch_changesets',
  344. :action => 'fetch_changesets',
  345. :conditions => {:method => :get}
  346. end
  347. map.connect 'uploads.:format', :controller => 'attachments', :action => 'upload', :conditions => {:method => :post}
  348. map.connect 'robots.txt', :controller => 'welcome',
  349. :action => 'robots', :conditions => {:method => :get}
  350. # Used for OpenID
  351. map.root :controller => 'account', :action => 'login'
  352. end