Bookends Tools, an Alfred workflow of 11 different functions

Users asking other users for AppleScripts that work with Bookends.
iandol
Posts: 315
Joined: Fri Jan 25, 2008 2:31 pm

Bookends Tools, an Alfred workflow of 11 different functions

Post by iandol »

I've traditionally used Quicksilver to trigger my scripts and tools, but I recently helped a friend set up an Alfred workflow that integrated many different scripts/tools together (several of them taken from this forum). Alfred offers a very elegant workflow interface, and it prompted me to switch to use it. Some tools take text selections in another app and search for that content in Bookends. Some export selected content out of Bookends to OPML (thanks dave83) or BibTeX/JSON files (thanks naupaka). For those who would like to use Scopus in Bookends, there is a tool that takes a selected ref in Bookends and finds the Scopus URL, and the Cited-By page to open in a browser. The final tools are modified from kseggelston, whereby you can search for author/editor names or title/keywords and an optional year and get a list of references within the Alfred interface to paste into a target app. These tools cover a fairly wide range of ways of interfacing from/to Bookends.

Image

You can use Alfred keywords to trigger these, or bind them to keyboard combinations directly.

Download, source code, and further instructions available here: https://github.com/iandol/bookends-tools

# Changelog
  • 1.2.9 — add a new workflow variable `tempCitationStyle` that sets the default temporary citation format for becite / betitle / beall. When unset it will be the Bookends standard, but you can set the variable to `Pandoc` / `MMD` / `LaTeX` to paste the citation in a different format (`[@key]` / `[#key]` / `\\cite[]{key}`). Also if the authors field is empty for a reference, we now try to use editor names instead in the Alfred results list.
  • 1.2.8 — add phrase search, so for example 'cartesian theatre' 2016 will find papers that use that exact phrase rather than before where cartesian and theatre were searched irrespective of their location.
  • 1.2.5 — becite/betitle/beall first AND last author names with initials are now shown, and if an attachment is present you can Quicklook it directly from Alfred without losing focus (press shift or ⌘Y)!
  • 1.2.4 — becite/betitle/beall now show if a reference has an attachment, and for BE13 users use the new applescript events that are slightly more efficienct.
  • 1.2.3 — small change to open the attachment when you use becite with [fn].
  • 1.2.2 — update the Scopus search tool to the newest API changes (https by default and httpAccept is required)
  • 1.2.1 — rewrote the becite, bebib and betitle tools to perform a mutliple item search (i.e author1 + author2) and you can add an optional YEAR to refine the search. So for example [Zipser Lamme 1998] searches for references by authors (or editors) Zipser and Lamme published in 1998. Also optimised the search code (rewritten in Ruby) so now it takes much less time for large results sets. Because it is so much faster, add a new [beall] tool like betitle but to search in all database fields. For becite/betitle/beall you can now use SHIFT to open ref directly in Bookends.
  • 1.1.0 — option to use RTF for becite/betitle temporary citations to enable bookends links copied into RTF comments/annotation aware apps like Scrivener. Added Workflow env variables citeUsesRTF to enable/disable this feature (default is disabled). Note it cannot match your font on paste of RTF, this is a limitation of RTF.
  • 1.0.9 - add quick add tool that allows you to select a DOI/PMID/ISBN/JSTOR in any app and use the new quick add tool in BE >13.0.3
  • 1.0.8 — allow author or editor search for becite, better chinese fix
  • 1.0.7 — try to get search for chinese authors to work
  • 1.0.6 — add betitle that searches within the reference title for a word.
  • 1.0.5 — add ⌥ to bebib to paste pandoc footnote format. bebib formatted ref now pastes in the target app. add environment variable to control the bibliography format for bebib
Last edited by iandol on Tue Aug 14, 2018 6:00 am, edited 3 times in total.

dave83
Posts: 38
Joined: Fri Oct 02, 2015 8:55 am

Re: Bookends Tools, an Alfred workflow of 8 different functions

Post by dave83 »

Iandol,

Wow, you've been busy! While I currently don't use Alfred, this post is giving me pause to consider it. Up to now my needs have been relatively simple, but just started using DevonThink Pro (DTP) to help correlate and manage my research. I'm currently using it in parallel with Evernote since I need to use DTP some more to be comfortable and understand its full feature set. DTP already integrates well with Bookends and I especially love the ability to have DTP reference the source Bookends documents in their stored location (no duplicates, minimizes database size, and ensures comments/highlights are current).

