The ability to link a specific individual note in Tinderbox to a PDF file or a web site is a game changer for me. Hook works great as long as I don’t move the note within the Tinderbox file. However, if I do move the note within the file, the Hook link breaks. Looking at the link Hook generates for the Tinderbox note, I notice the link includes the outline path as well as the note URL that Tinderbox uses. By including the outline path, moving a hooked note then becomes broken.
For example, here is the link generated by Hook: (I deleted the path part)
hook://tbx/Tinderbox_5_22/Notes/Misc?view=outline&select=1651872102;?filepath=. . .
Here is the URL that Tinderbox generates for the same note:
tinderbox://Tinderbox_5_22/?view=outline&select=1651872102;
I like that when I invoke a hook link from say a PDF file that hook just shows me the relevant outline section in Tinderbox. However, I also move notes around and I don’t like not having the note hooked anymore.
+1 to fix. Currently Hookmark is broken within Tinderbox. Whenever you move a note, it loses the hook link making it very unreliable. Mark Bernstein suggested that the reason this was happening was because $Path was being used instead of $IDString. $IDString is a newer method (9.5) and would allow identification of notes, if moved anywhere in the document.
Welcome to the Hookmark Forum , @damao . And thank you all for posting about this.
I was not aware that the method to identify notes has changed. We will have a look into it . We should publish notes on using Hookmark with Tinderbox once this is done.
This is my script that seems to be fixing the broken links whenever a Tinderbox note is moved after linking in HookMark in my system. Your mileage may vary. This is just a start. . The old code was written in Tinderbox 8, I am currently using a backstage Release Tinderbox v9.6 I am not an Applescript guy…just a HookMark user in need. I have pieced this together over several days of testing.
Feel free to improve.
To use, this script should replace the GetAddress default script. This will need some further testing.
–original script by Rob Trew
–edited by Tom Diaz
–hints by Mark Anderson and Mark Bernstein
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
--original script commented out
--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
-- edited by Tom Diaz 20230314
set docName to name of first document
set docName to text 1 thru -5 of docName
set tinderboxURL to value of attribute "ID" of openNote
set tinderboxURL to "tinderbox://" & docName & "/?view=outline+select=" & tinderboxURL
-- end of edit
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
Unfortunately the $IDString is using a hash that includes, randomly, “/” and “+” (and maybe other) characters in many of its values that definitely breaks URL addressing. I have made a request to fix this. Until then, I’ve revertted back to using $ID for now. With fingers crossed.
$IDString is a read only system attribute in the format of tbx:LettersAndNum
Here is my new cleaned up version using $IDString which now seems to work with the newest backstage release. This version was cleaned up due to an error in my use of commenting in the code. Rookie mistake… So, I took the comments out to simplify the code.
This is the version I am currently using with one caveat. If a link breaks, check the $IDString in your note. It should look like this format “tbx:Upkdl123” The point, if it contains “/” or “+” characters (and possibly others, the URL link will not work. Linking is still pretty fragile. This edited Hook script is a “bleeding edge release”.
NB: In the versions before this release, $IDString was using “/” and “+” characters in its read only hash. This newest release seems to fix this problem. However this is still EARLY testing.
Tom
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 docName to name of first document
set docName to text 1 thru -5 of docName
set tinderboxURL to value of attribute "IDString" of openNote
set tinderboxURL to "tinderbox://" & docName & "/?view=outline+select=" & tinderboxURL
return tinderboxURL
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
Update:
In case you came to this post looking for an update,
New update from the Tinderbox forum below… until HookMark settles in with more stable Tinderbox script update…