(DT3 Bibliography) Formatted reference from Custom MD

Aha, I see. To be honest, my knowledge of AS is very rudimentary and I don’t know about HTTPS at all.

Still, DT3 has a built-in script that can take a JSON file and use the data populate the appropriate fields with it. It uses the DOI to get the JSON file from the web. If we could find a way to point the script to take the data from the appropriate Zotero entry, it would be ready to work.

Note: this would have to happen one record at a time, so a unique id such as the bib key would be ideal. Using the bib key, the script would send a request to get the appropriate record from Zotero in JSON format.

How does that sound to you?

If your knowledge of AS is rudimentary that makes you an expert compared to me. You shouldn’t have to know about HTTP – AFAICT, AS has http download support baked in. “Get from the web” is the same as “supports HTTP”, so that seems set.

It’d be trivial for me to get an entry based on its bibtex key. @rkaplan, you had some ideas on this?

Does that create a Sheet (with a fixed format). Or would it allow you full access to the data so you could create a Group of rich text documents in whatever desired format, such as the existing demo Pubmed Search template does?

But the question then is - how do we retrieve the Bibtex key?

I am hoping that retorquere can show us an example to retrieve data from Zotero and then collectively there is tons of experience on this group to use that data in different ways within DT3.

It seems to me the most straightforward way would be to take something like the existing demo Pubmed search template which runs a Pubmed search and creates DT3 groups with one rich text document per citation. But hopefully retorquere could change that so the input were not from a Pubmed search but rather the input were the contents of a Zotero collection.

I think if we had that example as a working script, then from there the DT3 group has enough experience to modify it for lots of other specific and useful situations.

I am referring to the download metadata smart rule. The behaviour would be exactly the same.

If you want to visually select stuff from Zotero and import it, that’s mostly already done with zotero CAYW (you’ll have to google it, because I can’t post links). I could add a CAYW format that returns pretty much whatever you like.

For a bibtex-key based solution, I could make available an URL that takes it as a parameter. I can’t show what that would look like because I can’t ^@#&%&%@# post links here.

This could work like the download metadata smart rule. You’d set the bibkey on DT3 and it would get the data attached to this bibkey on Zotero.

If do this @retorquere I would be happy to adapt the AS to make it work.

P.S.: http://retorque.re/zotero-better-bibtex/citing/cayw/

Very interesting - honestly I have not tried that smart rule yet.

Let me give that a try tonight and get back to you.

Can you give me an example how you incoprporated that into a smart rule and how you activate it and what the output is?

@rkaplan if you just want the CSL-JSON for any given collection, this is already available:

  • make sure you have BBT installed
  • right-click the collection of interest and select “Show BibLaTeX Server URL” from the popup menu
  • copy one of the URLs in the dialog that now appears and change the .biblatex at the end into .csljson
  • paste that URL into your browser, or have DT fetch it, etc

That URL gives you the CSL-JSON for that collection you selected in step 1.

@Bernardo_V I could add a method to the existing JSON-RPC endpoint to fetch an item by its bibtex key. The curl equivalent call would look something like

curl http://127.0.0.1:23119/better-bibtex/json-rpc -X POST --data-binary '{"jsonrpc": "2.0", "method": "item.fetch", "params": ["bibtexkey"]}'

if a web POST is hard to do, I could add a dedicated GET endpoint, but for POST I have all the plumbing in place.

edit: lookie here, me with the fancy URL-posting rights

Thanks - it may take me a few days to try out this and the smartrule option - I will give further thoughts after that

That’s cool. For anything that requires changes on the Zotero end of things I would need to invite you guys over to create an issue at https://github.com/retorquere/zotero-better-bibtex/issues; I have a workflow in place that can get you custom builds while we figure this out, but this workflow requires a github issue to work against.

1 Like

I have no ideia what all this means :upside_down_face:
What I need is a simple URL address to which I can attach the bibkey and get to the right JSON file. Is that possible?

Posting this on behalf of retorquere (who is limited in posts today as a new user by Discourse defaults)

It means

  • send an HTTP POST request (rather than the standard HTTP GET request)
  • to the URL http://127.0.0.1:23119/better-bibtex/json-rpc,
  • and when connected send the text {"jsonrpc": "2.0", "method": "item.fetch", "params": ["bibtexkey"]}

But it looks like applescript can’t easily do POST (man applescript is one broken language :roll_eyes:) so I could instead offer something like http://127.0.0.1:23119/better-bibtex/item?<something>.csljson which would just return the csl-json form of the item (or anything else you’d want). I can get you something to test with on github – I can’t easily get custom builds to you otherwise.

man applescript is one broken language :roll_eyes:

I would strongly disagree with this.

That’s like saying a screwdriver is broken because it doesn’t effectively hammer nails. :stuck_out_tongue:

1 Like

Hi

OK I tried out the various suggestions and here are my thoughts:

(1) The Download Metadata smart rule basically tries to do what Zotero has mastered over many years, i.e. identifying DOI for a document. I am not sure it would be much help to reinvent that wheel

(2) Using BBT in Zotero to create a URL with JSON output from a Zotero collection is very nice. I like the idea of the various endpoints you suggest that could be created. As a first step to get what I think would be a working useful integration, would it be possible to modify the existing Pubmed search script (Data - New From Template-Search-PubMed) to paste the BBT-created URL as the “search” and then have the script create individual documents in DT3 just as the script does now for the search results?

(1) The Download Metadata smart rule basically tries to do what Zotero has mastered over many years, i.e. identifying DOI for a document. I am not sure it would be much help to reinvent that wheel

Many people are not running Zotero (or other apps you are referring to), so it’s not reinventing the wheel.

Agreed

I did not mean to suggest that the smart rule is not useful.

What I meant is that for this project which we are discussing (integrating Zotero with DT3) I do not think the smart rule would be helpful as a building block.

Thanks to @rkaplan @retorquere and @Bernardo_V for continuing to work on the Zotero and DT integration question. Your technical knowledge quickly surpassed my own, so I’m watching how this develops with great interest.

As this post has evolved significantly since it was started, I just wanted to highlight some of the initial questions (not mutually exclusive) as I saw them:

  1. Following @Bernardo_V example could we get DT to handle some of the citation management and organization functions currently being done in other programs? Demonstrated more clearly here: https://discourse.devontechnologies.com/t/dt3-and-bibdesk/48765?u=cali310
  2. How can we better integrate DT and Zotero? How can we get Zotero data into DT efficiently without having to rely on exporting the database or drag-and-drop etc?

I’m out of my league here, but the Alfred workflow ZotHero pulls from the Zotero SQL database even when Zotero is open (I assume it caches the db info). The code for it is in github, so it might offer some of the plumbing that’s being discussed here: https://github.com/deanishe/zothero

Dean created ZotHero to fix an older broken workflow called ZotQuery, which had been created by a grad student who got in way over his head. You can read all about it here:

https://www.alfredforum.com/topic/3708-zotquery-an-alfred-workflow-for-zotero/page/19/

(I’m user dfay in that thread - I did a lot of testing etc. but in the end stuck with BibDesk, which is way easier to automate).