Tinderbox and Hook - moving notes

I saw the discussion from a few months back about using Hook and Tinderbox. I’ve used Hook for awhile but until I saw the discussion, I didn’t know you could link to a specific note in Tinderbox. That’s a game changer for me and my workflows. The only issue I’m running into is that if I move the note within Tinderbox, Hook seems to lose track of it. I’ve looked at the URL Hook generates and it incorporates the Tinderbox URL for the note but it also incorporates the outline levels as well. I’m not sure Hook needs to include the outline levels as part of the link.

Anyone have any solutions or advice other than never move your Hook linked notes?

I suggest explaining the issue at the Hook Forum. The owner, CogSci, is very interested in suggestions for improving or adding to the integration scripts included with Hook, and there are several folks there who have actively contributed suggestions. (Some of them are members here, too.)

You can add your own scripts to Hook – if you want to modify the ones provided by CogSci. Personally, I think it’s best to stay with the ones CogSci provides since they will be professionally maintained over the long term.

Thanks! I added a similar post to their forum.

Did anyone get a resolution to this? Please share your experiences with Hookmark and whether moving a Note within Tinderbox breaks the Hookmark link?

Thanks!

Hi Art,

How interesting. I had not seen this before. In testing just now, Greg is right. If I move the original note, Hook loses the hookmarks, but if I put it back, its fine.

Looks like this remains a bug with HookMark. Thanks for bringing this to my attention as I just begin to explore using it again, now with this limitation.

Tom

1 Like

Yes; my current active project structure is being shuffled, and so are my Finder destinations. I could only use a solution that provided some kind of permanent link between a Tinderbox Note and say the UUID of the target Finder file. Pending that I’m just storing the $File info as-is and will rely on human skills to fix future broken links.

1 Like

I am going to loop in @lucb the developer of HookMark into this conversation. Let’s see what he says. Looks like @gregi has already posted in the HookMark forum.

Tom

Sounds like Hook may be identifying notes by $Path, which may be a good choice. In that case, if you have a note /ToDo and move it to /Tasks/Todo, Hook won’t find it. That might be right: maybe you moved it to /Obsolete/2022/Todo and made a new note for /ToDo, and you want the note that has the current ToDos even if it’s a new note!

If you want to retain the link to the note, wherever it is, use the note’s $IDString.

Here is the Applescript that is listed in the Get Address for Hookmark if anyone knows Applescript. I do not know how to modify it to change from $Path to the new $IDString.
It looks like this was written a while ago (Tinderbox 8) by Rob Trew.

use framework "Foundation"

tell application "Tinderbox 9"
    if (count of documents) is equal to 0 then
        return "No document is available"
    end if
    
    set openFile to file of first document
    if openFile is missing value then
        return "Hookmark can't link unsaved files"
    end if
    
    set filePath to my encodedPath(POSIX path of (openFile as alias)) as string
    
    set openNote to selected note of first document
    if openNote is missing value then
        -- link to file if no note is selected
        return "file://" & filePath
    end if
    
    set tinderboxURL to value of attribute "NoteURL" of openNote
    set tinderboxURL to (text (1 + (length of "tinderbox://")) thru -1 of tinderboxURL)
    set tinderboxURL to "tbx://" & tinderboxURL
    
    return tinderboxURL & "?filepath=" & filePath
end tell

