add setting for default file suffix#223
Conversation
|
Ready for review |
|
please keep in mind, that i am not familar with the nextcloud code and plugin development at all, i don't know if all the things i am writing here are possible/not possibe/completly wrong/has sideeffects/are already possible with this code/... please correct me if i am wrong. as far as i can see you implemented a setting for the extension which can be changed in the plugin settings page. which is very nice, but isn't this only a per user setting? in the issue #24 there was a lot of discussion about this topic:
often i read something like "saving the user from ..." but with this PR we don't save the user and leave the admin without an influence to that.
with this PR it looks for me we are only a part having what is really missing for me would to be able to configure the |
| // pass -1 because no file has id -1 and that will ensure | ||
| // to only return filenames that dont yet exist | ||
| $path = $this->generateFileName($folder, $title, "txt", -1); | ||
| $path = $this->generateFileName($folder, $title, $this->settings->get('fileSuffix'), -1); |
There was a problem hiding this comment.
why the change for fileSuffix instead of extension in all files?
There was a problem hiding this comment.
Is your comment about the naming? I chose fileSuffix because the value includes the dot. I wanted to have the dot included, because it's more generic and I think that displaying .md to the user is more helpful than displaying md.
| private $settings = [ | ||
| private $defaults = [ | ||
| "notesPath" => "Notes", | ||
| "fileSuffix" => ".txt", |
There was a problem hiding this comment.
please make this value globally changeable. this is the most important part of the issue your are fixing here.
maybe even configuring the notesPath globally would be nice.
There was a problem hiding this comment.
This PR is about a per user setting. I think that we should do a system-wide (admin) setting in a separate PR (if it is really needed).
| } | ||
| } | ||
| } else { | ||
| $settings = (object)$this->defaults; |
There was a problem hiding this comment.
i personally would prefer to have a real settings class here and call the constructor with the defaults array. typecasting here makes me have a bad feeling but as i don't know the coding standard in this project and in nextcloud i assume you can ignore this. for projects where i approve the PR i would probably request a change.
in gerneral i would use symfonys option resolver for handling all the settings https://symfony.com/doc/current/components/options_resolver.html
There was a problem hiding this comment.
We are not using symfony in this app, yet. Personally, I don't want to use another library just for this small thing. But please feel free to provide a PR with your proposed implementation.
There was a problem hiding this comment.
symfony is not only a full stack framework, its components can easily used in many projects but as i wrote, nothing i really thought you would change. i only try to be constructive.
|
This PR is about a per user setting. I think that we should do a system-wide (admin) setting in a separate PR (if it is really needed). What's your opinion on this, @jancborchardt ? |
|
This is absolutely a per-user setting. It should be none of the admins concern what the default file extension for Notes is. Everyone might use different systems and workflows. Also, the default should of course stay .txt while Windows still can’t really read .md by default. This is not a voting for which format we like better, but we need to stay compatible. :) |
|
@camilasan @stefan-niedermann and @nextcloud/notes can you review this too? :) |
jancborchardt
left a comment
There was a problem hiding this comment.
@korelstar I would only say to change it to "File extension for new notes" instead of "File suffix", because "File extension" is the term people use. :) Otherwise good from UX! :)
Also, the colon ":" can be removed from both of the settings, and there should ideally be some whitespace between the entries?
|
@jancborchardt I implemented your change requests and I added the confirm buttons, you requested in nextcloud/server#1068. Please review again ... |
|
Good stuff, looks great! Thanks for also adding the confirm function! :) (We could also think about not having the confirm for the file extension and simply applying when you switch.) |
Could we only think about this or should I remove the button? I have no opinion on this. You're the design boss. ;-) |
|
We can do this later, if needed. |
Hehe – ok then I will say it would be great to not have to confirm but simply apply when the select value is changed. :) |

fixes #24
txt,md)