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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2016 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. resources :journals, :only => [:edit, :update] do
  45. member do
  46. get 'diff'
  47. end
  48. end
  49. get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt'
  50. get '/issues/gantt', :to => 'gantts#show'
  51. get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar'
  52. get '/issues/calendar', :to => 'calendars#show'
  53. get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report'
  54. get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details'
  55. get '/issues/imports/new', :to => 'imports#new', :as => 'new_issues_import'
  56. post '/imports', :to => 'imports#create', :as => 'imports'
  57. get '/imports/:id', :to => 'imports#show', :as => 'import'
  58. match '/imports/:id/settings', :to => 'imports#settings', :via => [:get, :post], :as => 'import_settings'
  59. match '/imports/:id/mapping', :to => 'imports#mapping', :via => [:get, :post], :as => 'import_mapping'
  60. match '/imports/:id/run', :to => 'imports#run', :via => [:get, :post], :as => 'import_run'
  61. match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post]
  62. match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]
  63. match 'my/page', :controller => 'my', :action => 'page', :via => :get
  64. match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page
  65. get 'my/api_key', :to => 'my#show_api_key', :as => 'my_api_key'
  66. post 'my/api_key', :to => 'my#reset_api_key'
  67. post 'my/rss_key', :to => 'my#reset_rss_key', :as => 'my_rss_key'
  68. match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post]
  69. match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get
  70. match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post
  71. match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post
  72. match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post
  73. resources :users do
  74. resources :memberships, :controller => 'principal_memberships'
  75. resources :email_addresses, :only => [:index, :create, :update, :destroy]
  76. end
  77. post 'watchers/watch', :to => 'watchers#watch', :as => 'watch'
  78. delete 'watchers/watch', :to => 'watchers#unwatch'
  79. get 'watchers/new', :to => 'watchers#new', :as => 'new_watchers'
  80. post 'watchers', :to => 'watchers#create'
  81. post 'watchers/append', :to => 'watchers#append'
  82. delete 'watchers', :to => 'watchers#destroy'
  83. get 'watchers/autocomplete_for_user', :to => 'watchers#autocomplete_for_user'
  84. # Specific routes for issue watchers API
  85. post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue'
  86. delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue'
  87. resources :projects do
  88. member do
  89. get 'settings(/:tab)', :action => 'settings', :as => 'settings'
  90. post 'modules'
  91. post 'archive'
  92. post 'unarchive'
  93. post 'close'
  94. post 'reopen'
  95. match 'copy', :via => [:get, :post]
  96. end
  97. shallow do
  98. resources :memberships, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
  99. collection do
  100. get 'autocomplete'
  101. end
  102. end
  103. end
  104. resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy]
  105. get 'issues/:copy_from/copy', :to => 'issues#new', :as => 'copy_issue'
  106. resources :issues, :only => [:index, :new, :create]
  107. # Used when updating the form of a new issue
  108. post 'issues/new', :to => 'issues#new'
  109. resources :files, :only => [:index, :new, :create]
  110. resources :versions, :except => [:index, :show, :edit, :update, :destroy] do
  111. collection do
  112. put 'close_completed'
  113. end
  114. end
  115. get 'versions.:format', :to => 'versions#index'
  116. get 'roadmap', :to => 'versions#index', :format => false
  117. get 'versions', :to => 'versions#index'
  118. resources :news, :except => [:show, :edit, :update, :destroy]
  119. resources :time_entries, :controller => 'timelog', :except => [:show, :edit, :update, :destroy] do
  120. get 'report', :on => :collection
  121. end
  122. resources :queries, :only => [:new, :create]
  123. shallow do
  124. resources :issue_categories
  125. end
  126. resources :documents, :except => [:show, :edit, :update, :destroy]
  127. resources :boards
  128. shallow do
  129. resources :repositories, :except => [:index, :show] do
  130. member do
  131. match 'committers', :via => [:get, :post]
  132. end
  133. end
  134. end
  135. match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
  136. resources :wiki, :except => [:index, :create], :as => 'wiki_page' do
  137. member do
  138. get 'rename'
  139. post 'rename'
  140. get 'history'
  141. get 'diff'
  142. match 'preview', :via => [:post, :put, :patch]
  143. post 'protect'
  144. post 'add_attachment'
  145. end
  146. collection do
  147. get 'export'
  148. get 'date_index'
  149. post 'new'
  150. end
  151. end
  152. match 'wiki', :controller => 'wiki', :action => 'show', :via => :get
  153. get 'wiki/:id/:version', :to => 'wiki#show', :constraints => {:version => /\d+/}
  154. delete 'wiki/:id/:version', :to => 'wiki#destroy_version'
  155. get 'wiki/:id/:version/annotate', :to => 'wiki#annotate'
  156. get 'wiki/:id/:version/diff', :to => 'wiki#diff'
  157. end
  158. resources :issues do
  159. member do
  160. # Used when updating the form of an existing issue
  161. patch 'edit', :to => 'issues#edit'
  162. end
  163. collection do
  164. match 'bulk_edit', :via => [:get, :post]
  165. post 'bulk_update'
  166. end
  167. resources :time_entries, :controller => 'timelog', :only => [:new, :create]
  168. shallow do
  169. resources :relations, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
  170. end
  171. end
  172. # Used when updating the form of a new issue outside a project
  173. post '/issues/new', :to => 'issues#new'
  174. match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete
  175. resources :queries, :except => [:show]
  176. resources :news, :only => [:index, :show, :edit, :update, :destroy]
  177. match '/news/:id/comments', :to => 'comments#create', :via => :post
  178. match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete
  179. resources :versions, :only => [:show, :edit, :update, :destroy] do
  180. post 'status_by', :on => :member
  181. end
  182. resources :documents, :only => [:show, :edit, :update, :destroy] do
  183. post 'add_attachment', :on => :member
  184. end
  185. match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu, :via => [:get, :post]
  186. resources :time_entries, :controller => 'timelog', :except => :destroy do
  187. collection do
  188. get 'report'
  189. get 'bulk_edit'
  190. post 'bulk_update'
  191. end
  192. end
  193. match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/
  194. # TODO: delete /time_entries for bulk deletion
  195. match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete
  196. # Used to update the new time entry form
  197. post '/time_entries/new', :to => 'timelog#new'
  198. get 'projects/:id/activity', :to => 'activities#index', :as => :project_activity
  199. get 'activity', :to => 'activities#index'
  200. # repositories routes
  201. get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
  202. get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
  203. get 'projects/:id/repository/:repository_id/changes(/*path)',
  204. :to => 'repositories#changes',
  205. :format => false
  206. get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
  207. get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
  208. post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
  209. delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
  210. get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
  211. %w(browse show entry raw annotate diff).each do |action|
  212. get "projects/:id/repository/:repository_id/revisions/:rev/#{action}(/*path)",
  213. :controller => 'repositories',
  214. :action => action,
  215. :format => false,
  216. :constraints => {:rev => /[a-z0-9\.\-_]+/}
  217. end
  218. get 'projects/:id/repository/statistics', :to => 'repositories#stats'
  219. get 'projects/:id/repository/graph', :to => 'repositories#graph'
  220. get 'projects/:id/repository/changes(/*path)',
  221. :to => 'repositories#changes',
  222. :format => false
  223. get 'projects/:id/repository/revisions', :to => 'repositories#revisions'
  224. get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision'
  225. get 'projects/:id/repository/revision', :to => 'repositories#revision'
  226. post 'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue'
  227. delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
  228. %w(browse show entry raw annotate diff).each do |action|
  229. get "projects/:id/repository/revisions/:rev/#{action}(/*path)",
  230. :controller => 'repositories',
  231. :action => action,
  232. :format => false,
  233. :constraints => {:rev => /[a-z0-9\.\-_]+/}
  234. end
  235. %w(browse entry raw changes annotate diff).each do |action|
  236. get "projects/:id/repository/:repository_id/#{action}(/*path)",
  237. :controller => 'repositories',
  238. :action => action,
  239. :format => false
  240. end
  241. %w(browse entry raw changes annotate diff).each do |action|
  242. get "projects/:id/repository/#{action}(/*path)",
  243. :controller => 'repositories',
  244. :action => action,
  245. :format => false
  246. end
  247. get 'projects/:id/repository/:repository_id/show/*path', :to => 'repositories#show', :format => false
  248. get 'projects/:id/repository/show/*path', :to => 'repositories#show', :format => false
  249. get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
  250. get 'projects/:id/repository', :to => 'repositories#show', :path => nil
  251. # additional routes for having the file name at the end of url
  252. get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'
  253. get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
  254. get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
  255. get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
  256. resources :attachments, :only => [:show, :update, :destroy]
  257. get 'attachments/:object_type/:object_id/edit', :to => 'attachments#edit_all', :as => :object_attachments_edit
  258. patch 'attachments/:object_type/:object_id', :to => 'attachments#update_all', :as => :object_attachments
  259. resources :groups do
  260. resources :memberships, :controller => 'principal_memberships'
  261. member do
  262. get 'autocomplete_for_user'
  263. end
  264. end
  265. get 'groups/:id/users/new', :to => 'groups#new_users', :id => /\d+/, :as => 'new_group_users'
  266. post 'groups/:id/users', :to => 'groups#add_users', :id => /\d+/, :as => 'group_users'
  267. delete 'groups/:id/users/:user_id', :to => 'groups#remove_user', :id => /\d+/, :as => 'group_user'
  268. resources :trackers, :except => :show do
  269. collection do
  270. match 'fields', :via => [:get, :post]
  271. end
  272. end
  273. resources :issue_statuses, :except => :show do
  274. collection do
  275. post 'update_issue_done_ratio'
  276. end
  277. end
  278. resources :custom_fields, :except => :show do
  279. resources :enumerations, :controller => 'custom_field_enumerations', :except => [:show, :new, :edit]
  280. put 'enumerations', :to => 'custom_field_enumerations#update_each'
  281. end
  282. resources :roles do
  283. collection do
  284. match 'permissions', :via => [:get, :post]
  285. end
  286. end
  287. resources :enumerations, :except => :show
  288. match 'enumerations/:type', :to => 'enumerations#index', :via => :get
  289. get 'projects/:id/search', :controller => 'search', :action => 'index'
  290. get 'search', :controller => 'search', :action => 'index'
  291. get 'mail_handler', :to => 'mail_handler#new'
  292. post 'mail_handler', :to => 'mail_handler#index'
  293. get 'admin', :to => 'admin#index'
  294. get 'admin/projects', :to => 'admin#projects'
  295. get 'admin/plugins', :to => 'admin#plugins'
  296. get 'admin/info', :to => 'admin#info'
  297. post 'admin/test_email', :to => 'admin#test_email', :as => 'test_email'
  298. post 'admin/default_configuration', :to => 'admin#default_configuration'
  299. resources :auth_sources do
  300. member do
  301. get 'test_connection', :as => 'try_connection'
  302. end
  303. collection do
  304. get 'autocomplete_for_new_user'
  305. end
  306. end
  307. match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
  308. match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post]
  309. match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post]
  310. match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post]
  311. match 'settings', :controller => 'settings', :action => 'index', :via => :get
  312. match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post]
  313. match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post], :as => 'plugin_settings'
  314. match 'sys/projects', :to => 'sys#projects', :via => :get
  315. match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post
  316. match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => [:get, :post]
  317. match 'uploads', :to => 'attachments#upload', :via => :post
  318. get 'robots.txt', :to => 'welcome#robots'
  319. Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
  320. file = File.join(plugin_dir, "config/routes.rb")
  321. if File.exists?(file)
  322. begin
  323. instance_eval File.read(file)
  324. rescue Exception => e
  325. puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
  326. exit 1
  327. end
  328. end
  329. end
  330. end