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

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