Unable to link items in Bookends

I am using the latest versions of Bookends and Hookmark on a 2017 iMac running Ventura. When I select an item in my Bookends library and invoke Hookmark, I get the “No linkable item found in Bookends” message. I have reset Accessibility and Automation for Hook, but it has made no difference. Are my computer and operating system too old for this to work?

Thank you for contacting us, @pubay .

I just tried it and it seesm to be working fine on my Mac.

Could you please try the following script in Script Editor and see if there is any error message?

Summary
use scripting additions
use framework "Foundation"
property NSMutableCharacterSet : a reference to current application's NSMutableCharacterSet


on urlEncode(input)
	tell current application's NSString to set rawUrl to stringWithString_(input)
	set charset to NSMutableCharacterSet's URLQueryAllowedCharacterSet's mutableCopyWithZone:(missing value)
	charset's removeCharactersInString:"?"
	set theEncodedURL to rawUrl's stringByAddingPercentEncodingWithAllowedCharacters:charset
	return theEncodedURL as Unicode text
end urlEncode

tell application id "com.sonnysoftware.bookends2"
	set bookendsVer to version
	
	considering numeric strings
		set isNew to bookendsVer ≥ "14.1.9"
	end considering
	
	tell front library window
		set myLink to ""
		try
			set myLink to link to selected text of displayed PDF
			set tlt to selected text info of displayed PDF
		end try
		if myLink is "" then
			set myLinks to selected publication items
			if (count of myLinks) is greater than 0 then
				set aPub to item 1 of myLinks
				set sid to id of aPub
				set tlt to title of aPub
				
				if isNew then
					set libName to name
					set my text item delimiters to ".bdb"
					set libName to first item of text items of libName
					
					set myLink to "bookends://sonnysoftware.com/ref/" & my urlEncode(libName) & "/" & sid
					
				else
					set myLink to "bookends://sonnysoftware.com/" & sid
				end if
			end if
			
		end if
		return "{\"name\":\"" & my base64encode(tlt) & "\", \"address\":\"" & my base64encode(myLink) & "\",\"s_en\":\"base64\"}"
		
		return "[" & tlt & "](" & myLink & ")"
	end tell
end tell


on base64encode(str)
	return do shell script "base64  <<<" & quoted form of str
end base64encode

I’m not sure whether this is an error message or not, but the Result panel reads:

“{"name":"QnVkZGhpc3QgV2FyZmFyZQo=", "address":"Ym9va2VuZHM6Ly9zb25ueXNvZnR3YXJlLmNvbS9yZWYvTWFpbiUyMERhdGFiYXNlJTIwMjAxNzA1MTYvNDg3NTYK","s_en":"base64"}”

Thank you, @pubay .

Could you please copy the following script, and paste it into Hookmark Setttings window ->Scripts->Bookend2->Get Address? Then click on the save button.

Summary
use scripting additions
use framework "Foundation"
property NSMutableCharacterSet : a reference to current application's NSMutableCharacterSet


on urlEncode(input)
	tell current application's NSString to set rawUrl to stringWithString_(input)
	set charset to NSMutableCharacterSet's URLQueryAllowedCharacterSet's mutableCopyWithZone:(missing value)
	charset's removeCharactersInString:"?"
	set theEncodedURL to rawUrl's stringByAddingPercentEncodingWithAllowedCharacters:charset
	return theEncodedURL as Unicode text
end urlEncode

try
	tell application id "com.sonnysoftware.bookends2"
		set bookendsVer to version
		
		considering numeric strings
			set isNew to bookendsVer ≥ "14.1.9"
		end considering
		
		tell front library window
			set myLink to ""
			try
				set myLink to link to selected text of displayed PDF
				set tlt to selected text info of displayed PDF
			end try
			if myLink is "" then
				set myLinks to selected publication items
				if (count of myLinks) is greater than 0 then
					set aPub to item 1 of myLinks
					set sid to id of aPub
					set tlt to title of aPub
					
					if isNew then
						set libName to name
						set my text item delimiters to ".bdb"
						set libName to first item of text items of libName
						
						set myLink to "bookends://sonnysoftware.com/ref/" & my urlEncode(libName) & "/" & sid
						
					else
						set myLink to "bookends://sonnysoftware.com/" & sid
					end if
				end if
				
			end if
			return "{\"name\":\"" & my base64encode(tlt) & "\", \"address\":\"" & my base64encode(myLink) & "\",\"s_en\":\"base64\"}"
			
			return "[" & tlt & "](" & myLink & ")"
		end tell
	end tell
on error msg
	display dialog msg
end try


on base64encode(str)
	return do shell script "base64  <<<" & quoted form of str
end base64encode

After that, please invoke Hookmark over a selected Bookends item. It should display a dialog window with error message.

If no error message, could you please take a screenshot of “No linkable item…” window together with the selected item?

Thank you

That script seems to have solved the problem. Thank you!

The script is essentially the same as the original, except that it now displays an error message if anything goes wrong.

Is your Hookmark 6.9? If yes, you can click on “Reset to default” button in Hookmark Setttings window ->Scripts->Bookend2, and see if it still works.

Thank you

1 Like

It still works. Thank you.