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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put, :patch]
  27. match '/preview/text', :to => 'previews#text', :as => 'preview_text', :via => [:get, :post, :put, :patch]
  28. match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post]
  29. match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message'
  30. get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message'
  31. match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post]
  32. get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
  33. post 'boards/:board_id/topics/preview', :to => 'messages#preview', :as => 'preview_board_message'
  34. post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply'
  35. post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
  36. post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy'
  37. # Misc issue routes. TODO: move into resources
  38. match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues'
  39. match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu', :via => [:get, :post]
  40. match '/issues/changes', :to => 'journals#index', :as => 'issue_changes', :via => :get
  41. match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue'
  42. resources :journals, :only => [:edit, :update] do
  43. member do
  44. get 'diff'
  45. end
  46. end
  47. get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt'
  48. get '/issues/gantt', :to => 'gantts#show'
  49. get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar'
  50. get '/issues/calendar', :to => 'calendars#show'
  51. get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report'
  52. get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details'
  53. get '/issues/imports/new', :to => 'imports#new', :as => 'new_issues_import'
  54. post '/imports', :to => 'imports#create', :as => 'imports'
  55. get '/imports/:id', :to => 'imports#show', :as => 'import'
  56. match '/imports/:id/settings', :to => 'imports#settings', :via => [:get, :post], :as => 'import_settings'
  57. match '/imports/:id/mapping', :to => 'imports#mapping', :via => [:get, :post], :as => 'import_mapping'
  58. match '/imports/:id/run', :to => 'imports#run', :via => [:get, :post], :as => 'import_run'
  59. match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post]
  60. match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]
  61. match 'my/page', :controller => 'my', :action => 'page', :via => :get
  62. post 'my/page', :to => 'my#update_page'
  63. match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page
  64. get 'my/api_key', :to => 'my#show_api_key', :as => 'my_api_key'
  65. post 'my/api_key', :to => 'my#reset_api_key'
  66. post 'my/rss_key', :to => 'my#reset_rss_key', :as => 'my_rss_key'
  67. match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post]
  68. match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post
  69. match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post
  70. match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post
  71. resources :users do
  72. resources :memberships, :controller => 'principal_memberships'
  73. resources :email_addresses, :only => [:index, :create, :update, :destroy]
  74. end
  75. post 'watchers/watch', :to => 'watchers#watch', :as => 'watch'
  76. delete 'watchers/watch', :to => 'watchers#unwatch'
  77. get 'watchers/new', :to => 'watchers#new', :as => 'new_watchers'
  78. post 'watchers', :to => 'watchers#create'
  79. post 'watchers/append', :to => 'watchers#append'
  80. delete 'watchers', :to => 'watchers#destroy'
  81. get 'watchers/autocomplete_for_user', :to => 'watchers#autocomplete_for_user'
  82. # Specific routes for issue watchers API
  83. post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue'
  84. delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue'
  85. resources :projects do
  86. collection do
  87. get 'autocomplete'
  88. end
  89. member do
  90. get 'settings(/:tab)', :action => 'settings', :as => 'settings'
  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' 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. get '/queries/filter', :to => 'queries#filter', :as => 'queries_filter'
  177. resources :news, :only => [:index, :show, :edit, :update, :destroy]
  178. match '/news/:id/comments', :to => 'comments#create', :via => :post
  179. match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete
  180. resources :versions, :only => [:show, :edit, :update, :destroy] do
  181. post 'status_by', :on => :member
  182. end
  183. resources :documents, :only => [:show, :edit, :update, :destroy] do
  184. post 'add_attachment', :on => :member
  185. end
  186. match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu, :via => [:get, :post]
  187. resources :time_entries, :controller => 'timelog', :except => :destroy do
  188. member do
  189. # Used when updating the edit form of an existing time entry
  190. patch 'edit', :to => 'timelog#edit'
  191. end
  192. collection do
  193. get 'report'
  194. get 'bulk_edit'
  195. post 'bulk_update'
  196. end
  197. end
  198. match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/
  199. # TODO: delete /time_entries for bulk deletion
  200. match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete
  201. # Used to update the new time entry form
  202. post '/time_entries/new', :to => 'timelog#new'
  203. # Used to update the bulk edit time entry form
  204. post '/time_entries/bulk_edit', :to => 'timelog#bulk_edit'
  205. get 'projects/:id/activity', :to => 'activities#index', :as => :project_activity
  206. get 'activity', :to => 'activities#index'
  207. # repositories routes
  208. get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
  209. get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
  210. get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
  211. get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
  212. post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
  213. delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
  214. get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
  215. %w(browse show entry raw annotate diff).each do |action|
  216. get "projects/:id/repository/:repository_id/revisions/:rev/#{action}(/*path)",
  217. :controller => 'repositories',
  218. :action => action,
  219. :format => 'html',
  220. :constraints => {:rev => /[a-z0-9\.\-_]+/, :path => /.*/}
  221. end
  222. %w(browse entry raw changes annotate diff).each do |action|
  223. get "projects/:id/repository/:repository_id/#{action}(/*path)",
  224. :controller => 'repositories',
  225. :action => action,
  226. :format => 'html',
  227. :constraints => {:path => /.*/}
  228. end
  229. get 'projects/:id/repository/:repository_id/show/*path', :to => 'repositories#show', :format => 'html', :constraints => {:path => /.*/}
  230. get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
  231. get 'projects/:id/repository', :to => 'repositories#show', :path => nil
  232. # additional routes for having the file name at the end of url
  233. get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment', :format => 'html'
  234. get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
  235. get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
  236. get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
  237. resources :attachments, :only => [:show, :update, :destroy]
  238. get 'attachments/:object_type/:object_id/edit', :to => 'attachments#edit_all', :as => :object_attachments_edit
  239. patch 'attachments/:object_type/:object_id', :to => 'attachments#update_all', :as => :object_attachments
  240. resources :groups do
  241. resources :memberships, :controller => 'principal_memberships'
  242. member do
  243. get 'autocomplete_for_user'
  244. end
  245. end
  246. get 'groups/:id/users/new', :to => 'groups#new_users', :id => /\d+/, :as => 'new_group_users'
  247. post 'groups/:id/users', :to => 'groups#add_users', :id => /\d+/, :as => 'group_users'
  248. delete 'groups/:id/users/:user_id', :to => 'groups#remove_user', :id => /\d+/, :as => 'group_user'
  249. resources :trackers, :except => :show do
  250. collection do
  251. match 'fields', :via => [:get, :post]
  252. end
  253. end
  254. resources :issue_statuses, :except => :show do
  255. collection do
  256. post 'update_issue_done_ratio'
  257. end
  258. end
  259. resources :custom_fields, :except => :show do
  260. resources :enumerations, :controller => 'custom_field_enumerations', :except => [:show, :new, :edit]
  261. put 'enumerations', :to => 'custom_field_enumerations#update_each'
  262. end
  263. resources :roles do
  264. collection do
  265. match 'permissions', :via => [:get, :post]
  266. end
  267. end
  268. resources :enumerations, :except => :show
  269. match 'enumerations/:type', :to => 'enumerations#index', :via => :get
  270. get 'projects/:id/search', :controller => 'search', :action => 'index'
  271. get 'search', :controller => 'search', :action => 'index'
  272. get 'mail_handler', :to => 'mail_handler#new'
  273. post 'mail_handler', :to => 'mail_handler#index'
  274. get 'admin', :to => 'admin#index'
  275. get 'admin/projects', :to => 'admin#projects'
  276. get 'admin/plugins', :to => 'admin#plugins'
  277. get 'admin/info', :to => 'admin#info'
  278. post 'admin/test_email', :to => 'admin#test_email', :as => 'test_email'
  279. post 'admin/default_configuration', :to => 'admin#default_configuration'
  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', :to => 'welcome#robots'
  300. Dir.glob File.expand_path("#{Redmine::Plugin.directory}/*") 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