diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-03-18 19:15:31 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-18 19:15:31 +0300 |
commit | 66adbbbe655ef62f1545a39c2bf31630455af8da (patch) | |
tree | 3d0343166617e728f41e37ede2a1dc5983e1d8c8 /lib |
Add basic app structure
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AppInfo/Application.php | 25 | ||||
-rw-r--r-- | lib/Controller/NavigationController.php | 23 | ||||
-rw-r--r-- | lib/Controller/SessionController.php | 65 |
3 files changed, 113 insertions, 0 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php new file mode 100644 index 000000000..acb422b35 --- /dev/null +++ b/lib/AppInfo/Application.php @@ -0,0 +1,25 @@ +<?php +declare(strict_types=1); + +namespace OCA\Text\AppInfo; + +use OCP\AppFramework\App; + + +class Application extends App { + + + const APP_NAME = 'text'; + + + /** + * Application constructor. + * + * @param array $params + */ + public function __construct(array $params = []) { + parent::__construct(self::APP_NAME, $params); + } + +} + diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php new file mode 100644 index 000000000..0947097d3 --- /dev/null +++ b/lib/Controller/NavigationController.php @@ -0,0 +1,23 @@ +<?php +declare(strict_types=1); + +namespace OCA\Text\Controller; + +use OCA\Text\AppInfo\Application; +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\TemplateResponse; + +class NavigationController extends Controller { + + /** + * + * @NoCSRFRequired + * @NoAdminRequired + * + * @return TemplateResponse + */ + public function navigate(): TemplateResponse { + return new TemplateResponse(Application::APP_NAME, 'main'); + } + +} diff --git a/lib/Controller/SessionController.php b/lib/Controller/SessionController.php new file mode 100644 index 000000000..0ce4c1e03 --- /dev/null +++ b/lib/Controller/SessionController.php @@ -0,0 +1,65 @@ +<?php +declare(strict_types=1); + + +namespace OCA\Text\Controller; + +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\Http\FileDisplayResponse; +use OCP\Files\IRootFolder; +use OCP\ICacheFactory; +use OCP\IRequest; +use OCP\ITempManager; +use OCP\Security\ISecureRandom; + +class SessionController extends Controller { + + + private $userId; + private $secureRandom; + + public function __construct(string $appName, IRequest $request, ICacheFactory $cacheFactory, ITempManager $tempManager, $userId, IRootFolder $rootFolder, ISecureRandom $secureRandom) { + parent::__construct($appName, $request); + + $this->userId = $userId; + $this->file = $rootFolder->get('example.md'); + $this->secureRandom = $secureRandom; + } + + /** + * @NoCSRFRequired + * @NoAdminRequired + */ + public function init() { + $sessionId = $this->secureRandom->generate(32, ISecureRandom::CHAR_DIGITS); + $token = $this->secureRandom->generate(32); + // save session to database + // return session details + } + + /** + * @NoCSRFRequired + * @NoAdminRequired + */ + public function push($transaction): DataResponse { + return new DataResponse([]); + } + + /** + * @NoCSRFRequired + * @NoAdminRequired + */ + public function get() { + return new FileDisplayResponse($this->file); + } + + /** + * @NoCSRFRequired + * @NoAdminRequired + */ + public function sync($transaction): DataResponse { + return new DataResponse([]); + } + +} |