Have you ever used DTP? Do you know how well Alfred integrates with DTP? As you know, I'll always use Scrivener for my writing; including the incorporation of Bookends notes into Scrivener's research folder. However, once I get more familiar with DTP, I will be looking to automate and deeply integrate it into my workflow.

Again, wonderful work on expanding our scripts. you've truly expanded the horizon.
Cheers,
Dave

iandol
Posts: 315
Joined: Fri Jan 25, 2008 2:31 pm

Re: Bookends Tools, an Alfred workflow of 8 different functions

Post by iandol »

No experience of DTP, though there are lots of Scrivener users who use DTP as a core of their workflow; I find Bookends + Scrivener + mindmaps sufficient for my academic writing.

NilsMS
Posts: 53
Joined: Mon Sep 16, 2013 10:13 am

Re: Bookends Tools, an Alfred workflow of 8 different functions

Post by NilsMS »

Have you ever used DTP? Do you know how well Alfred integrates with DTP? As you know, I'll always use Scrivener for my writing; including the incorporation of Bookends notes into Scrivener's research folder.
DTP(O) (I recommend the Office-version) is highly scriptable. I use Alfred regularly to invoke DTPO-Apple scripts, but more complicated workflows should be possible.

BTW, @landol: many thanks for sharing your workflow from my side, too!

Cassady
Posts: 167
Joined: Thu Aug 22, 2013 3:48 pm
Location: Sqornshellous

Re: Bookends Tools, an Alfred workflow of 8 different functions

Post by Cassady »

These look fantastic - thank you for sharing. Will hopefully be able to give them a go in the next few days!

iandol
Posts: 315
Joined: Fri Jan 25, 2008 2:31 pm

Re: Bookends Tools, an Alfred workflow of 10 different functions

Post by iandol »

I updated this to include a new tool: you select a DOI/PMID/ISBN/JSTOR identifier in any app like a web browser, then trigger bequickadd and it will trigger the excellent new feature in BE 13.0.3+ to quickly add the reference to your database (thanks Jon for such a lovely new feature!)

If you don't use Alfred, you can use the Applescript directly, find its source here:

https://github.com/iandol/bookends-tool ... pplescript

Code: Select all

#!/usr/bin/osascript
tell application "System Events"
	keystroke "c" using command down
	
	tell application "Bookends"
		activate
		delay 0.1
	end tell
	
	tell application "System Events"
		keystroke "n" using {command down, control down}
		delay 0.6
		keystroke "v" using command down
		delay 0.1
		keystroke return --comment this out if you want to edit text before search
	end tell
end tell

taja
Posts: 41
Joined: Sun Feb 12, 2012 10:39 pm

Re: Bookends Tools, an Alfred workflow of 10 different functions

Post by taja »

These look awesome. Can anyone with any coding skills adapt them into Launchbar actions?

iandol
Posts: 315
Joined: Fri Jan 25, 2008 2:31 pm

Re: Bookends Tools, an Alfred workflow of 10 different functions

Post by iandol »

You could try asking on the LaunchBar forums, the source is all contained here:

https://github.com/iandol/bookends-tool ... ter/source

Over on the Scrivener forums someone asked for a Keyboard Maestro version, but the main issue is that for several of these tools they require a script to be able to return a list of items for further selection by the launch app. Can Launchbar do this? If not then bescopus, becite, bebib and betitle could not work, but the others should. I've never used Launchbar so I have no idea what it is capable of, I used to use some of these with Quicksilver and suspect it is similar (index the scripts directly).

taja
Posts: 41
Joined: Sun Feb 12, 2012 10:39 pm

Re: Bookends Tools, an Alfred workflow of 10 different functions

Post by taja »

thanks! I'll ask on the LB forums. I think Launchbar can indeed return a list of items for further selection.

fb3
Posts: 14
Joined: Tue Jan 09, 2018 8:23 am

Re: Bookends Tools, an Alfred workflow of 10 different functions

Post by fb3 »

Should Workflow 6 export proper subscript / superscript ?!? I do not get them...
However, it might just be that I do not fully understand the setup in Bookends :roll:

I enabled JSON output in the workflow variables (as suggested for speed)

So in Bookends I have 'Scan and Bib' settings like this:
- output as styled text: superscript ^, subscript | (would I need to select 'as BibTex' here? )

