NodeJS library to sync Zotero data with bookends using JXA

Users asking other users for AppleScripts that work with Bookends.
Post Reply
cboulanger
Posts: 59
Joined: Mon Jan 28, 2008 6:18 pm

NodeJS library to sync Zotero data with bookends using JXA

Post by cboulanger »

Hi, in case anyone's interested: I started working a plugin for https://github.com/retorquere/zotero-sync to allow live synchronization (as opposed to export/import) from Zotero to Bookends:

https://github.com/cboulanger/zotero-sync-bookends

I've tried this before a few years back but the recent addition of real dictionary based AppleScripting (Thanks Jon!) and the introduction of Javascript scripting support in MacOS (JXA) has vastly improved development experience and performance. JXA is horribly under-documented and requires a lot of try-and-error, but once I found out how things translated from AppleScript to JXA it was nice to be able to stay in one language only. So if anyone is interested in how to do Bookends Scripting using Javascript, here are some examples:

https://github.com/cboulanger/zotero-sy ... c/index.ts

The library isn't finished yet, but works as a proof-of-concept. Contributors are welcome.

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

Re: NodeJS library to sync Zotero data with bookends using JXA

Post by iandol »

Great, thanks for this. i had previously played with JXA a bit as anything is better than Applescript, using it for one simple script but ultimately was more comfortable sticking to my preferred language Ruby for larger scripts. Having some clear examples of using JXA will be really helpful for future projects 8)

cboulanger
Posts: 59
Joined: Mon Jan 28, 2008 6:18 pm

Re: NodeJS library to sync Zotero data with bookends using JXA

Post by cboulanger »

@landol Yes indeed I was also happy to find out that I could avoid AppleScript, but it is sad how little attention JXA seems to be getting from Apple - you almost have to guess everything. Luckily, we now have debugging support with the Safari web inspector, which makes try & error at least bearable.

cboulanger
Posts: 59
Joined: Mon Jan 28, 2008 6:18 pm

Re: NodeJS library to sync Zotero data with bookends using JXA

Post by cboulanger »

The Zotero to Bookends synchronization script now is relatively stable: https://github.com/cboulanger/zotero-sync-bookends

Bookends itself doesn't seem to particularly like being scripted - it sometimes crashes when trying to sync really big libraries (>10.000 items).

Other than that, I am pretty happy to have Bookend's lightening-fast search features to query my Zotero group data.

Jon
Site Admin
Posts: 9107
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: NodeJS library to sync Zotero data with bookends using JXA

Post by Jon »

Crash? Or error message (and app continues to run)? In either case, you can send the log or the stack trace to us @ support@sonysoftware.com

Jon
Sonny Software

cboulanger
Posts: 59
Joined: Mon Jan 28, 2008 6:18 pm

Re: NodeJS library to sync Zotero data with bookends using JXA

Post by cboulanger »

Thanks, Jon, I will! It completely crashes and afterwards, all the groups programmatically created with

Code: Select all

libraryWindow.groupItems.push(bookends.GroupItem({name:"new group's name"}));
are gone. They can be retrieved by "Flatten Groups List Hierarchy", but are then in some previous state (the script renames the groups often to store the synchronization state - I know that is not how Bookends groups are supposed to be used, but it should be possible in principle).

Jon
Site Admin
Posts: 9107
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: NodeJS library to sync Zotero data with bookends using JXA

Post by Jon »

Please send me the crash log.

Jon
Sonny Software

Post Reply