Closed lwinch2006 closed 6 years ago
I have worked on that some time ago. Would need to re-add to the current version. But I would rather wait til v1.0 is out and add to this. Just be patient for a while longer ;-)
Hi there, Saving to file was removed during the rewrite. It will be added soon by @ThomasDaheim and me. I've updated the readme accordingly. Sorry for any inconvenience
Hello. This is great. Just take your time devs ;-). Meanwhile since saving to files is crucial for me since I need html notes synced to my mobile device. So I created a little hack that maybe would help to somebody else like me or maybe gave you an idea to implement some simple solution before a serious one.
Generally it does:
rootFolder
in NextNoteService
IRootFolder
that delivers root folder to the class. create()
function it creates respective file in hardcoded folder for my user.update()
function it checks if note name was changed and deletes file with old name if it is true. It also delete file if note is marked as deleted, otherwise just update content of the file.Sorry for poor PHP language syntax.
Code examples:
...
use OCP\Files\IRootFolder;
use OCP\Files\Folder;
...
class NextNoteService {
...
private $rootFolder;
...
public function __construct(NextNoteMapper $noteMapper, Utils $utils, NextNoteShareBackend $shareBackend, IRootFolder $rootFolder) {
...
$this->rootFolder = $rootFolder;
...
}
...
public function create($note, $userId) {
...
$folder = $this->rootFolder->get('/[user name]/files/HtmlNotes');
$newNoteName = $note->getName();
$fileName = $newNoteName . '.html';
if ($folder->nodeExists($fileName)) {
$file = $folder->get($fileName);
} else {
$file = $folder->newFile($fileName);
}
$file->putContent($note->getNote());
...
}
...
public function update($note) {
...
$oldNoteName = $entity->getName();
...
$folder = $this->rootFolder->get('/[user name]/files/HtmlNotes');
$newNoteName = $note->getName();
if (strtolower($oldNoteName) <> strtolower($newNoteName)) {
$fileName = $oldNoteName . '.html';
if ($folder->nodeExists($fileName)) {
$file = $folder->get($fileName);
$file->delete();
}
}
$fileName = $newNoteName . '.html';
if ($folder->nodeExists($fileName)) {
$file = $folder->get($fileName);
} else {
$file = $folder->newFile($fileName);
}
if ($note->getDeleted() == 0) {
$file->putContent($note->getNote());
} else {
$file->delete();
}
...
}
...
}
Like header says I have a small trouble with finding how to save note as html file to a folder. At least description in Readme.md says it is possible. (maybe it is enabled in separate branch
folder only
? I have installedmaster
branch at the moment)Another small thing is copy-paste from clipboard not working. Only works when open source code and copy-paste there directly.