Also, I use the indicators like so "... bla bla CO|2| and ^15^N-labled ...". This should be OK, no?

In the Tex/BibTex settings sheet I do have the option 'Bracket acronyms in title' enabled... Not sure if this is relevant?

Cheers

iandol
Posts: 315
Joined: Fri Jan 25, 2008 2:31 pm

Re: Bookends Tools, an Alfred workflow of 10 different functions

Post by iandol »

BiBTeX / JSON are plain text styles so I don't think they can handle styled text like sub/superscript. I'm not sure what the proper workflow is for this using citeproc (what the BibTeX export is designed for). What is your overall workflow (what other apps are you using with Bookends)?

fb3
Posts: 14
Joined: Tue Jan 09, 2018 8:23 am

Re: Bookends Tools, an Alfred workflow of 10 different functions

Post by fb3 »

Hi.

I go from Bookends to Scrivener (with Alfred or by typing the cite keys)... Then compile to MarkDown (scrivomatic/ pandocomatic)...
I do have a fair bit of references with chemical symbols (CO2, N2O, ... 15N). Now, in the Text in scrivener I simply write them in Markdown (N~2~O, CO~2~, ^15^N, ...). I would do the same in Bookends, but if I do that they are escaped in the export... Or do I write in latex notation in Bookends (CO$_2$)?

Maybe I should use a specific output formatter? Or use LaTeX style sub-/superscript in Bookends and have it converted in my MD file?

C

fb3
Posts: 14
Joined: Tue Jan 09, 2018 8:23 am

Re: Bookends Tools, an Alfred workflow of 10 different functions

Post by fb3 »

@iandol

Is there a difference in the API call your Alfred uses to the regular export functionality in Bookends?

To summarise I basically wonder:
- How would I encode a subscript/ superscript in my Bookends library (CO|2|, CO~2~, CO$_2$)? No preference, whatever people suggest
- To be honest, I find the "Scan & Bib" preference section pretty confusing. What would I need to set there for this to work? Is this even relevant in the workflow discussed? Should I use Output text as BibTex or StyledText if I build the bib database using the Alfred script? Do I have to specify the superscript/ subscript characters in the dialog? Do I have to disable bracket acronyms in title in the Tex/ Bibtex pane?!?

Cheers,
fb3

iandol
Posts: 315
Joined: Fri Jan 25, 2008 2:31 pm

Re: Bookends Tools, an Alfred workflow of 10 different functions

Post by iandol »

Hi fb3,

The tool that makes the bibliography in the workflow you are describing is citeproc using the CSL style files. So I think the answer should be found in the Zotero / Mendeley / Papers help docs somewhere.

I tend to use unicode sub/superscripts for most of my day to day sub/super needs as they are much more robust (I have an Alfred snippet to quickly paste e.g. ×10⁻¹²³⁴⁵⁶⁷⁸⁹⁰ or ⁰¹²³⁴⁵⁶⁷⁸⁹⁄₀₁₂₃₄₆₇₈₉ into Scrivener), though I have no refs with sub/superscripts in the title, but unicode characters should pass through most systems?

I suspect the formal solution will involve using <sup> and <sub> somewhere...

The BibTeX exporter script in Bookends tools should produce the same BibTeX output as the manual export in Bookends, and for testing you should use the manual Bookends export.

The Scan & Bib settings shouldn't matter too much if you are using the Alfred tool to generate temp citations, but I do have mine set up like this:
Screen Shot 2018-02-05 at 15.08.25_SMALL.png
Screen Shot 2018-02-05 at 15.08.25_SMALL.png (47.27 KiB) Viewed 10502 times
And my Pandoc.fmt uses $@$u1 to generate the @user1 key

EDIT: yes, it is <sub> and <sup> http://docs.citationstyles.org/en/1.0/r ... hin-fields — but the question is whether this works via pandoc and whethere you can put these in BE and they would make their way through without being escaped. I don't have time to test...

iandol
Posts: 315
Joined: Fri Jan 25, 2008 2:31 pm

Re: Bookends Tools, an Alfred workflow of 10 different functions

Post by iandol »

If anyone can help test, I rewrote the becite/bebib/betitle tools to allow multiple author/title and optional year search. Please can you download the beta workflow from github and let me know if it works OK on your system...

https://github.com/iandol/bookends-tools

Post Reply