retorquere / zotero-better-bibtex

Make Zotero effective for us LaTeX holdouts
https://retorque.re/zotero-better-bibtex/
MIT License
5.21k stars 285 forks source link

Generate export file from list of citekeys #1503

Closed bwiernik closed 4 years ago

bwiernik commented 4 years ago

I'm using BBT with pandoc. I'd like to be able to add citations using citekeys, without having manually curate a collection to export the .bib or .json file at the end of the process.

Is it possible to generate a list an export file (BibLaTeX or CSL JSON) from a list of citekeys? If not, could a function be added for that, such as a button in the BBT Preferences and/or as a parameter passed to the CAYW interface?

retorquere commented 4 years ago

Would #1477 cover your needs? Sounds similar, but not necessarily the same.

bwiernik commented 4 years ago

I'm not really following what that is issue is about. I don't really know what the AUX scanner feature does.

bwiernik commented 4 years ago

The workflow I'm envisioning is being able to add citations to my Markdown document, then extract all of the citekeys at the end and use these to generate a .json file.

retorquere commented 4 years ago

I could add a method to the JSON-RPC endpoint.

As to #1477, during a bibtex compilation, multiple files are created as part of the process, one of which has extension .aux and it hold information about the references cited in the latex document. The aux scanner parses the aux file and populates a collection with it.

bwiernik commented 4 years ago

Oh, got it! Do you have a link to an example .aux file?

retorquere commented 4 years ago

If you don't have one, the #1477 workflow won't help you much; you'd know if you had one, because the latex compile litters the working directory with them.

Sample: output.aux

bwiernik commented 4 years ago

I rarely use TeX, mostly Markdown to HTML or DOCX. But I think I might be able to make a dummy aux file to fill this purpose.

retorquere commented 4 years ago

No, don't do that, I'll get you an endpoint you can post a bunch of citekeys to.

blip-bloop commented 4 years ago

:robot: this is your friendly neighborhood build bot announcing test build 5.2.21.6436 ("export endpoint")

Install in Zotero by downloading test build 5.2.21.6436, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

bwiernik commented 4 years ago

What's the API for the endpoint?

retorquere commented 4 years ago

It's going to be

curl http://localhost:23119/better-bibtex/json-rpc -X POST -H "Content-Type: application/json" -H "Accept: application/json" --data-binary '{"jsonrpc": "2.0", "method": "items.export", "params": [[<list of citekeys>], "<format>"] }'

but it doesn't work yet. In format you can specify either a name (better at the start not necessary) to get one of the BBT formats, or a translator guid to get any one that's available at that moment in Zotero.

retorquere commented 4 years ago

found the error. new build incoming.

blip-bloop commented 4 years ago

:robot: this is your friendly neighborhood build bot announcing test build 5.2.21.6438 ("look up by citekey, not itemID, genius")

Install in Zotero by downloading test build 5.2.21.6438, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

retorquere commented 4 years ago

I'll roll it into a release. I think GH is still on the fritz -- I saw your email, but don't see the message here.

bwiernik commented 4 years ago

Actually, it's not working for me. I misspoke and deleted the message.

curl http://localhost:23119/better-bibtex/json-rpc -X POST -H "Content-Type: application/json" -H "Accept: application/json" --data-binary '{"jsonrpc": "2.0", "method": "items.export", "params": [["Bonachecompensationexpatriatesreview2006", "BeckerModelbasedmetaanalysis2009"], "json"] }'

Then it gets no response. Debug ID: XPY8ASZX-euc

bwiernik commented 4 years ago

Ah, nevermind. It works if I specify csljson for the format, but not with just json.

bwiernik commented 4 years ago

Thank you again!

retorquere commented 4 years ago

My pleasure. I'll roll it into a release when I close a few issues I'm currently working on. I could have json work too BTW, it's just a matter of filtering out csl.

retorquere commented 4 years ago

Just json should work now too.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.