sawhney17 / logseq-smartblocks

MIT License
172 stars 12 forks source link

Limiting execution of code to only once or only after a certain hour of the day #6

Closed danieltomasz closed 2 years ago

danieltomasz commented 2 years ago

I want to use the button to input my daily journal question, so I want to input the button into my daily template, but I dont want to by chance input the question before certain hour and input these question more than once

Is there an option to limit the execution of the plugin given some condition, for example, execute only if there are no children below the block or if there is a specific hour of the day (if the condition isn't satisfied the template shouldn't input template)

Or maybe this is already planned ot requested in other issues, for example https://github.com/sawhney17/logseq-smartblocks/issues/5?

sawhney17 commented 2 years ago

For limiting the execution to only once, would something like an inline code like {{renderer smartblockInline: templaName}} work. This would then automatically expand the template upon being clicked. I'm working on adding more conditions. There's currently if dayofweek, if dayofmonth and ifdayofyear. I guess an "if hoursafter" or {{if hoursbefore}} makes sense.

danieltomasz commented 2 years ago

I dont know if this is possible, but maybe the "lesser than" < and "greater than" > relations? This make room for extending the plugin for users but is probably hard to implement?

Below is offtopic: Also I dont know nothing about Logseq API and JS (Also I dont use Roam Smartblock) but does your plugin (or its extentsion) has the potential to execute the custom user written js script? Like getting today agenda from Calendar or some todo app?

sawhney17 commented 2 years ago

JS may be a bit difficult to figure out. I'll add the operators to my list. Logseq actually has a feature called custom.js which allows you to execute JS in app. But I actually created a plug-in, published like an hour ago which fetches your events from the day and appends it to the journal

https://github.com/sawhney17/logseq-calendars-plugin On 28 Jan 2022, 2:48 PM +0400, Daniel Borek @.***>, wrote:

I dont know if this is possible, but maybe the "lesser than" < and "greater than" > relations? This make room for extending the plugin for users but is probably hard to implement? Below is offtopic: Also I dont know nothing about Logseq API and JS (Also I dont use Roam Smartblock) but does your plugin (or its extentsion) has the potential to execute the custom user written js script? Like getting today agenda from Calendar or some todo app? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

sawhney17 commented 2 years ago

@danieltomasz, does the calendar pluign fulfill your need?

I've also added inline rendering so that you can trigger a smartblock just once

danieltomasz commented 2 years ago

Thanks for the updates! I think the current state is ok for me. I learned to not click the smartblock button too many times:)

So {{renderer smartblockInline: templateName}} will execute the code (insert template) at the very moment it will appear on a page and then disappear? My idea was a smartblock which will may be present whole time on the page and only in the moment of first interaction will inserct the template once. Or maybe I do it wrong. This is not that important now, I think I could use it the way it is now. Thank you again for making this plugin :)

sawhney17 commented 2 years ago

I believe you can just put the insert renderer block into your daily note template and when the template it triggered. It will appear as a blank spot which upon clicking the block Willy leave the content.