Page 1 of 1

NodeJS library to sync Zotero data with bookends using JXA

Posted: Mon Apr 26, 2021 9:02 am
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.

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

Posted: Tue Apr 27, 2021 2:49 am
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)

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

Posted: Tue Apr 27, 2021 3:09 am
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.

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

Posted: Thu Apr 29, 2021 11:47 am
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.

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

Posted: Thu Apr 29, 2021 11:50 am
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

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

Posted: Fri Apr 30, 2021 2:23 am
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).

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

Posted: Fri Apr 30, 2021 7:45 am
by Jon
Please send me the crash log.

Jon
Sonny Software