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

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