Jump to content

Bookends Tools — A curated toolset for Bookends reference manager


iandol

Recommended Posts

13 minutes ago, iandol said:

 

@Cassady — I'm a bit confused, BE Tools already uses OneUpdater, the settings appear correct and all 11 tools are connected to it. So it should not need any manual configuration, but be triggered when any tool executes.

 

 

 

Wait, what??! ?

 

Wow. I just maximised the Alfred editor, and saw the OneUpdater node, top-left. 

Clearly, I was the confused one!

 

I clearly didn't read properly, and thought the user needed to add the node, should they prefer. 

Gah!

 

That said, somewhere, something isn't working as it should.

The workflow is still sitting on version 1.2.4, which is why I tried to drop in OneUpdater in the first place (after seeing that new versions had dropped), thinking it would then do the updates.

 

Regardless, I have disabled my node now, and will wait and see if it triggers as it was initially intended to [I have dropped the 'frequency' down to "0", just to test].

 

Thanks for the clarification, and apologies for introducing some confusion into the mix! ?  

Edited by Cassady
Link to comment

@iandol I'm afraid I get another error with 1.2.6 when using beall. Here's what ocmes up:

[2018-07-11 17:02:06][ERROR: input.scriptfilter] Code 1: /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:215:in `processAuthor': undefined method `chomp' for nil:NilClass (NoMethodError)
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:198:in `parseAuthors'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:85:in `block in getRecords'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:81:in `each'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:81:in `each_with_index'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:81:in `getRecords'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:227:in `doSearch'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:254:in `<main>'
[2018-07-11 17:02:07][ERROR: input.scriptfilter] Code 1: /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:215:in `processAuthor': undefined method `chomp' for nil:NilClass (NoMethodError)
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:198:in `parseAuthors'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:85:in `block in getRecords'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:81:in `each'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:81:in `each_with_index'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:81:in `getRecords'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:227:in `doSearch'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.16824124-417E-42A2-BC67-A5CA41BCFCAD/findReferencesAll.rb:254:in `<main>'

Link to comment

@taja — ok, the new author parsing didn't handle empty author fields, this wasn't an issue for becite, but was for beall. For the next release I should retrieve both authors and editors, and use editors if authors is empty, but I don't have time to do that for now, so author becomes "Unknown"...

 

V1.2.7 released, please retest and let me know how it goes.

Link to comment

@iandol Hi - just tested beall and betitle on 1.2.7 and it works *except* when I search for one term that should return a very large number of results (for reference, when I type it into search field in Bookends it returns nearly 3000 results). Neither beall nor betitle return any results when searching for it. I don't know if the problem relates to the sheer number of results. This might be a bit of an edge case, because beall works fine in all other cases, e.g.:

2018-07-12 09:46:21][trigger.hotkey] Processing output of 'input.scriptfilter' with arg ''
[2018-07-12 09:46:23][input.scriptfilter] Queuing argument 'adcock'
[2018-07-12 09:46:24][input.scriptfilter] Script with argument 'adcock' finished
[2018-07-12 09:46:24][input.scriptfilter] {"comment":"NAMES=adcock | YEAR= | SQL=(allFields REGEX '(?i)adcock')","items":[{"uid":"9203","arg":"9203","title":"Unknown  (2007)","subtitle":"Modern Political Science: Anglo-American Exchanges Since 1880","icon":{"path":"file.png"}},{"uid":"86192","arg":"86192","title":"Adcock R  (2007)","subtitle":"Interpreting Behaviouralism","icon":{"path":"file.png"}},{"uid":"57741","arg":"57741","title":"Adcock R & Bevir M  (2007)","subtitle":"The Remaking of Political Theory","icon":{"path":"file.png"}},{"uid":"24715","arg":"24715","title":"Ball T  (2007)","subtitle":"An Ambivalent Alliance: Political Science and American Democracy","icon":{"path":"file.png"}}],"length":4}


However, when I search for a term that should yield a very very high number of results:


beall:

[2018-07-12 09:33:59][ERROR: input.scriptfilter] Code 1: /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesAll.rb:216:in `processAuthor': undefined method `chomp' for nil:NilClass (NoMethodError)
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesAll.rb:199:in `parseAuthors'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesAll.rb:85:in `block in getRecords'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesAll.rb:81:in `each'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesAll.rb:81:in `each_with_index'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesAll.rb:81:in `getRecords'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesAll.rb:228:in `doSearch'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesAll.rb:255:in `<main>'

betitle:

[2018-07-12 09:41:51][ERROR: input.scriptfilter] Code 1: /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesTitle.rb:216:in `processAuthor': undefined method `chomp' for nil:NilClass (NoMethodError)
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesTitle.rb:199:in `parseAuthors'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesTitle.rb:85:in `block in getRecords'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesTitle.rb:81:in `each'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesTitle.rb:81:in `each_with_index'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesTitle.rb:81:in `getRecords'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesTitle.rb:228:in `doSearch'
    from /Users/Was/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.5761D1A7-6E32-41AB-9C99-22930F789ECE/findReferencesTitle.rb:255:in `<main>'

 

Link to comment

@taja — does V1.2.5 handle the large results list? I've not tested with such a large number, but the error you show is the same as previously, and it doesn't make too much sense. It occurs when processing the author initial, but I've tested authors who have a comma after the family name but no first name or initials and it should work. I've added more defensive checks to try to not trigger this error. Please download the updated script manually and run it from the command line for testing or you can replace the version in your installed workflow:

 

https://github.com/iandol/bookends-tools/blob/master/source/findReferencesAll.rb 

 

Let me know if it works, I don't think this is to do with lots of results, but references that have mangled author names or something, and that large search is revealing the issue...

Edited by iandol
Link to comment

Updated to V1.2.8 which adds phrase search delimited by single quotation marks (without quoting words are searched in any location/order):

 

https://github.com/iandol/bookends-tools/releases/tag/V1.2.8

 

43035829-669f857a-8d28-11e8-9fc6-18a6557

 

Also just to remind you, if you want Quicklook to work, you should change the attachmentsFolder variable to point to your Bookends attachments path. All PDFs should be in the same folder, as it would be too slow to try to find the path automatically… 

Edited by iandol
Link to comment

V1.2.9 is released:

  • 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}).
  • If the authors field is empty for a reference, we now try to use editor names instead in the Alfred results list.
Link to comment
  • 1 year later...

I am getting this error, when I set the hotkey to double tap control key. I am on BE 13.3.1 and Alfred 4.

 

[15:21:12.579] Bookends Tools[Hotkey] Processing complete

[15:21:12.580] Bookends Tools[Hotkey] Passing output '' to Script Filter

[15:21:13.074] Bookends Tools[Script Filter] Queuing argument ''

[15:21:13.539] Bookends Tools[Script Filter] Script with argv '' finished

[15:21:13.543] ERROR: Bookends Tools[Script Filter] Code 1: 112:115: execution error: Bookends got an error: Can’t set doi to "". (-10006)

/Users/sramadug/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.94979EC6-3570-4874-86B3-26DCA9AC9F78/scopusSearch:240:in `<main>': undefined method `split' for nil:NilClass (NoMethodError)

 

