-
Save to Zotero.org
+
Saving
-
-
Zotero Connector must be authorized in order to save items to zotero.org when Zotero is not open.
-
-
-
-
Zotero Connector will save items to zotero.org as when Zotero is not open.
-
-
-
-
+
+
+
Saving to Zotero.org
+
+
Zotero Connector must be authorized in order to save items to zotero.org when Zotero is not open.
+
+
+
diff --git a/src/common/preferences/preferences.jsx b/src/common/preferences/preferences.jsx
index cb2dccf061..6075157aad 100644
--- a/src/common/preferences/preferences.jsx
+++ b/src/common/preferences/preferences.jsx
@@ -159,8 +159,8 @@ Zotero_Preferences.General = {
updateAuthorization: function(userInfo) {
document.getElementById('general-authorization-not-authorized').style.display = (userInfo ? 'none' : 'block');
document.getElementById('general-authorization-authorized').style.display = (!userInfo ? 'none' : 'block');
- if(userInfo) {
- document.getElementById('general-span-authorization-username').textContent = userInfo.username;
+ if (userInfo) {
+ document.getElementById('general-span-authorization-username').textContent = userInfo['auth-username'];
}
},
diff --git a/src/common/test/tests/backgroundTest.js b/src/common/test/tests/backgroundTest.js
index e7384bbf5b..93eee2853c 100644
--- a/src/common/test/tests/backgroundTest.js
+++ b/src/common/test/tests/backgroundTest.js
@@ -23,7 +23,11 @@
***** END LICENSE BLOCK *****
*/
-describe('Connector_Browser', function() {
+/**
+ * https://github.com/zotero/zotero-connectors/pull/193 effectively reverts
+ * https://github.com/zotero/zotero-connectors/issues/152
+ */
+describe.skip('Connector_Browser', function() {
var tab = new Tab();
describe('onPDFFrame', function() {
@@ -31,7 +35,11 @@ describe('Connector_Browser', function() {
try {
let bgPromise = background(function() {
Zotero.Prefs.set('firstUse', false);
- let stub = sinon.stub(Zotero.Connector_Browser, '_showPDFIcon');
+ if (Zotero.isBrowserExt) {
+ var stub = sinon.stub(Zotero.Extension.Button, 'showPDFIcon');
+ } else {
+ stub = sinon.stub(Zotero.Connector_Browser, '_showPDFIcon');
+ }
var deferred = Zotero.Promise.defer();
stub.callsFake(deferred.resolve);
@@ -50,16 +58,20 @@ describe('Connector_Browser', function() {
await bgPromise;
let tabId = await background(async function(tabId) {
if (Zotero.isBrowserExt) {
- return Zotero.Connector_Browser._showPDFIcon.args[0][0].id;
+ return Zotero.Extension.Button.showPDFIcon.args[0][0].id;
} else {
return (await Zotero.Background.getTabByID(tabId)).isPDFFrame ? tabId : -1;
}
}, tab.tabId);
assert.equal(tabId, tab.tabId);
} finally {
- await background(function() {
- Zotero.Connector_Browser._showPDFIcon.restore()
- });
+ await background(function () {
+ if (Zotero.isBrowserExt) {
+ Zotero.Extension.Button.showPDFIcon.restore()
+ } else {
+ Zotero.Connector_Browser._showPDFIcon.restore();
+ }
+ });
if (tab.tabId) {
await tab.close();
}
diff --git a/src/common/test/tests/translationTest.js b/src/common/test/tests/translationTest.js
index 52bfd96dc6..9e6fe40b5b 100644
--- a/src/common/test/tests/translationTest.js
+++ b/src/common/test/tests/translationTest.js
@@ -56,7 +56,7 @@ describe("Translation", function() {
return Zotero.Inject.translators[key].metadata.label;
});
});
- assert.deepEqual(['COinS', 'DOI'], translators);
+ assert.deepEqual(['COinS', 'DOI', 'Embedded Metadata'], translators);
});
});
@@ -119,25 +119,6 @@ describe("Translation", function() {
});
assert.include(message, items[0].title);
}));
-
- it('saves as snapshot', async function () {
- await background(async function(tabId) {
- var stub = sinon.stub(Zotero.Connector, "callMethodWithCookies").resolves([]);
- let tab = await Zotero.Background.getTabByID(tabId);
- try {
- await Zotero.Connector_Browser.saveAsWebpage(tab, false);
- } finally {
- stub.restore()
- }
- }, tab.tabId);
- await Zotero.Promise.delay(20);
- var message = await tab.run(function() {
- var message = document.getElementById('zotero-progress-window').textContent;
- Zotero.ProgressWindow.close();
- return message;
- });
- assert.include(message, "Scarcity or Abundance? Preserving the Past in a Digital Era");
- });
it('displays an error message if Zotero responds with an error', async function () {
await background(async function(tabId) {
@@ -285,7 +266,7 @@ describe("Translation", function() {
}, tab.tabId);
assert.notEqual(instanceID, 0);
- assert.deepEqual(['COinS', 'DOI'], translators);
+ assert.deepEqual(['COinS', 'DOI', 'Web Page'], translators);
} finally {
await tab.close();
}
diff --git a/src/common/translate_item.js b/src/common/translate_item.js
index 46332ecebb..95dd968bb7 100644
--- a/src/common/translate_item.js
+++ b/src/common/translate_item.js
@@ -88,13 +88,16 @@ Zotero.Translate.ItemSaver.prototype = {
* save progress. The callback will be called as attachmentCallback(attachment, false, error)
* on failure or attachmentCallback(attachment, progressPercent) periodically during saving.
*/
- saveItems: function (items, attachmentCallback) {
+ saveItems: async function (items, attachmentCallback) {
+ items = await this._filterAttachments(items);
+
// first try to save items via connector
var payload = { items, uri: this._baseURI };
if (Zotero.isSafari) {
// This is the best in terms of cookies we can do in Safari
payload.cookie = document.cookie;
}
+
payload.proxy = this._proxy && this._proxy.toJSON();
return Zotero.Connector.callMethodWithCookies("saveItems", payload).then(function(data) {
Zotero.debug("Translate: Save via Standalone succeeded");
@@ -123,6 +126,32 @@ Zotero.Translate.ItemSaver.prototype = {
throw e;
}.bind(this));
},
+
+ /**
+ * Filters away attachments from items per user prefs
+ *
+ * @param items
+ * @returns {Promise.
}
+ * @private
+ */
+ _filterAttachments: async function(items) {
+ let prefs = await Zotero.Prefs.getAsync(["downloadAssociatedFiles", "automaticSnapshots"]);
+ for (let item of items) {
+ item.attachments = item.attachments.filter(function(attachment) {
+ let isSnapshot = false;
+ if (attachment.mimeType) {
+ switch (attachment.mimeType.toLowerCase()) {
+ case "text/html":
+ case "application/xhtml+xml":
+ isSnapshot = true;
+ }
+ }
+
+ return (isSnapshot && prefs.automaticSnapshots) || (!isSnapshot && prefs.downloadAssociatedFiles);
+ });
+ }
+ return items;
+ },
/**
* Polls for updates to attachment progress
@@ -258,11 +287,6 @@ Zotero.Translate.ItemSaver.prototype = {
isSnapshot = true;
}
}
-
- if ((isSnapshot && !prefs.automaticSnapshots) || (!isSnapshot && !prefs.downloadAssociatedFiles)) {
- // Skip attachment due to prefs
- continue;
- }
let deferredHeadersProcessed = Zotero.Promise.defer();
let itemKeyPromise = deferredHeadersProcessed.promise
diff --git a/src/common/zotero.js b/src/common/zotero.js
index 7948909593..be386780a1 100644
--- a/src/common/zotero.js
+++ b/src/common/zotero.js
@@ -244,7 +244,7 @@ Zotero.Prefs = new function() {
"debug.time": false,
"lastVersion": "",
"downloadAssociatedFiles": true,
- "automaticSnapshots": true, // only affects saves to zotero.org. saves to client governed by pref in the client
+ "automaticSnapshots": true,
"connector.repo.lastCheck.localTime": 0,
"connector.repo.lastCheck.repoTime": 0,
"connector.url": ZOTERO_CONFIG.CONNECTOR_SERVER_URL,