-- encodedPath :: FilePath -> Percent Encoded String
on encodedPath(fp)
    tell current application
        (its ((NSString's stringWithString:fp)'s ¬
            stringByAddingPercentEncodingWithAllowedCharacters:(its NSCharacterSet's ¬
                URLPathAllowedCharacterSet))) as string
    end tell
end encodedPath

OK. I see what he’s doing, and yes, it’s tied to paths.

I think this is really what you want to do, much of the time: you do want /TODO, not the old note that you archived.

I’ll ponder this.

3 Likes

It appears in the HookMark to Tinderbox script above that it is using the NoteURL to get the File Path. I think.

Question: Is the $IDString exposed in the AppleScript dictionary? If not, how would you get at the $IDString from HookMark?

Thanks
Tom

$IDString is an attribute like any other. It’s just special in that its value can be used as a designator.

1 Like

The Problem with the older code above is the $NoteURL attribute referenced above breaks when an item is moved because it uses path via $NoteURL using $ID.

“set tinderboxURL to value of attribute “NoteURL” of openNote”

All we have to do is to either replace the $ID with $IDString section in the code, however I do not know AppleScript well enough to do it.

What I tried…
I tried to just replace the “NoteURL” with “IDString”. It did not work. It correctly substituted the IDString only like so

image

For this to work, “NoteURL” needs to be passed the $IDString to use instead of the $ID (which I do not think is possible" or we need to replace the text string after “select=”$ID with “select=”$IDString
-I do not know how to do either in AppleScript. Stuck here.

Here is the result we want

Does anyone know AppleScript well enough to modify the code.

@TomD, can you share the source for the AppleScript you quote above? The base code does not appear to be working.

The Source code is in Hook/Preferences/Scripts/Tinderbox 9/Get Address. It is the original code that ships. You can write custom codes on top of the older scripts. The code was written with Tinderbox 8 by Rob Trew.

Got it. I really don’t know hook, but I this appears to work.

In the code change:

	set tinderboxURL to value of attribute "NoteURL" of openNote
	set tinderboxURL to (text (1 + (length of "tinderbox://")) thru -1 of tinderboxURL)
	set tinderboxURL to "tbx://" & tinderboxURL

to

	set tinderboxURL to value of attribute "IDString"

The try it.

I suggest you make a copy of the original code.

I think two things are getting confused here. $IDString is nothing more that a unique string encoded from the ID number. The aim is that the resulting string is less prone to occasional mishandling of the ID as a number, i.e. you don’t want some process to multiple $ID twice and use the result as an ID. So for general use the IDString is the same as a ID just expressed differently. The ID never changes, so the IDString can’t (as it is based on the ID).

So the assertion here is false:

Both those examples point to the same thing. What you are overlooking is the NoteURL uses the -in-TBX-document path. For the note on $NoteURL the $NoteURL is:

tinderbox://aTbRef-95/?view=outline+select=1448512291

But that’s because the current view is at root. If I hoist the container ‘System Attribute view’ and repeat the process I get the path:

tinderbox://aTbRef-95/A%20Tinderbox%20Reference%20File/Automating%20Tinderbox/Coding/Use%20of%20Attributes/Attribute%20Listings/System%20Attribute%20List?view=outline+select=3420021570

The syntax you see is

  • (open) Document name (minus '.tbx. extension : tinderbox://aTbRef-95
  • container path: A%20Tinderbox%20Reference%20File/Automating%20Tinderbox/Coding/Use%20of%20Attributes/Attribute%20Listings/System%20Attribute%20List
  • view type for container: ?view=outline
  • selected item(s) in that view: +select=3420021570

Your path issue relates to bullet #2 above, yet changing $ID to $IDString only affects bullet #4

It look like your process failure is not ID, but but because the note described from ID has moved from the path at which it was recorded. Using a simpler version than above let’s assume we have a note $Name “Patient Review”, $ID 2920021571 at $Path “/Projects/Trial X/Patient Review”. Looking at the note in the map “Trial X”, the $NoteURL is:

tinderbox://untitled/Projects/Trial%20X?view=outline+select=1678642209;

If I move the note to container “/Projects/Trial Y”, a NoteURL-based call will fail as there is now no item with $ID 1678642209 in the map (i.e. container) “/Projects/Trial X

Visually:

One suggestion. If Tinderbox gets a tinderbox:// call where the ID is valid but the path is not, that the doc uses a root-level outline and selects the ID (expanding a branch as needed). The user can then adjust the tab’s view type/scope as needed. If the target is a multiple selection, do the display based off the first ID and select any other valid IDs regardless of location.

TL;DR. The problem is not the ID/IDString but the -in-docpath to the item (if any) embedded in the noteURL.

This did not work for me. Will call MichaelB later.

What do you suggest as a solution in the script?

No rush, but in order to use Hook reliably with Tinderbox , we need to update the basic script HookMark is using in HookMark/Preferences/Scripts/Tinderbox 9/GetAddress

This I think will require someone with expertise in AppleScript. I am trying but I am still in the starting gate.

Thanks
Tom

In Tinderbox $NoteURL is read-only, but to get a note URL using $IDString, make a URL-type attribute 'NoteStringURL`. Now use this stamp:

$NoteStringURL = $NoteURL.replace($ID,$IDString);

My test, with $ID 1678642209, $IDString tbx:BkDgwh $NoteURL is: “tinderbox://untitled/Projects/Trial%20Y?view=outline+select=1678642209;”. After using the stamp $NoteStringURL is " tinderbox://untitled/Projects/Trial%20Y?view=outline+select=tbx:BkDgwh;"

But, as per my previous reply I don’t think this will fix the path-related problem you are describing above/

1 Like