-
-
Notifications
You must be signed in to change notification settings - Fork 524
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
Allow editing of DayOne entries #1001
Conversation
Add test for editing Dayone entries (this test currently fails) Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
DayOneJournal previously reimplemented Journal._parse inside of DayOneJournal.parse_editable_string, and in doing so caused issues between itself and the class it was inheriting from. This commit fixes the issue by moving the UUID to be in the body of the entry, rather than above it. So, then Journal._parse still finds the correct boundaries between entries, and DayOneJournal then parses the UUID afterward. Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
Well, that took longer than expected, but I think this is all working now. @MinchinWeb @micahellison Would y'all mind taking a look over this? |
I haven't had the chance to test drive this yet, but it we're using a regex match:
|
@MinchinWeb I think those are all very good questions, and we should definitely discuss if and how to handle extended metadata on entries for certain journal types, but I would consider that out of scope for issue #955. I was also very tempted to change the |
# merge existing tags with tags pulled from the entry body | ||
entry.tags = list(set(entry.tags + match.tags)) | ||
|
||
# extended Dayone metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this extended metadata being preserved? or is it being dropped when the entry is edited?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is being preserved: it is read when the journal is opened, it remains in memory as the entry is being edited, then it's saved back. And it still creates the metadata when writing a new entry.
@@ -37,18 +39,30 @@ def title(self): | |||
self._parse_text() | |||
return self._title | |||
|
|||
@title.setter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These setters I don't think are being used by your solution. Would it make sense to drop them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good to leave them in. It sends a nudge to future contributors that they should use entry's accessors rather than underscore-prefixed internals.
Simple local testing seems to show that it works! Extended metadata stays in place. The In regards to this PR, should we remove the setter code I added, as it's not being used? In regards to future work:
I'm excited to see this merged. Thank for everyone's help! LGTM! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Nice collaboration!
* add test to repro issue #955 * Allow editing of DayOne entries * Add broken test for Dayone Add test for editing Dayone entries (this test currently fails) Co-authored-by: Jonathan Wren <jonathan@nowandwren.com> * Fix editing logic for DayOneJournal DayOneJournal previously reimplemented Journal._parse inside of DayOneJournal.parse_editable_string, and in doing so caused issues between itself and the class it was inheriting from. This commit fixes the issue by moving the UUID to be in the body of the entry, rather than above it. So, then Journal._parse still finds the correct boundaries between entries, and DayOneJournal then parses the UUID afterward. Co-authored-by: MinchinWeb <w_minchin@hotmail.com> Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
Fixes #955
DayOneJournal previously reimplemented Journal._parse inside of DayOneJournal.parse_editable_string, and in doing so caused issues between the two classes (the body was being reparsed for a title, overwriting the title, and essentially dropping the first line of each edited entry). This commit fixes the issue by moving the UUID to be in the body of the entry, rather than above it. Doing this allows us to use Journal._parse like normal (it still finds the correct boundaries between entries), and then DayOneJournal parses the UUID afterward.
Co-authored-by: MinchinWeb
Co-authored-by: Micah Jerome Ellison
Checklist
for the same issue.