From 7d361b10b2a462443cdf92317ec4e35576d4bd74 Mon Sep 17 00:00:00 2001 From: Tom Najdek Date: Fri, 7 Nov 2025 19:51:50 +0100 Subject: [PATCH] Add ability to share bibliography to ZoteroBib --- chrome/content/zotero/bibliography.xhtml | 1 + chrome/content/zotero/fileInterface.js | 33 ++++++++++++++++++++++++ chrome/locale/en-US/zotero/zotero.ftl | 3 +++ 3 files changed, 37 insertions(+) diff --git a/chrome/content/zotero/bibliography.xhtml b/chrome/content/zotero/bibliography.xhtml index b85c98d603..2a4c84a2c5 100644 --- a/chrome/content/zotero/bibliography.xhtml +++ b/chrome/content/zotero/bibliography.xhtml @@ -41,6 +41,7 @@ + diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js index 97da1dd6e0..677fd2a18c 100644 --- a/chrome/content/zotero/fileInterface.js +++ b/chrome/content/zotero/fileInterface.js @@ -923,6 +923,39 @@ var Zotero_File_Interface = new function () { fStream.write(bibliography, bibliography.length); fStream.close(); } + } else if (io.method == 'save-to-zbib') { + const zbibStoreURL = 'https://v1snar4wu4.execute-api.us-east-1.amazonaws.com/1'; + let itemsJSON = items.map(item => item.toJSON()); + let data = { + title: Zotero.ftl.formatValueSync('bibliography-zbib-title'), + citationStyle: io.style.replace('http://www.zotero.org/styles/', ''), + items: itemsJSON + }; + try { + let req = await Zotero.HTTP.request( + "POST", + zbibStoreURL, + { + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(data) + } + ); + if (req.status != 200) { + throw new Error(`Zotero.Bibliography: Received status ${req.status} from zbib store`); + } + let resp = JSON.parse(req.response); + let zbibURL = `https://zbib.org/${resp.key}`; + Zotero.launchURL(zbibURL); + } catch (e) { + Zotero.alert( + null, + Zotero.getString('general.error'), + Zotero.getString('fileInterface.bibliographyGenerationError') + ); + throw (e); + } } } diff --git a/chrome/locale/en-US/zotero/zotero.ftl b/chrome/locale/en-US/zotero/zotero.ftl index 03a5e94c59..ddff04b70a 100644 --- a/chrome/locale/en-US/zotero/zotero.ftl +++ b/chrome/locale/en-US/zotero/zotero.ftl @@ -392,9 +392,12 @@ bibliography-outputMethod-saveAsHTML = .label = Save as HTML bibliography-outputMethod-copyToClipboard = .label = Copy to Clipboard +bibliography-outputMethod-saveToZbib = + .label = Save to ZoteroBib bibliography-outputMethod-print = .label = Print bibliography-manageStyles-label = Manage Styles… +bibliography-zbib-title = Saved from Zotero styleEditor-locatorType = .aria-label = Locator type