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

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