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.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 @@