Inconsistent behaviour with Bookends

I’ve just run into a problem using Hook with Bookends. For most of the items, when I invoke Hook to copy the link, I see exactly what I expect – the Bookends icon and the title (in the format I have specified in the Hook custom scripts, as set out in a recent post on the Bookend forums):

However, in some cases, when I invoke Hook, it’s giving me a link to the PDF attachment of the item in Bookends, not the the item itself. This is not at all what I want. I can’t see any reason why this happens to some, but not most, items.

In addition, there are a small number of cases where Hook is giving me nothing at all:

For one of the items which resulted in a PDF link, I detached the PDF attachment in Bookends, invoked Hook and got the normal result of a Bookends link. Then I attached the PDF again, and Hook reverted to giving me a link to the PDF not the Bookends item.

Using Bookends’ AppleScript, Hook simply asks Bookends to return the ID of the item, based on which Hook creates a hyperlink.

could you please compare the result of Hook’s copy link function in Bookends with Bookends’ own copy hypertext link > as link? Are they the same?

In that case, is Bookends > copy hypertext link > as link disabled ?

We also published an alternative Bookends script that uses hook://file//, but I don’t think that’s what you want.

Thanks, Luc.

They are not the same. These are the result from my second example above:

  • Result from Hook: hook://file/tGmgs2hnv?p=aUNsb3VkfmNvbX5zb25ueXNvZnR3YXJlfmJvdC9Eb2N1bWVudHM=&n=Waltner%201984.pdf.pdf
  • Result from Bookends: bookends://

Obviously, the two URL schemes are different, but it’s still clear that the Hook result points to the PDF while the Bookends result points to the ID of the work (Waltner).

In the case of those Bookends items that produce no result in Hook, Bookends is still able to provide the link. Using my third example from above:

  • Hook result – none
  • Bookends result: bookends://

Pasting these results here has made me realise that I expected Hook to return results using the Bookends URL scheme, since the Get Address script is:

tell application id "com.sonnysoftware.bookends"

    set selectedItems to selected publication items of front library window
    if selectedItems is not {} then
        set selectedUrl to url of item 1 of selectedItems
        if selectedUrl is not equal to "" then
            get properties of item 1 of selectedItems
            return "bookends://" & id of item 1 of selectedItems
            set a to attachments of item 1 of selectedItems
            if a is equal to "" then
                return "bookends://" & id of item 1 of selectedItems
            end if
            return "file://" & default attachments path & a
        end if

    end if
end tell

Is this where my problem lies?

For completeness, here’s the script I have for Get Name:
tell application id “com.sonnysoftware.bookends”
tell front library window

		set selectedPubs to selected publication items -- requires Bookends ≥ 13.2.1
		if selectedPubs is not {} then
			set aPub to first item of selectedPubs
			-- NOTE: leave out the "using ..." part to instead format according to your
			--       current Bookends setting (see the “Biblio > Default Format” menu)
			set formattedReference to format aPub using "Harvard (Anglia).fmt"
			return formattedReference
		end if
	end tell
end tell

It looks like you’ve overridden Hook’s built in script for Hook. This may be because you applied a script from the forum before CogSci Apps provided a script for bookends in Hook itself (and the script server). If a user has created or modified a script for an app, Hook won’t override it.

The built in script returns a bookends URL:

tell application id "com.sonnysoftware.bookends"
	set selected_ids to «event ToySRUID» "Selection"
	set selected_ids to words of selected_ids --coerces to list
	set n to count of selected_ids
	if n ≥ 1 then
		set sid to item 1 of selected_ids
		set myUrl to "bookends://" & sid
	end if
end tell

Using Hook with Bookends Reference Manager by Sonny Software – Hook

Hook supports Bookends. By default, Copy Link and Copy Markdown Link in Bookends return links of the form bookends://.

If you would rather traffic in hook://file/ links, then Hook Pro users may the alternative Hook-Bookends integration script below.

If you would like to get Hook’s built-in script you can click the “-” button at the bottom left of Hook > Preferences > Script Editor tab for that script.

1 Like

Yes, that’s the issue. Getting rid of the custom script has made it work properly again. I think I probably put this script in early last year when I started using Hook.

Many thanks for your help.

1 Like