Page 1 of 1

Improving Bookends Integration with Other software

Posted: Tue Mar 22, 2016 8:44 am
by iandol
I attach a few scripts (Jon the developer of Bookends wrote one and I modified it to create the others) to ease interaction between your word processor, browser, or any other app and Bookends.

Live Search Formatted/Unformatted Ref
The first takes a text selection in your word processor, that is a formatted or unformatted ref, removes unnecessary text/characters and searches for it within bookends using the Live-search field.

If I have text like:

Code: Select all

(Hubel and Wiesel, 1962)
it strips [(), and] to leave [Hubel Wiesel 1962], which finds that reference in bookends instantly. A simple ⌘Y and that selected text gets replaced with the proper temporary citation without any further fiddling. It works with existing temporary citations too, so:

Code: Select all

{Shipp et al., 2013, #54808}
gets converted to [Shipp 2013] search to quickly check the source reference in Bookends.

Search selected text in Pubmed
The second takes a text selection, and pastes it into Bookends Pubmed search engine. Again it works in any app not just Scrivener. it means I can select an author, DOI or some words in my browser/word processor and quickly run a Pubmed search with Bookends (i.e. then easy to import into the database). For it to work optimally, it needs Bookends 12.7 beta (introducing the new cloud sync) and later to work, as Jon made a small change to the Pubmed browser to make it more reliable.

Search selected ID in Bookends
The third one simply takes a selected unique ID and selects that entry in Bookends.

How to use them?
You can read the raw code and download a ZIP here:

https://gist.github.com/iandol/c8fdd7884379adb8c2db

As they are plain Applescripts they normally live in ~/Library/Scripts, but to quickly access them you need some way to trigger them. I use Quicksilver, which automatically indexes ~/Library/Scripts, so you can easily trigger these scripts wherever you are. Alfred/Launchbar/Keyboard maestro and others also allow you to quickly trigger Applescripts, though each may do so in a slightly different way. OS X also has a built-in scripts menu you can display (Script Editor > Preferences > General to enable it); you then run them from the menu bar.

Re: Improving Bookends Integration with Other software

Posted: Wed Mar 23, 2016 3:42 am
by NilsMS
Very useful, thank you very much!

However, I do not know why but the script "Live Search Formatted/Unformatted Ref" does not work for me. To make it work, I had to specify the programm first:

Code: Select all

tell application "Scrivener"
	activate
end tell
This is not a dealbreaker for me, but it defies the original purpose to work with any app. Perhaps it is has to do with my usage of Alfred for invoking the script.

Cheers,

Nils

Re: Improving Bookends Integration with Other software

Posted: Sat Mar 26, 2016 1:13 am
by iandol
I think you may need to enable Applescript utility in System Preferences first:
Screen Shot 2016-03-26 at 13.02.35_SMALL.png
Screen Shot 2016-03-26 at 13.02.35_SMALL.png (28.13 KiB) Viewed 19171 times
Give it a try and let me know how it goes.

Re: Improving Bookends Integration with Other software

Posted: Sun Apr 03, 2016 4:35 pm
by pepemac
Hello
How can I do to go to specific reference from ID number in temporary citation?

"bookends://sonnysoftware.com/" & "ID selected"

Thanks

Re: Improving Bookends Integration with Other software

Posted: Sun Apr 03, 2016 10:09 pm
by iandol
Well, you can't use the unique ID number and the Live search which is what these Applescripts use. But as you say you can use the URL scheme in which case it is very easy to modify the Applescripts to use the unique ID. You can copy from the clipboard and open using:

This works:

Code: Select all

id=''; pbpaste | read id; open "bookends://sonnysoftware.com/$id"
This works from the commandline, but it doesn't work within an applescript, for some reason $id is not assigned (the arcane world of running shell scripts within applescript). So you'lll need to work out why read id works on the commandline but not within applescript:

This fails:

Code: Select all

on run
	tell application "System Events"
		keystroke "c" using command down
		delay 0.5
		do shell script "id=''; pbpaste | read id; open \"bookends://sonnysoftware.com/$id\""
	end tell
end run

Re: Improving Bookends Integration with Other software

Posted: Sun Apr 03, 2016 11:22 pm
by iandol
OK, I think this should work:

Code: Select all

on run
	tell application "System Events"
		keystroke "c" using command down
		delay 0.5
		do shell script "id=$(pbpaste); open \"bookends://sonnysoftware.com/$id\""
	end tell
end run

Re: Improving Bookends Integration with Other software

Posted: Mon Apr 04, 2016 3:33 am
by pepemac
Wow!
Works perfectly.
Thank you very much