routes.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  5. * @author Christoph Wurst <christoph@owncloud.com>
  6. * @author Christopher Schäpers <kondou@ts.unde.re>
  7. * @author Georg Ehrke <georg@owncloud.com>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Roeland Jago Douma <rullzer@owncloud.com>
  11. * @author Thomas Müller <thomas.mueller@tmit.eu>
  12. * @author Thomas Tanghus <thomas@tanghus.net>
  13. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  14. * @author Vincent Petry <pvince81@owncloud.com>
  15. *
  16. * @copyright Copyright (c) 2016, ownCloud, Inc.
  17. * @license AGPL-3.0
  18. *
  19. * This code is free software: you can redistribute it and/or modify
  20. * it under the terms of the GNU Affero General Public License, version 3,
  21. * as published by the Free Software Foundation.
  22. *
  23. * This program is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. * GNU Affero General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU Affero General Public License, version 3,
  29. * along with this program. If not, see <http://www.gnu.org/licenses/>
  30. *
  31. */
  32. use OC\Core\Application;
  33. $application = new Application();
  34. $application->registerRoutes($this, [
  35. 'routes' => [
  36. ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'],
  37. ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'],
  38. ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'],
  39. ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'],
  40. ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'],
  41. ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'],
  42. ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'],
  43. ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'],
  44. ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'],
  45. ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'],
  46. ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'],
  47. ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'],
  48. ['name' => 'token#generateToken', 'url' => '/token/generate', 'verb' => 'POST'],
  49. ['name' => 'occ#execute', 'url' => '/occ/{command}', 'verb' => 'POST'],
  50. ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'],
  51. ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'],
  52. ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'],
  53. ],
  54. ]);
  55. // Post installation check
  56. /** @var $this OCP\Route\IRouter */
  57. // Core ajax actions
  58. // Search
  59. $this->create('search_ajax_search', '/core/search')
  60. ->actionInclude('core/search/ajax/search.php');
  61. // AppConfig
  62. $this->create('core_ajax_appconfig', '/core/ajax/appconfig.php')
  63. ->actionInclude('core/ajax/appconfig.php');
  64. // Share
  65. $this->create('core_ajax_share', '/core/ajax/share.php')
  66. ->actionInclude('core/ajax/share.php');
  67. // Tags
  68. $this->create('core_tags_tags', '/tags/{type}')
  69. ->get()
  70. ->action('OC\Core\Tags\Controller', 'getTags')
  71. ->requirements(array('type'));
  72. $this->create('core_tags_favorites', '/tags/{type}/favorites')
  73. ->get()
  74. ->action('OC\Core\Tags\Controller', 'getFavorites')
  75. ->requirements(array('type'));
  76. $this->create('core_tags_ids_for_tag', '/tags/{type}/ids')
  77. ->get()
  78. ->action('OC\Core\Tags\Controller', 'getIdsForTag')
  79. ->requirements(array('type'));
  80. $this->create('core_tags_favorite', '/tags/{type}/favorite/{id}/')
  81. ->post()
  82. ->action('OC\Core\Tags\Controller', 'favorite')
  83. ->requirements(array('type', 'id'));
  84. $this->create('core_tags_unfavorite', '/tags/{type}/unfavorite/{id}/')
  85. ->post()
  86. ->action('OC\Core\Tags\Controller', 'unFavorite')
  87. ->requirements(array('type', 'id'));
  88. $this->create('core_tags_tag', '/tags/{type}/tag/{id}/')
  89. ->post()
  90. ->action('OC\Core\Tags\Controller', 'tagAs')
  91. ->requirements(array('type', 'id'));
  92. $this->create('core_tags_untag', '/tags/{type}/untag/{id}/')
  93. ->post()
  94. ->action('OC\Core\Tags\Controller', 'unTag')
  95. ->requirements(array('type', 'id'));
  96. $this->create('core_tags_add', '/tags/{type}/add')
  97. ->post()
  98. ->action('OC\Core\Tags\Controller', 'addTag')
  99. ->requirements(array('type'));
  100. $this->create('core_tags_delete', '/tags/{type}/delete')
  101. ->post()
  102. ->action('OC\Core\Tags\Controller', 'deleteTags')
  103. ->requirements(array('type'));
  104. // oC JS config
  105. $this->create('js_config', '/core/js/oc.js')
  106. ->actionInclude('core/js/config.php');
  107. // Routing
  108. $this->create('core_ajax_preview', '/core/preview')
  109. ->actionInclude('core/ajax/preview.php');
  110. $this->create('core_ajax_preview', '/core/preview.png')
  111. ->actionInclude('core/ajax/preview.php');
  112. $this->create('core_ajax_update', '/core/ajax/update.php')
  113. ->actionInclude('core/ajax/update.php');
  114. // File routes
  115. $this->create('files.viewcontroller.showFile', '/f/{fileId}')->action(function($urlParams) {
  116. $app = new \OCA\Files\AppInfo\Application($urlParams);
  117. $app->dispatch('ViewController', 'showFile');
  118. });
  119. // Sharing routes
  120. $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) {
  121. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  122. $app->dispatch('ShareController', 'showShare');
  123. });
  124. $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate')->post()->action(function($urlParams) {
  125. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  126. $app->dispatch('ShareController', 'authenticate');
  127. });
  128. $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate')->get()->action(function($urlParams) {
  129. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  130. $app->dispatch('ShareController', 'showAuthenticate');
  131. });
  132. $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) {
  133. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  134. $app->dispatch('ShareController', 'downloadShare');
  135. });
  136. // used for heartbeat
  137. $this->create('heartbeat', '/heartbeat')->action(function(){
  138. // do nothing
  139. });