how can I resolve this error?

 

Thanks,
Sai

 

Link to comment
  • 2 months later...
On 2/26/2020 at 5:23 AM, skrama87 said:

I am getting this error, when I set the hotkey to double tap control key. I am on BE 13.3.1 and Alfred 4.

 

Sorry for the late reply, I don't check here very often. scopusSearch needs a DOI in the Bookends ref to work, and you may need to generate your own API key...

 

EDIT: actually there was a small change in the Bookends Applescript interface that causes the grab-selected-DOI to fail. I will make a fix and update tomorrow.

Edited by iandol
add solution
Link to comment

Released V1.3.3, focussed on the Scopus Search tool:

 

https://github.com/iandol/bookends-tools/releases/tag/V1.3.3

 

  • Update the applescript interface used to control Bookends to use the new events system that is faster and fix an error.
  • Improving error checking when fetching the scopus API data, and working round an annoying Ruby crash when the system proxy is set (we just bypass the proxy for now).
  • Added a new environment variable scopusBaseURL to specify a replacement base url prefix, if for e.g. you access Scopus through a proxy. For example, the default address is https://www.scopus.com but my institution accesses through https://www-scopus-com-443.webvpn.las.ac.cn/ so I set that and URLs get rewritten to use the new base URL.
Edited by iandol
Link to comment
  • 2 months later...

V1.3.4 released:

 

https://github.com/iandol/bookends-tools/releases/tag/V1.3.4

Changes:

  • A few releases back (~V13.2), Bookends added a dedicated Quick Add Applescript command. I couldn't get it to work in the background at the time and continued to use GUI scripting. Thanks to a hint from @bcdavasconcelos I realised it was a problem in my code, and this works fine in the background, so I upgraded bequickadd to use this more efficient and reliable command method.
  • Also a tweak for betobibtex, if there is a parsing error when pandoc-citeproc tries to convert the BibTeX output to JSON (e.g. your citekey/user1 field is empty), the user will be warned with a display notification and the BibTeX will not be deleted so the user can check it.
