diff --git a/README.md b/README.md index 0b61a4e..8a430d0 100644 --- a/README.md +++ b/README.md @@ -73,4 +73,6 @@ https://c.infdj.com/apps/files/?dir=/Documents/Manuals%20-%20Drivers/drivers/MAD https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/api.html -phpunit -c phpunit.integration.xml \ No newline at end of file +phpunit -c phpunit.integration.xml + +https://github.com/nextcloud/nextcloud-vue \ No newline at end of file diff --git a/appinfo/routes.php b/appinfo/routes.php index 1db0969..20e7aee 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -9,9 +9,11 @@ */ return [ 'resources' => [ - 'wiki' => ['url' => '/wiki'] + 'wiki' => ['url' => '/wikis'] ], 'routes' => [ - ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'] + ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'], + ['name' => 'page#test', 'url' => '/test', 'verb' => 'GET'], + ['name' => 'wiki#test', 'url' => '/wikis/test', 'verb' => 'GET'] ] ]; diff --git a/js/script.js b/js/script.js index e69de29..a3b437e 100644 --- a/js/script.js +++ b/js/script.js @@ -0,0 +1,34 @@ +var MyWiki = MyWiki || {}; + +(function(window, $, exports, undefined) { + 'use strict'; + + $('#MyWiki-test').on('click',test); + + function test() { + var baseUrl = OC.generateUrl('/apps/mywiki/wikis'); + $.ajax({ + url: baseUrl + '/test', + type: 'GET', + contentType: 'application/json' + }).done(function (response) { + // handle success + $('output').html(response); + }).fail(function (response, code) { + // handle failure + $('output').html('

'+response.statusText+'

'+response.responseText+''); + }); + } + +/* + // if this function or object should be global, attach it to the namespace + exports.myGlobalFunction = function(params) { + return params; + }; +*/ +})(window, jQuery, MyWiki); + + + + + diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index d9c4355..63131e4 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -28,4 +28,11 @@ class PageController extends Controller { return new TemplateResponse('mywiki', 'index'); // templates/index.php } + /** + * @NoAdminRequired + */ + public function test() { + return new DataResponse('JDG::Test'); + } + } diff --git a/lib/Controller/WikiController.php b/lib/Controller/WikiController.php index 989b36a..79fb3be 100644 --- a/lib/Controller/WikiController.php +++ b/lib/Controller/WikiController.php @@ -23,9 +23,15 @@ /** * @NoAdminRequired */ - public function index() { - return new DataResponse($this->service->test($this->userId)); + public function test() { + $x = $this->service->test($this->userId); + return new DataResponse(print_r($x,true)); + } + /** + * @NoAdminRequired + */ + public function index() { return new DataResponse($this->service->findAll($this->userId)); } diff --git a/lib/Helper/WikiHelper.php b/lib/Helper/WikiHelper.php index 350ebb1..87d09b9 100644 --- a/lib/Helper/WikiHelper.php +++ b/lib/Helper/WikiHelper.php @@ -1,32 +1,25 @@ getValue('datadirectory') - -datadirectory is the key in the array defined in config.php that contains the base directory. - -$basepath now contains a path like /var/www/html/nextcloud/data. - */ - // ToDo - $nodes = \OC\Files\Node\Folder::getById($folderId); - - return true; + public static function isFolder(IRootFolder $storage, int $folderId) :bool { + $nodes = $storage->getById($folderId); + if ( count($nodes)>0 ) { + return $nodes[0]->getType() == \OCP\Files\Node::TYPE_FOLDER; + } + return false; } - public static function isWiki(int $folderId) :bool { - return \OC\Files\Filesystem::nodeExists('.wiki'); + public static function isWiki(IRootFolder $storage, int $folderId) :string { + $nodes = $storage->getById($folderId); + if ( count($nodes)>0 ) { + $nodeStorage = $nodes[0]->getStorage(); + return $nodeStorage->file_get_contents('/wiki.yaml'); + // getPath() + // getStorage() + } + return false; } public static function initWiki(int $folderId, string $title) :bool { // ToDo diff --git a/lib/Migration/Version000000Date20220302210900.php b/lib/Migration/Version000000Date20220302210900.php index acc3a57..17b60a9 100644 --- a/lib/Migration/Version000000Date20220302210900.php +++ b/lib/Migration/Version000000Date20220302210900.php @@ -1,13 +1,13 @@ mapper = $mapper; - $this->rootFolder = $rootFolder; + // $this->userSession = $userSession; + $this->storage = $storage; // , IUserSession $userSession } public function test(string $userId) { - echo 'JDG :: Test for '.$userId; + return WikiHelper::isWiki($this->storage, 208); } public function findAll(string $userId) { diff --git a/templates/content/index.php b/templates/content/index.php index 159202e..278ecf8 100644 --- a/templates/content/index.php +++ b/templates/content/index.php @@ -1 +1,10 @@

Hello world

+ +
+
+ +
+
+ +
+
diff --git a/templates/index.php b/templates/index.php index 0b43197..12ac33e 100644 --- a/templates/index.php +++ b/templates/index.php @@ -1,6 +1,6 @@
diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 4566a54..1085eb6 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '9254fe2d3d9dba572f9f5e831eda5f0896e82e3e', + 'reference' => '1984e55837df92230d61b2bce1fcf2e08e2ec4a9', 'name' => 'jdg/mywiki', 'dev' => true, ), @@ -25,7 +25,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '9254fe2d3d9dba572f9f5e831eda5f0896e82e3e', + 'reference' => '1984e55837df92230d61b2bce1fcf2e08e2ec4a9', 'dev_requirement' => false, ), 'myclabs/deep-copy' => array(