It’s not a callback URL because it does not return anything. It’s just an URL command.
In Draft, you’d do somethink like this
/* get text of current MD document - check Draft's documentation
something like this:
const txt = draft.processTemplate("%%[[draft]]%%")
*/
const app = Application('DEVONThink 3');
const rec = app.getRecordWithUuid("B9C35..."); /* use your record's UUID here */
rec.plainText = rec.plainText() + txt;
This whole thing has to go into a Draft action (if that’s the word) that you can run from any currently open MD document. Note I did not test this code! And you have of course first have to get the text of your current Draft document’s text. But that should be easy.
finally had some time to get back to this. I can’t see, to get it to work though
this is the current state of the code
/* get text of current MD document - check Draft's documentation something like this:*/
const txt = draft.processTemplate("%%[[draft]]%%")
const app = Application('DEVONThink 3');
const rec = app.getRecordByUuid("B9C35634-FECB-4315-ADD2-C23131F38FFE"); /* use your record's UUID here */
rec.plainText = rec.plainText() + txt;
Apparently Drafts does not use Apple’s scripting technology, so Application is not known inside Drafts.
I’m away from my desktop, so can’t explore further. You could check if Drafts provides for execution of shell scripts. Then you could run the JavaScript through osascript in the shell.
Are you creating separate notes to append to a Markdown document in DEVONthink?
Or are you adding to an existing Drafts file and replacing all the text?
thx guys! @BLUEFROG , yes I want to append the text in a current draft to an existing md note in Devonthink
ideally I could get a popup to choose which file in Devonthink but if not I can also live with a predefined md and just create a bunch of drafts actions to send to specific files
In fact, Drafts provides shell functionality like described here:
So it would be possible to write a script (AppleScript or JavaScript) that could
retrieve the current Drafts document’s content
get the list of groups from DT
present that list to the user to select from
get the list of records from that group
present that list to the user to select from
append the Drafts document to the selected record
Give that script the appropriate she-bang line and Drafts should be able to run it.
While it’s feasible, I’m wondering if it’s worth the effort. How often do you need this functionality, and why do you need it in the first place instead of simply editing the record directly in DT?
If I got you right and you want to append notes written in Drafts to exactly one note in DEVONthink why not give the notes a marker like a tag or a special part in the name which lets DEVONthink detect them and have Smart Rule/script add them to that note?
And if you used a Markdown app that unlike Drafts uses actual files and not a locked database you could handle this completely different. Simpler, that is.
this gave me some food for thoughts and I started playing with implementing this using obsidian instead of Drafts since as you said that uses proper .md files.
but Im running into issues…
first to get it into Devonthink I have tried using hazel to auto move any .md file to Devonthink based on the availability of the Devonthink tag and moving that file to a auto import to Devonthink folder I have on the mac, sadly this dosent seem to work
There are different ways to handle what you want to achieve. And a Markdown app that has an open file system (like Obsidian) offers just more options. Or to put it another way: With apps that have locked content you have to find solutions for problems which simply do not exist with apps using an open file system.
Let’s see what you could do (no claim for completeness here):
An app saves a note to a fixed place. Could be the DEVONthink Inbox or any Finder folder. A Smart Rule in DEVONthink handles the note—Hazel is not needed here. (With Drafts you could also send directly to a group, but remember: No batch send is possible!)
To trigger the Smart Rule the note must have some kind of marker. This could be a tag or a unique part in the note’s name or something else. It would also be possible that the folder (or with Drafts: group) it has been saved/sent to already is the marker as that folder is used exclusively for content that gets added to your “Big Note”. In that case you should not use the Global Inbox as you would block it for any other content.
The Smart Rule must, as @bluefrog pointed out, use a script. The script could add the content of the new note(s) to the end of the Big Note and delete the new note afterwards.
Since DEVONthink has file transclusion the script could also just add a transclusion link (if that’s the proper term) to the end of the Big Note and keep the smaller ones.
When you use a Markdown app that uses an open file system instead of importing the notes to DEVONTHINK you could make DEVONthink index the notes folder of the Markdown app instead. No moving into a DEVONthink database necessary.
If you did that you could again use a script that adds the content to the Big Note.
Or you could use a Script that adds just a transclusion link.
But what you could also do is just not create smaller notes which get one way or the other added to the Big Note but write in the Big Note directly! Because when indexed you have access to it both in your Markdown app and in DEVONthink. It is the very same file! If navigating in the Big Note is not a problem due to its length then this would be both the most technically simple and the most efficient solution I’d say.
But that is of course up to you and how it fits your workflow.