Edited by iandol
Link to comment
  • 2 months later...
On 8/14/2018 at 10:58 AM, iandol said:

V1.2.9 is released:

  • 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}).
  • If the authors field is empty for a reference, we now try to use editor names instead in the Alfred results list.

This is a brilliant utility, thanks. However when I use the modifier keys to change the citation format to MMD or Pandoc I only get the [#] or [@] part and no author or date information. I've checked through the workflow and I cannot see the cause. Any help would be gratefully received.

Link to comment
  • 7 months later...
On 10/31/2020 at 9:25 PM, tenbobnote said:

This is a brilliant utility, thanks. However when I use the modifier keys to change the citation format to MMD or Pandoc I only get the [#] or [@] part and no author or date information. I've checked through the workflow and I cannot see the cause. Any help would be gratefully received.

Sorry I haven't been on this forum for a while, do you still have this problem? It is working fine for me, does it depend on what citation format you're using?

Link to comment
  • 2 months later...
On 6/4/2021 at 7:36 AM, iandol said:

Sorry I haven't been on this forum for a while, do you still have this problem? It is working fine for me, does it depend on what citation format you're using?

I just tried it and I am experiencing the same issue with several different citation styles.

Link to comment

OK, one simple workaround for the moment is to set the tempCitationStyle variable in the workflow to your preferred format (in my case Pandoc), then you don't need to use any modifiers:

1906024961_ScreenShot2021-09-01at08_19_54.png.34a7d676d3d2e67ea25d202c6117c2ab.png

 

At the moment when you press ⌘ or ⌥ modifiers it routes to a shell script  and without a modifier it uses a ruby script and the tempCitationStyle variable — again both routes are working here (I retested, using the latest Bookends and Alfred versions) and I can't see an obvious bug (not that that means one doesn't exist 🤪). The Bibkey itself is returned here in the script:

 

https://github.com/iandol/bookends-tools/blob/master/source/formatCitation.sh#L15

 

which must be the part failing on your system. I could update the Applescript fragment to use the newer AS library but that is slower than the older events system in my experience. The script also specifies bash and now the default is zsh but bash is still shipped AFAIK...

 

Does setting tempCitationStyle help? What version of Bookends and Alfred?

 

If you run the Applescript directly (in script editor) do you get a correct bibkey back (you need to replace 54808 with a unique ID from your own library😞

 

tell application "Bookends"
    return «event ToySRFLD» "54808" given string:"user1"
end tell

1062342274_ScreenShot2021-09-01at08_55_53.png.53f84e8a60433a74a8659860c986c1f0.png

 

Edited by iandol
incomplete text
Link to comment

Thank you! After I tried the script there indeed was no result and then it occurred to me: For some reason I do not understand, there were no cite keys in the user1 field even though I was sure that I checked "create cite key when importing" in Bookends' setting. Ticked it again, manually created citekeys using CMD+Shift+K, now everything is working as expected. Thank you!

 

925912973_Screenshot2021-09-01at14_24_01.thumb.png.527e693e09dd1369c1cac526659ccd89.png

Edited by analogue_man
Link to comment
  • 3 weeks later...
  • 3 weeks later...

Hi, there was a bug in Bookends V14.0 with the Applescript interface, a silent update fixed it. The bundle id was not being used so that wasn't the problem.

 

I've also updated bookends-tools to V1.3.9:

 

https://github.com/iandol/bookends-tools/releases/tag/V1.3.9 

 

Between the last public release and the latest: https://github.com/iandol/bookends-tools/compare/V1.3.4...V1.3.9

 

  • Allow ⇧⌃to copy the bookends:// link as text.
  • allow ⌘⌥ to open an attached PDF directly.
  • betobibtex: Allow using a customised BibTeX formatter, default is the builtin BibTeX, but for example you can make a modified format removing address and abstract that makes export faster and the resultant files much smaller.
  • bebib: make sure this tool uses the citeUsesRTF Alfred environment variable so you can choose RTF or plain text output.
  • There is also a new tool, beconvert, which is only useful if you want to convert author-date formatted citations in e.g. Word, like (Barlow et al., 1963), to temporary user key citations. This really depends on your BibTeX keys also conforming to [authordate], it will not work for any other cases. See https://www.sonnysoftware.com/phpBB3/viewtopic.php?f=6&t=5548 for the details...
Edited by iandol
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...