Giter Site home page Giter Site logo

iandol / bookends-tools Goto Github PK

View Code? Open in Web Editor NEW
95.0 8.0 9.0 8.47 MB

Alfred Workflow to Integrate with Bookends, an academic reference manager/bibliography tool for macOS

License: MIT License

JavaScript 5.77% AppleScript 52.55% Ruby 36.57% Shell 1.64% Python 3.47%
bookends alfred alfred3-workflow scrivener bibliography pandoc biblatex alfred4-workflow alfred-workflow citation

bookends-tools's Introduction

Bookends Tools

Bookends is an excellent bibliographic/research manager for macOS. This Alfred workflow curates around 11 tools together in one interface to integrate between Bookends and other apps. You can use Alfred keywords (be…) and/or your preferred key binding to trigger them (edit the Hotkey trigger). The workflow is designed for Alfred 3 and 4, and should keep itself up-to-date using OneUpdater.

Download it here…

Workflow screenshot

Note: the tools denoted by 📄 utilise Applescript System Events to trigger keyboard bindings with delays; the delays work fine for me but may need to be adjusted for you. If the tools seems to not work try to manually type V and enter.

key: 📄: select some text in another app then trigger tool🗄: select reference(s) within Bookends then trigger tool⌨: trigger tool and enter some text  

  1. beidsearch 📄 — Find a selected uniqueID in Bookends. For example, if you have a temporary citation like {Koffka, 1922, #6475} in your word-processor, double-click select the Bookends ID 6475, then trigger this workflow and it will find the reference in Bookends for you.
  2. bebrowser 📄 — Search selected text in Bookends browser. For the Pubmed interface you should select this manually in the bookends browser before triggering this tool. If the automatic paste into the search field fails, press V and ENTER to trigger the search.
  3. berefsearch 📄 — Take selected text like "(Doe et al., 2005)" citation, clean it up to become "Doe 2005" and send it to Bookend's quick search. This is great because you can take a formatted ref in a text document and search for the first author/year, then quickly paste back (⌘Y for Scrivener) the Bookends style temporary citation in its place!
  4. bequickadd 📄 — Take a selected DOI / PMID / ISBN / JSTOR in any application and send it to Bookend's Quick Add (added in Bookends 13.0.3+) to quickly add this reference to your database.
  5. betobibtex ⌨ — You enter the name of a Bookends static/smart group name and this will create a BibTeX bibliography file for those particular groups. Very useful for Pandoc and/or LaTeX workflows -- though note that recent Bookends versions can auto-sync the database to a BibTeX file (see tips here). You can optionally generate JSON. You can configure the export path in the workflow variables (default Desktop/). betobibtex
  6. betoopml 🗄 — Select multiple references within Bookends, then run this to create an OPML file which you can import into Scrivener or other OPML-aware tool. This will contain the abstract and notes which is very useful for research. It contains links back to the Bookends reference. You can configure the export path in the workflow variables (default Desktop/).
  7. bescopus 🗄 — Select a reference with a DOI in Bookends, then trigger this to search Scopus with that DOI. It will return an inline results list for the Scopus entry AND the Cited-by page if available. Select an entry to open that page. Environment variables: appendScopusNotes [true/false] — copy the URLs into the Notes field | scopusKey [value] if you have registered for your own key enter it here | scopusBaseURL [url] — If you got through a proxy, enter the URL base to replace https://www.scopus.com/. bescopus
  8. becite ⌨ — Activate becite in any application to search your bookends database with one or more author/editor names and an optional year (for example: friston hobson 2014), and get a floating inline results list. You can then select a result and paste the selected ref as a temporary citation ( pastes Pandoc style, pastes MMD style, pastes formatted ref, open ref in Bookends, ⌘⌥ open PDF directly, [fn] opens attachment in Bookends, ⇧⌃ copies the bookends:// link as text). For becite, betitle. and beall there is also a workflow environment variable (citeUsesRTF & commentText) to copy the Pandoc/MMD temporary citation using RTF; this puts the link back to bookends into an RTF comment (and/or annotation in Scrivener). becite
  9. betitle ⌨ — Enter one or more words contained in the title or keywords and an optional year, and get a floating inline results list. You can then paste this as a temporary citation ( pastes Pandoc style, pastes MMD style, pastes formatted ref, open ref in Bookends, ⌘⌥ open PDF directly, [fn] opens attachment in Bookends, ⇧⌃ copies the bookends:// link as text). betitle
  10. beall ⌨ — You enter one or more words contained in any field and an optional year, and get an inline results list. You can then paste this as a temporary citation ( pastes Pandoc style, pastes MMD style, pastes formatted ref, open ref in Bookends, ⌘⌥ open PDF directly, [fn] opens attachment in Bookends, ⇧⌃ copies the bookends:// link as text).
  11. bebib ⌨ — You enter one or more author/editor names and an optional year, and get an inline results list. You can then paste the selected ref as a formatted reference (see workflow variable citationStyle; ⌘ pastes Pandoc style, ⌥ pastes MMD style).
  12. beconvert 📄 — This has a very specific use, say you have an author-date formatted intext citation (Barlow et al., 1963), select it and run this to get a temporary citation using the most likely BibTeX key [barlow1963]. It allows me to take an author-date formatted manuscript from someone else and as long as I have regular BibTeX keys [authoryear], manually converts the intext citations to a form Bookends or Pandoc can then scan, saving some time.

Workflow variables

variables

There are several workflow variables which let you modify the functionality of the tools:

  • tempCitationStyle : for becite / betitle / beall the default temporary citation style is Bookends (with key modifiers allowing Pandoc and MMD formats). However if you will never use the Bookends format, you can set tempCitationStyle to Pandoc / MMD / LaTeX and the default temp citation will be set accordingly.
  • attachmentsFolder : relative or absolute path to where your Bookends attachments are stored. This is used so that you can Quicklook results with PDF attachments from becite / betitle / beall tools (press [shift] or ⌘Y)
  • BibTeXtoJSON (default = FALSE): allows you to convert the BIB file to a JSON file, which at least for Pandoc-citeproc is much faster (~3X) to then process for the bibliography. Requires pandoc-citeproc for the conversion...
  • citeUsesRTF (default = FALSE) & commentText: for the becite and betitle tools for Pandoc/MMD temporary citations, if you enable this then the temp citation is copied as RTF with a comment-enclosed link back to Bookends. In Scrivener if you enable Preferences▸Sharing▸Import comments as inline annotations, then the comment becomes an inline annotation. commentText is the text that is linked back to Bookends (default is @). For bebib tool it will toggle whether the formatted ref is plain or RTF.
  • customExportFormat (default = EMPTY) : for betobibtex the default is to use the standard BibTeX.fmt export format. This includes abstract and addresses which are not always needed for bibliography generation. You can therefore specify a custom format, for example like this BibTeX-Minimal format, which omits these fields and results in a faster BibTeX generation and smaller resultant file.
  • protectBibTitles (default = FALSE): makes titles in the BIB file {{ wrapped }} so the case is not changed in subsequent processing.
  • citationStyle (default = APA 6th Edition): is the Bookends bibliographic style used by bebib when outputting the formatted reference.
  • exportPath (default = Desktop): used by betoopml and betobibtex
  • appendScopusNotes (default = FALSE): allows you to toggle the behaviour whereby the Scopus URLs are appended back into the Bookends reference note stream.
  • scopusKey: your personal Scopus API key (see below).
  • scopusBaseURL: If you use a proxy that changes the base URL, enter it here to replace the default https://www.scopus.com/.

Scopus Info

For the Scopus search tool, ideally you should register for your own Scopus API key (without it it will use the demo key which may or may not work) and enter it in the workflow variables. The Scopus URLs also benefit from an institutional subscription, otherwise you will see a Scopus preview (which still contains useful information). If your institution offers a proxy, then you can enter the scopusBaseURL variable to use that.

Sources

Several of these very useful tools have been modified from the following sources:

betoopml

Thanks to Dave Glogowski (dave83); Bookends forum thread

betobibtex

Thanks and MIT copyright to Naupaka Zimmerman; Bookends forum thread | Original Gist

becite & bebib

Thanks to kseggleton for the original applescript version; Bookends forum thread

OneUpdater

Thanks to Vitor for his excellent update system for Alfred workflows: OneUpdater

bookends-tools's People

Contributors

iandol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bookends-tools's Issues

Latest update is not Latex friendly

The first script used user1 for inserting references. It required minimal modification to use it for bibtex citation.

#!/usr/bin/osascript
-------------------------------------------------------------------------
-- SCRIPT FOR SETTING CITATION USING {AUTHOR, DATE #UID}
-------------------------------------------------------------------------
on run argv
	set refItem to argv as text
	tell application "Bookends"
		-- Extract the Citekey
		set rBib to («event ToySRFLD» refItem given string:"user1")
		set refBib to text items of rBib
		set AppleScript's text item delimiters to {"'"}
		set AppleScript's text item delimiters to {""}
		-- Set citation
		set refCitation to "\\cite[]" & "{" & refBib & "}"
		set the clipboard to {Unicode text:refCitation}
	end tell
end run

Now, it dropped user1 to construct things from the author and unique ID.
The unique ID is good for scanning. So is the User1. I don't know why you want to move to the unique ID system. The unique is problematic for the latex usage (without scanning).

#!/usr/bin/osascript
-------------------------------------------------------------------------
-- SCRIPT FOR SETTING CITATION USING {AUTHOR, DATE #UID}
-------------------------------------------------------------------------
on run argv
	set refItem to argv as text
	tell application "Bookends"
		-- Extract first Author
		set refAuthorList to («event ToySRFLD» refItem given string:"authors")
		set AppleScript's text item delimiters to {","}
		set refAuthors to text items of refAuthorList
		set AppleScript's text item delimiters to {"'"}
		set refAuthor to first item of refAuthors
		set AppleScript's text item delimiters to {""}
		-- Extract date
		set refDateRaw to («event ToySRFLD» refItem given string:"thedate")
		set cmd to "echo '" & refDateRaw & "' | sed 's/\\([0-9]*\\)\\(.*\\)/\\1/g'"
		set refDate to (do shell script cmd)
		-- Set citation
		set refCitation to "{" & refAuthor & ", " & refDate & ", #" & refItem & "}"
		set the clipboard to {Unicode text:refCitation}
	end tell
end run

Quickadd not working when evernote is open

Thanks very much for this very useful tool! I recently found that if my evernote is open, I cannot use the quickadd function to import DOI directly to Bookends. The DOI is still copied to the clipboard but left in the evernote instead of being sent to Bookends. Please could you look into this issue? Much appreciated!

betobibtex: nil object error

I'm getting an error when running betobibtex. It reads: ‘An error has occurred: nil object’. It then offers the opportunity to send error details to SonnySoftware by email, which read:

----------------------------------------------------------------
                   Diagnostic Information
----------------------------------------------------------------

Error message: nil object

Trace:

RaiseNilObjectException
HitsAndGroupWindow.HitsAndGroupWindow.getGroupNameList%s%o<HitsAndGroupWindow.HitsAndGroupWindow>b
HitsAndGroupWindow.HitsAndGroupWindow.returnGroupNamesAppleEvent%%o<HitsAndGroupWindow.HitsAndGroupWindow>o<AppleEvent>
App.Event_HandleAppleEvent%b%o<App>o<AppleEvent>ss
XojoFramework$1288
_Z20aeDispatchAppleEventPK6AEDescPS_mPh
_ZL25dispatchEventAndSendReplyPK6AEDescPS_
aeProcessAppleEvent
AEProcessAppleEvent
_DPSNextEvent
-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
-[NSApplication(NSEvent) nextEventMatchingMask:untilDate:inMode:dequeue:]
XojoFramework$1294
XojoFramework$1295
Delegate.Invoke%%
Application._CallFunctionWithExceptionHandling%%o<Application>p
XojoFramework$9814
XojoFramework$1294
-[NSApplication run]
XojoFramework$9816
RuntimeRun
_Main
main
start

Open PDF?

Hi. Is it possible to open the PDF associated with a reference? I know I can use shift with becite to see a preview, but I would like to be able to open the pdf directly. Perhaps a bepdf, which searches the library and for the selected reference in the menu displays the pdf in the default viewer? Thanks much. Bookends-Tools is super!

Swap author (result text) and (title) subtext

Hiya,
Thank you for the workflow.
Is there a simple way to have the paper/book title feature in the result text field and the author/year in the subtext field? i.e. swap them around.
Cheers,

Conversion to JSON issue

First of all, thank you for these amazing tools. I noticed that you are also the author of scrivomatic which I have been using with Scrivener and these bookends tools to make reference managing a breeze.

The issue that I am having with toBibTeX and the subsequent conversion to JSON is at the JSON conversion step. I had a different issue with this back in 2020 (#8), but none of the cite keys are empty and I have even gone through the keys to make sure that none of them were duplicates. The attached screenshot is the error that I am getting. I narrowed down the cause and it appears to have been caused by special characters in the abstract field (see second screenshot). Not sure how to put that special character in a SQL search, but I thought that I would bring it to your attention in case anyone else has a similar issue.

Thank you again.
Screen Shot 2022-02-22 at 21 24 49
Screen Shot 2022-02-22 at 21 49 43

"An error has occurred: SQL Error line 1:42: unexpected end of file" in JSON export from Betools

Thanks so much for this wonderful set of tools!
I use this along with your scrivomatic/pandocomatic workflow.
It's fantastic!

I'm running into some trouble with the exporting of the BibTex file to JSON. It works with the smaller groups in
my library like a charm. But when I try to export the larger 1500+ references to a large JSON file, I get the following error:
"An error has occurred: SQL Error line 1:42: unexpected end of file"
I wrote to Jon at Sonny who said to contact you. I rebuilt the library, so it's not this.
And I'm trying to go through the bib entries to see if there is something malformed.

Do you have any thoughts as to what I might try? It might make sense to export a BibTex file and see if that is properly formatted. But I'm hoping that you have another suggestion before I start my weeding.

Maurice

Enhancement to becite request

Hi

becite would be even better if we could input modifiers ie page numbers, a prefix and a suffix, omit author, so that the user (me!) doesn't have to remember the necessary syntax.

TIA

Graeme

Blank JSON export

I ran into an issue of the betobibtex creating a blank JSON. If I set BibTeXtoJSON to false, I would then get a .bib file that was not properly formatted for pandoc-citeproc to read (the error stated that there was a "," and whitespace was expected). However, the issue appears to have arisen from the lack of an author in one of the citations or an incomplete citation generally. Once the offending citation was removed from the group, the JSON was created normally.

undefined method error

When I run bookends-tools, for any command that search the bookends db I get things like this:

ERROR: Bookends Tools[Script Filter] Code 1: /Users/roambot/Dropbox/Personal/Alfred/Alfred.alfredpreferences/workflows/user.workflow.F5BD40AB-DC91-4498-B088-6E70D00D7F15/findReferencesAll.rb:167:in `block in returnResults': undefined method `+' for nil:NilClass (NoMethodError)

Any idea what is happening here?

Two issues with toBibTeX script

The first is more of a request, the second is an issue I'm running into:

  1. do you know if it's possible to run this script with Launchbar? It seems that the script takes arguments (path and group), and I'm not sure how to insert those into Launchbar. If I wanted to encode those variables into the script itself, what would I change?
  2. I normally have the default format set to Chicago, though the insert citation format is set to pandoc. However, if I export it that way I just get a bunch of cite keys. If I change the default format to BibTeX, it does correctly export the BibTeX format, however, there are no line breaks either within a reference or between them so that it just looks like one big file with never ending text. Is there a setting I might have wrong here?

Thanks!

Add translator and editor to JSON string coming from findReferencesAll.rb

Hi Ian,
there is something I been meaning to ask.

The findReferencesAll.rb script returns authors and date as the title of the json string and title of the work as the subtitle. Could you point me out in the right direction so that I could add editor and/or translator as well? I gave it a try, but I am ruby illiterate.

Thanks!

BibTeX export

Sometimes when I use betobib export the exported bibfile does not contain valid bibtex but rather simply the list of entries in the form of their PDF title (e.g. citekey_title-with-no-spaces). This will be true even if I have the default format set to Bibtex. Do you have any idea why this would be?

Thanks again for these great tools.

toBibTeX with BibTeX markup

Hi iandol, first of all thank you very much for taking care of this great toolbox!

I use the toBibTeX workflow quite often. My problem is that it doesn't export the references in BibTeX markup, which means that all formatting (italics, superscripts etc.) are lost.

With the dictionary-based scripting methods it has now become possible to export with proper BibTeX markup. I made some corresponding changes to the code. It's not done in the most elegant way, and I was also not able to get the "repeat while" loop running. For larger groups it is considerably slower than your version.
Nevertheless, you may want to have a look at it and find a better way to integrate the changes.

Cheers,
Hannes

toBibTeX_HV.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.