Closed SterlingHooten closed 1 year ago
Hi! Thank you for raising this issue and #1.
I've been slowly implementing some changes in zotra over time that I haven't cleaned up to put here.
The one I've implemented uses completing-read-multiple
and asks the user to select which of the items should be fetched, and then only those items are fetched from the server.
I'll clean up the code and push the changes. If it turns out to be slow, we can always add more options and change the implementation.
I've add the option to handle multiple responses and variables to configure the behavior when there are multiple responses. I'm closing this issue as resolved. Feel free to raise another issue if there are any problems with it.
Thank you so much for implementing this!
I've been (casually) testing it for the past month and it seems to work well so far.
When the Zotero server detects multiple DOIs or other resource identifiers it will return a JSON object with the possible resources listed as 'items:'. These are intended to be selected from by the user, and then POSTed back to the Zotero server to actually fetch the JSON citation for them.
These responses come back wrapped in curly braces rather than square brackets, and will currently give an error with Zotra and fail (as the Zotero server expects an array).
I've hacked up a solution but still haven't determined where to put the selection framework (discussed afterwards).
The Zotero server project website gives an overview of the process for dealing with multiple options, but I'll reiterate them here. You first POST a standard request like:
Which gives back a response:
To make a selection, delete unwanted results from the items object and POST the returned data back to the server as application/json.
Which returns a JSON array
To implement this in Zotra I first tried to detect whether the response is multiple or not:
If it is we can use
swh-zotra-get-json-from-multiple
to get the responses by querying the Zotero server again with content type "application/json".Now this can be treated the same as a typical response and fed into
zotra-get-entry
. I've rewritten it to simply check whether the initial response contains items, and if so to query again.In this configuration
swh-zotra-get-entry
will return more than one bibtex entry for an initial response that contains multiple items. Without a selection framework interjected at that point I'm imagining some of the Zotra functions will fail.The Zotero devs are assuming there's an interactive pop-up that a user can select from. In my implementation I have a separate capture frame come up and fetch the URL data from Safari.
One possibility would be to select from the `items:` that are in the JSON object initially returned by the Zotero server. In certain circumstances (e.g., search through SCOPUS or the NIH site) a large number (>300) of potential candidates may be returned. Selecting at this point might be faster (untested), as the Zotero server would only need to fetch the selected items.
Another possibility would be to fetch all of the items automatically, get the bibtex data back from the Zotero server, and then select on the bibtex entries. This has the advantage of simplifying the Zotra library (as selection is then a problem for whatever system is calling it). It also would be noninteractive.
Perhaps it's best to just implement both of these? And then have some variable or argument to determine where the selection should be made.