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

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