Publish from Tinderbox to DEVONthink

Thanks for your answer.
I came up with another solution that works quite well in my case. See next post.

This is not due to the template as you can see in the HTML section of your note that a link is not wrap in a <a></a> tag but in <p></<p> tag.

I have updated the template to account for this and replace any valid url wrapped in a <p></<p> tag into <a></a> tag by using the following regex:

replace('<p>(https?:\/\/.+)<\/p>', '<a href=\\"$1\\" class=\\"link-external\\">$1</a>')

Additionally, for me not having the image exported into DEVONThink was a deal breaker, so I found the following workflow that works quite well:

  1. Store the images in a DT database
  2. Drag an image to a TB note
  3. Copy the DT link and paste it right below the image
  4. You can add a class to the image if you need by adding
 || .link-dt

So the text below the images looks like:

x-devonthink-item://E85F32FD-211E-4EE8-AA1B-9A7AA502D5E9 || .link-dt

The output will be:

<img src="x-devonthink-item://E85F32FD-211E-4EE8-AA1B-9A7AA502D5E9" class="link-dt" />

You can also omit the || .link-dt

I like the idea to store the original image with the full quality in DT, and upon dragging into the TB note, having a reduced quality image just for viewing in the TB note. You can also add a middle step where you resize manually the image outside DT and before dragging into TB but still link to the original DT image by using the DT item link.

Note that images with no DT item directly below will not be processed and not viewable in DT upon export.

Because the TBX document file size grows very fast (is that a bug? If I drop a 34kB image in a note, the document size grows from 50kb to 5MB???), there is also a third options to show a DT image only after export:

For this, you don’t drag the image to TB but instead just copy the DT link id and paste as follow somewhere in your note:

@img: x-devonthink-item://E85F32FD-211E-4EE8-AA1B-9A7AA502D5E9 || .link-dt
@img: x-devonthink-item://E85F32FD-211E-4EE8-AA1B-9A7AA502D5E9

Again you may or may not use a class as am option for your image

New template:

publish-tinderbox-to-devonthink-0.5.4.tbx (205.0 KB)

1 Like

Help. Using the newest I believe 0.5.1 version. Question I have the demo version of Tinderbox, do I need the full version for this to work? Followed the instruction but does not seem to work. Thanks in advance.

If I recall correctly in the demo version you might have already reached the number of notes you can create. I was only able to export one of the existing notes found in the files not adding new ones.

Hi Pat,

I have been itching to use your publish to DT system for a long long time now, but only finally got to try it this week. It is all very exciting.

The trouble is that for some reason I can’t get things to work. I have tried both version 5.1 and 4.0. Even when I use method one (using the raw download file without elaboration), I still can’t get it to play ball. The url fields don’t populate and there is nothing appearing in the DT global inbox.

And so I am wondering if this is because:
~ I have not enabled some system-wide security feature that enables TB to talk to DT.
~ That a recent update has broken the mechanism. (I am on OS 11.6.2; TB 9.1.0 and DT pro 3.8)

I should have prefaced all of this by saying that I am a pretty clueless about AppleScript.

If you have any thoughts, that would be great.

And thanks for sharing all your work on developing this mini-machine, it has the potential to save me hours and hours of work.

Yours in hope,

Gavin

Just a quick agenda to the above. I had not seen the earlier posts in the forum from Julien and others. I am on a slow internet connection and so they did not appear - rather than me just being lazy.

I have just tried version 5.4 and still no luck.

all the best,

Gavin

just tried out 0.5.1 to 0.5.4 with TBX 9.1 - none of them created a new item in DevonThink?!

I have seen a few reports on the web regarding AppleScripts that stopped working after upgrade to Monterey, so I wonder if that has anything to do with it.

FWIW, It stopped for me several months ago while I was on Catalina. I am now on Monterrey and it still does not work. Unfortunately, I had to stop using it even though I really like it as a round trip back to DEVON from Tinderbox.

Tom

macOS changed its default Unix shell from bash to zsh from Catalina (10.15.x) onwards, in October 2019. That may be a factor and I do recall some other reports of runCommand() issues that might relate to the shell in use (sorry, I don’t recall where). runCommand() is rather under-the-hood stuff so this is probably one for @eastgate.

I have tried both versions (some months ago) and both worked. I can’t remember if I did something special. I would suggest giving accessibility permission to all the apps involved and giving it another go. Also, carefully read the instructions provided by @pat in the file, as you have to ‘prepare’ the notes that will be exported.

@mwra, while I can’t say for sure, I suspect that this is not the cause of the issue. There is nothing there that I can remember that could have been affected by some difference between bash and zsh.

1 Like

Good - if only to park that as a possible cause. :slight_smile:

Thanks for the suggestions, I think I have followed Pat’s advice and given the designated note the right prototype and used the stamp. I have also added both apps to the accessibility pane under the security preferences, and still no bananas. i.e. it doesn’t work for me.

It seems that there may be something amiss under the hood somewhere.

It would be great if this was a built in behaviour.

2 Likes

I too think it is related to the strange security settings implemented by Apple. It’s not the accessibility pane but the automation pane (wild guess) and there an app has to ask for the permission. Since macOS Mojave, the Security and Privacy controls restricts sending and receiving AppleEvents. A given process can only send events to a different process with user approval.
you can try this (dirty) AppleScript in the terminal:

if ! osascript -s o <<EndOfScript
    tell application id "Cere"
        try
  tell application id "DNtp"
    set theRecord to create record with {name:"test", type:"html"}
  end tell

        on error message number -1743
            error "Privacy settings prevent access to TBX"
        end try
    end tell
EndOfScript
then
    echo "just a try"
fi

If TBX has not rights in the automation pane it should bring up the approval dialog. Grant access and you should see a new html note in DT. This works for me.
Still it doesn’t work out of TBX for me using publish-tinderbox-to-devonthink-0.5.4

1 Like

Interesting!

It makes me wonder whether inserting keyboard maestro into the workflow might breathe some life back into it. My rationale being that it is likely to be more adept at handing the peculiarities of Apple’s various revisions to its security protocols. That’ll take some fiddling though.

I am wondering whether Mark @eastgate has thoughts on this ?

Something to try for all that cannot get transfers to DEVONthink.
In “Publish single note to DEVONthink” on each line

“result = runCommand(”/usr/bin/osascript", command.json);"

replace with

result = runCommand("/usr/bin/osascript", jsonEncode(command));

and the transfer to DEVONthink will start to work (at least for me).

4 Likes

works for me too! Great! Thanks!

Thanks Gunnar. That’s real progress.

It works for me in the sense that it now ports the note to DT, and populates the sourceURL field with a DT -pattern link. However, the script doesn’t swap the local TB-pattern ziplinks out in exchange for brand new DT-pattern links. In other words, it won’t allow one to move between linked notes within Devonthink.

Also, I was not sure whether the first of those two modified lines needed the expression “result=” at the head of it, as that is an additional change to the original syntax. But both those versions worked for me.

Yes, I noted the linking discrepancy.

Here is an update that is supposed to fix the linking problem in DEVONthink.

Locate the “Publish single note to DEVONthink” note (in “–UTIL–”). Replace from “var linkNotes;…};” up to, but not including $DTExportSource, with this code;

var linkNotes;
linkNotes = find($SourceURL.beginsWith(“x-devonthink-item”) & !$IsAlias);
$DTExportSource = ;
linkNotes.each(l) {
var dtLink($SourceURL(l));
var lp(exportedString(l, “^path^”));
if(theExport.contains(lp)) {
theExport = theExport.replace(lp, dtLink);
};
};

and links should work (even Zip-links).

2 Likes