Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[License Accepting Required] Custom filenames #885

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

justinsilvestre
Copy link

@justinsilvestre justinsilvestre commented Dec 14, 2022

Connection with issue(s)

Resolve issue #56

This + related issues were closed and converted to "discussions", although there was no resolution. Since I don't know the reason @vHanda closed them, I won't open a new issue.

EDIT: This incidentally solves issue #885. See comments in changed files.

Testing and Review Notes

So far, this PR only contains the template engine code + unit tests.

Hopefully someone who can successfully get a build running locally will be able to handle the UI/Flutter parts.

Well, I figured it out :P

Now, note creation with filename templates needs to be tested for normal + journal note types.

To Do

  • get a successful build with these changes
  • UI: add "template" option in settings

@justinsilvestre justinsilvestre changed the title Custom filename template engine Custom filenames Dec 16, 2022
@@ -1,9 +1,3 @@
/*
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was deleted automatically. not sure if this is correct

@@ -51,6 +52,13 @@ class NoteStorage {
return catchAll<Note>(() async {
assert(note.fullFilePath.startsWith(p.separator));

final directory = dirname(note.fullFilePath);
final directoryExists = io.Directory(directory).existsSync();
if (!directoryExists) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary to allow new folders to be created for filename templates like this:

folder_name/{{date}} {{title}}

@@ -73,7 +73,8 @@ class _EditorScaffoldState extends State<EditorScaffold> {

note = widget.startingNote;

SchedulerBinding.instance.addPostFrameCallback((_) => _initStateWithContext());
SchedulerBinding.instance
.addPostFrameCallback((_) => _initStateWithContext());
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the formatter caught this.

NoteFileNameFormat.fromPublicString(context, publicStr);
child: NoteFileNameFormatPreference(
getFileNameFormatFromConfig: () => folderConfig.journalFileNameFormat,
setFileNameFormatInConfig: (format) {
folderConfig.journalFileNameFormat = format;
folderConfig.save();
setState(() {});
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this is for, but it was present in the previous onChange handler, so included it here and below.

@@ -75,14 +74,16 @@ DateTime? parseDateTime(String str) {
return null;
}

DateTime parseUnixTimeStamp(int val, NoteSerializationUnixTimestampMagnitude magnitude) {
DateTime parseUnixTimeStamp(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the formatter did this automatically.

@justinsilvestre
Copy link
Author

hope this UI is good enough. I'm no designer :P

image

error UI:
image

@@ -177,6 +177,8 @@ class Settings extends ChangeNotifier with SettingsSharedPref {
}

class NoteFileNameFormat extends GjSetting {
final bool usesTitle;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introducing this here to prevent e.g. this bug #654 from happening again.

@@ -359,7 +370,7 @@ class Note implements File {
bool get shouldRebuildPath {
if (fileFormat != NoteFileFormat.Markdown) return false;

return parent.config.fileNameFormat == NoteFileNameFormat.FromTitle;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the source of #654.

The filename needs to be rebuilt whenever the file name format includes the title, which includes other cases than the plain "title" option.

@vHanda
Copy link
Contributor

vHanda commented Jan 19, 2023

This is wonderful. Thank you for this, and my apologies for not getting to it for over a month.

Could you please rebase your changes? I've added a clause in the README specifying that all contributions will be in Apache2 license. Would that work for you?

I want GitJournal to be released under GPL, but that would remove it from the iOS store, and I don't want to deal with CLAs.

@vHanda vHanda changed the title Custom filenames [License Accepting Required] Custom filenames Feb 16, 2023
@justinsilvestre
Copy link
Author

Hey @vHanda, finally found the time for that rebase 😃

Apache2 license is fine by me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants