Testing how to develop an app
This commit is contained in:
parent
1984e55837
commit
a30a4f13ec
@ -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
|
||||
phpunit -c phpunit.integration.xml
|
||||
|
||||
https://github.com/nextcloud/nextcloud-vue
|
@ -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']
|
||||
]
|
||||
];
|
||||
|
34
js/script.js
34
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('<h2>'+response.statusText+'</h2><code>'+response.responseText+'</code>');
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
// if this function or object should be global, attach it to the namespace
|
||||
exports.myGlobalFunction = function(params) {
|
||||
return params;
|
||||
};
|
||||
*/
|
||||
})(window, jQuery, MyWiki);
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -1,32 +1,25 @@
|
||||
<?php
|
||||
namespace OCA\MyWiki\Helper;
|
||||
|
||||
use OCP\AppFramework\Files\Folder;
|
||||
use OCP\Files\IRootFolder;
|
||||
|
||||
class WikiHelper {
|
||||
public static function isFolder(int $folderId) :bool {
|
||||
$mount = \OC\Files\Filesystem::getMountsForFileId($folderId);
|
||||
/*
|
||||
isReadable()
|
||||
getById($folderId)
|
||||
isCreatable()
|
||||
isUpdateable()
|
||||
lock()
|
||||
|
||||
$config = new \OC\Config('config/');
|
||||
$base_path = $config->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
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\NotesTutorial\Migration;
|
||||
namespace OCA\MyWiki\Migration;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use OCP\Migration\IOutput;
|
||||
|
||||
class Version1400Date20181013124731 extends SimpleMigrationStep {
|
||||
class Version000000Date20220302210900 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
|
@ -10,20 +10,28 @@ use OCA\MyWiki\Db\Wiki;
|
||||
use OCA\MyWiki\Db\WikiMapper;
|
||||
use OCA\MyWiki\Helper\WikiHelper;
|
||||
|
||||
use \OCP\Files\Storage;
|
||||
use \OCP\Files\IRootFolder;
|
||||
|
||||
use \OCP\IUserSession;
|
||||
|
||||
class WikiService {
|
||||
|
||||
private $mapper;
|
||||
private $rootFolder;
|
||||
private $storage;
|
||||
private $userSession;
|
||||
|
||||
public function __construct(WikiMapper $mapper,IRootFolder $rootFolder){
|
||||
public function __construct(WikiMapper $mapper, IRootFolder $storage) {
|
||||
// , IUserSession $userSession ) {
|
||||
$this->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) {
|
||||
|
@ -1 +1,10 @@
|
||||
<h1>Hello world</h1>
|
||||
|
||||
<div id="emptycontent">
|
||||
<div>
|
||||
<button id="MyWiki-test">Test</button>
|
||||
</div>
|
||||
<div>
|
||||
<output></output>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
script('mywiki', 'script');
|
||||
style('mywiki', 'style');
|
||||
\OCP\Util::addScript('mywiki', 'script');
|
||||
\OCP\Util::addStyle('mywiki', 'style');
|
||||
?>
|
||||
|
||||
<div id="app">
|
||||
|
4
vendor/composer/installed.php
vendored
4
vendor/composer/installed.php
vendored
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user