charliecm / obsidian-upcoming

Show upcoming daily notes in their own panes.
MIT License
15 stars 0 forks source link

Create upcoming notes #10

Open charliecm opened 1 year ago

charliecm commented 1 year ago

Closes #9.

charliecm commented 1 year ago

@Gewerd-Strauss Thanks for the feature suggestion. Can you try this build to see if it meets your need? obsidian-upcoming.zip

Gewerd-Strauss commented 1 year ago

This seems to resolve the issue on the end of this plugin; now all I need to do is figure out how to fix the issue this poses with regards to the template. (I only now realised this is an issue.)

The details as to why this was a short-thought solution:

The daily note template I use has distinct settings per weekday, and uses the this.app.workspace.getactivefile().basename command to detect the date, then converts that to its corresponding weekday:

## Day Planner <% this.app.workspace.getActiveFile().basename %> - <% tp.date.now("dddd",0,this.app.workspace.getActiveFile().basename,"DD.MM.YYYY") %>
---
### Start of Day (<% this.app.workspace.getActiveFile().basename %>)
<%  tp.file.include("{{Morning - 0" + tp.date.now("d dddd",0,this.app.workspace.getActiveFile().basename,"DD.MM.YYYY") + "}}") %>
---
### The Day (<% this.app.workspace.getActiveFile().basename %>)
<%  tp.file.include("{{Day - 0" + tp.date.now("d dddd",0,this.app.workspace.getActiveFile().basename,"DD.MM.YYYY") + "}}") %>
---
### Evening (<% this.app.workspace.getActiveFile().basename %>)
<%  tp.file.include("{{Evening - 0" + tp.date.now("d dddd",0,this.app.workspace.getActiveFile().basename,"DD.MM.YYYY") + "}}") %>
---

This, of course, doesn't work if the file is never rendered, and instead the files created by the upcoming-plugin will refer the filename of the note which is active when the command is issued. That means all notes created by it will contain the same contents.

As this is moreso an issue with my template, and not your plugin, I will be opening a discussion over in the templater-repo regarding this.


Bottom line: Seems to work flawlessly. Only issue with this plugin I seem to have is that the settings don't seem to allow toggling this feature off:

grafik

A toggle "Create without opening notes" should be added to toggle this functionality, I think.

Gewerd-Strauss commented 1 year ago

Addendum: I have potential other ideas how to resolve this if it cannot be fixed via a change in template, but that would be more work for you - which I wouldn't want to request if other options might be available - not to mention that you shouldn't feel obligated doing so anyways.

I will come back if this might become necessary.

charliecm commented 1 year ago

Sorry, I forgot to mention this release added a “Create upcoming notes” command instead of it being a setting. It should create any non-existing daily notes without opening them, and the “Create notes when opening” setting shouldn't affect it. Have you tried running that action?

Gewerd-Strauss commented 1 year ago

Thank you, that action does resolve this side of my project, and the scope of the original PR made by myself here. And now on to figuring out the templater-side of things :P

Gewerd-Strauss commented 1 year ago

I have a short question for verification that came up during the second leg of this journey for me:

Is (this version of) the upcoming-plugin not capable of executing templater-syntax?

Because given the really basic daily note template:

---
banner: "https://www.nasa.gov/sites/default/files/thumbnails/image/simulated_bh.jpg"
banner_x: 0.5
banner_y: 0.42794
cssclass: clean-embeds
date:
---
file.title: <% tp.file.title %>

I get the same contents as output:

---
banner: "https://www.nasa.gov/sites/default/files/thumbnails/image/simulated_bh.jpg"
banner_x: 0.5
banner_y: 0.42794
cssclass: clean-embeds
date: 
---
file.title: <% tp.file.title %>

I get the same output, aka tp.file.title does not get resolved if the daily note is created via the "Create upcoming notes"-cmd. It does however resolve when using "Open upcoming notes".

This seems most likely like a bug on the side of upcoming, however; or perhaps a weird interaction between the two plugins, especially because templater does get triggered via the other way as described above.

charliecm commented 1 year ago

Do you have “Trigger Templater on new file creation” setting turned on for Templater? If so, it should work when you run “Create upcoming notes”.

Gewerd-Strauss commented 1 year ago

Yes I do and no it doesn't.

More specifically, when creating via the command of upcoming, I get this issue from templater:

grafik

And even more frustratingly, that above message and bug I cannot reliably replicate. I will take more time for this.

Gewerd-Strauss commented 1 year ago

However, I am experiencing a different bug, reliably across restarts and restarts of obsidian as of right now:

Today's date: 19.12.2022
I have the plugin set to create the next 6 days. This issue has been observed when creating 2+ days in advance.

Resulting filename - inserted content 20.12.2022 - 20.12.2022 21.12.2022 - 21.12.2022 22.12.2022 - 21.12.2022 23.12.2022 - 22.12.2022 24.12.2022 - 22.12.2022 25.12.2022 - templater: reached incursion limit (10) - this seems to me like all files are somehow issued as a single batch to templater, instead of on a per-file basis. Each daily note template has 3 1st-level calls to tp itself, so neither single call should be able to reach an incursion of 10.


Furthermore, files (visually) seem to populate from the last date to the first - 25th → 20th. This means that once the incursion limit is reached in 23.12.2022, the remaining dates 20.12.2022 - 22.12.2022 are not resolved.


And this is not even replicable in its exact state - which I only noticed while writing this up, so yea. A few more repetitions below. Each time, the results map to the following dates:

20.12.2022
21.12.2022
22.12.2022
23.12.2022
24.12.2022
25.12.2022

The next attempt, I am repeating the same, only that in the same files I now get the contents of the

20th,
unresolved,
unresolved,
20th,
21st,
21st

The next attempt, this is the result

20th,
unresolved,
unresolved,
21st,
21st,
21st

The next attempt, this is the result

20th,
20th
unresolved,
21st,
21st
22nd

Bottom line: I have no idea how/why this is so random. if you want, I can provide you a copy of the template, folder paths and plugin settings if you want to take a closer look.


Additionally, none of this occurs if the notes are created via the calendar plugin. So I'd assume that there's some error in how the upcoming plugin dictates what date to feed to tp, and thus we get the mayhem above. Especially since the mapping seems kind of random - at least to me. I could automate a couple runs large scale over the next couple days, but I don't know if I will have the time for doing so. All plugins refer to the same template.


I hope this is detailed enough, otherwhise I will happily provide more details and/or a demo-section of my vault - which will take a bit to create first, but it's doable.