Add ownnote-like folder support
Opened this issue · 14 comments
Before adding/changing code to support notes stored in folders I will use this issue for discussion & design.
Aim: provide support for storing notes in folders as is done in current ownnote
- One folder can be configured where notes are stored
- Group name is encoded in note name like "[GROUP-NAME] NOTE-NAME.htm"
Once this is achieved we can think about extending that into various directions (multiple groups, tags, ...).
Places that need changing:
main.php
: extend & store valid values for $folder
OCA\NextNote\Db\NextNoteMapper
: I can see two options how to do that
- Rename this to NextNoteDbMapper, add a OCA\NextNote\Folder\NextNoteFolderMapper, introduce a OCA\NextNote\NextNoteMapper that calls the Db and/or Folder Mapper based on configuration
- Move NextNoteMapper "one-up" and add logic for folder access into it as well
@brantje : Your preferences?
OCA\NextNote\ShareBackend\NextNoteShareBackend
: Not quite sure what to do with formatItems
My idea was to use a service, eg copy the NextNoteService to NextNoteFileService (and rename the NextNoteService
to eg NextNoteDBService
).
In the api controller we inject both NextNoteService
and NextNoteFileService
, then we get the config parameter for which service which we need to use, and assign it to the controller using $this->service
.
The NextNoteFileService
can use file ids, since it will go through the api first the NextNoteFileService
can load files by id.
That would mean, that we can't support current database-and-folder mode anymore. And it would be difficult to extend to e.g. any third method of storage we can come up with. Not that I have any clue about the benefits of database-and-folder mode - but before throwing it away we might ask @Fmstrat about why its there.
Thats why I thought about having some kind of OCA\NextNote\NextNoteMapper
that gets injected and knows which is the right mapper (or even sequence of mappers as for database-and-folder mode...) for the config.
As for file ids: we would need to create these on the fly such that they are a) unique and b) map to note name + group name (those are the primary keys for files...). The only good solution I could think of would be id = note name + group name but that probably has some issues.
@brantje Started to add "storagemode" to admin.php
. But I must confess I'm out of my depth trying to fill settings-admin.js
properly. Had a look at the old admin.js
but thats quit different...
@ThomasDaheim The only reason it's there is because DB mode was added after the fact. I would doubt too many users would care if they had to pick one or the other.
@Fmstrat Thanks for the info. So I would go ahead and don't make provisions for a database-and-folder mode. Besides the add. overhead to keep both in sync there doesn't seem to be a good reason to have it.
Only one caveat: Without database-and-folder mode its impossible to switch from database to folder storage without some admin migration tool. So if we don't have it in general we need to add functionality to the admin section.
Finally found some time to have a look at this again. See my branch folder-only.
Things I have run into:
- return a unique id for files from file system is difficult; currently I simply return a counter -> needs to be changed to e.g. hash?
- doing find, update, delete based on the counter from findNotesFromUser wouldn't work well
As for now the list of notes is returned by findNotesFromUser and shown. Need to work on the other functions but I'm stuck in debugging. Trying to edit a note never ends up in NextNoteApiController::get. Not sure where the problem is (most likely in front of the machine...).
OK, enough for today:
Working:
- findNotesFromUser
- find
- create
- update
- delete
TODO:
Saving notes as html in a folder is my number one request for this app. What is the status on this feature?
Otherwise nice work.
Kind regards
Lars
I fear that parrot is dead :-)
I have played around with it and have added folder support but I fear that this project isn't active anymore. Happy to be proven wrong!
For me this would be a more important feature than e.g. etag support. I'd rather spent some time here than e.g. on etag support (#70)
If you are still working on this, I'd be happy to help out.
Still on vacation :-) Will get to this once I'm back... Since I'm only using folders for notes I would definitely want to add this.
So, at least a sign of life :-)
After finishing converting my ownNoteEditor to use TinyMCE as well I would start looking back into folder mode for nextnote. Will let you know how far I manage to come with this.