mirror of
https://github.com/zotero/zotero.git
synced 2026-08-28 05:25:31 +00:00
Add ability to share bibliography to ZoteroBib
This commit is contained in:
parent
06afaf3316
commit
7d361b10b2
3 changed files with 37 additions and 0 deletions
|
|
@ -41,6 +41,7 @@
|
|||
<radio id="save-as-rtf" data-l10n-id="bibliography-outputMethod-saveAsRTF"/>
|
||||
<radio id="save-as-html" data-l10n-id="bibliography-outputMethod-saveAsHTML"/>
|
||||
<radio id="copy-to-clipboard" data-l10n-id="bibliography-outputMethod-copyToClipboard"/>
|
||||
<radio id="save-to-zbib" data-l10n-id="bibliography-outputMethod-saveToZbib" />
|
||||
<radio id="print" data-l10n-id="bibliography-outputMethod-print"/>
|
||||
</radiogroup>
|
||||
</groupbox>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue