Skip to content

Commit

Permalink
Merge branch 'zmaster-6.0.30' into jurism-6.0.30
Browse files Browse the repository at this point in the history
  • Loading branch information
fbennett committed Jun 15, 2024
2 parents c0d4602 + dd98c5b commit 5ffccdb
Show file tree
Hide file tree
Showing 73 changed files with 1,189 additions and 246 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ jobs:
name: Build, Upload, Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 14
node-version: 18
#cache: npm

# On GitHub
Expand All @@ -27,7 +27,7 @@ jobs:

- name: Cache Firefox
id: firefox-cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: firefox-x86_64
key: firefox-60.9.0esr
Expand All @@ -42,7 +42,7 @@ jobs:

- name: Cache Node modules
id: node-cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
Expand All @@ -53,13 +53,16 @@ jobs:

- name: Build Zotero
run: npm run build
# Currently necessary for pdf-worker Webpack: https://stackoverflow.com/a/69746937
env:
NODE_OPTIONS: --openssl-legacy-provider

- name: Upload deployment ZIP
if: |
env.ACT != 'true'
&& github.repository == 'zotero/zotero'
&& github.event_name == 'push'
&& (github.ref == 'refs/heads/master' || endsWith(github.ref, '-hotfix') || github.ref == 'refs/heads/gh-actions-ci-test')
&& (github.ref == 'refs/heads/6.0' || endsWith(github.ref, '-hotfix') || github.ref == 'refs/heads/gh-actions-ci-test')
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -76,7 +79,7 @@ jobs:

- name: Cache utilities Node modules
id: utilities-node-cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: chrome/content/zotero/xpcom/utilities/node_modules
key: utilities-node-modules-${{ hashFiles('chrome/content/zotero/xpcom/utilities/package-lock.json') }}
Expand Down
86 changes: 50 additions & 36 deletions chrome/content/scaffold/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -1138,13 +1138,19 @@ var Scaffold = new function () {
string = fix2028(Zotero.Utilities.varDump(string));
}

if (output.value) output.value += "\n";
output.value += Zotero.Utilities.lpad(date.getHours(), '0', 2)
// Put off actually building the log message and appending it to the console until the next animation frame
// so as not to slow down translation with repeated layout recalculations triggered by appending text
// and accessing scrollHeight
// requestAnimationFrame() callbacks are guaranteed to be called in the order they were set
requestAnimationFrame(() => {
if (output.value) output.value += "\n";
output.value += Zotero.Utilities.lpad(date.getHours(), '0', 2)
+ ":" + Zotero.Utilities.lpad(date.getMinutes(), '0', 2)
+ ":" + Zotero.Utilities.lpad(date.getSeconds(), '0', 2)
+ " " + string.replace(/\n/g, "\n ");
// move to end
output.inputField.scrollTop = output.inputField.scrollHeight;
// move to end
output.inputField.scrollTop = output.inputField.scrollHeight;
});
}

/*
Expand Down Expand Up @@ -1299,6 +1305,12 @@ var Scaffold = new function () {
function _writeTestsToPane(tests) {
_writeToEditor(_editors.tests, _stringifyTests(tests));
}

function _confirmCreateExpectedFailTest() {
return Services.prompt.confirm(null,
'Detection Failed',
'Add test ensuring that detection always fails on this page?');
}

/**
* Mimics most of the behavior of Zotero.Item#fromJSON. Most importantly,
Expand Down Expand Up @@ -1516,7 +1528,7 @@ var Scaffold = new function () {

if (level < 2 && value.items) {
// Test object. Arrange properties in set order
let order = ['type', 'url', 'input', 'defer', 'items'];
let order = ['type', 'url', 'input', 'defer', 'detectedItemType', 'items'];
for (let i = 0; i < order.length; i++) {
let val = processRow(order[i], value[order[i]]);
if (val === undefined) continue;
Expand Down Expand Up @@ -1623,14 +1635,16 @@ var Scaffold = new function () {
_translatorProvider
);
return new Promise(
(resolve, reject) => tester.newTest(input, function (obj, newTest) { // "done" handler for do
if (newTest) {
resolve(_sanitizeItemsInTest(newTest));
}
else {
reject(new Error('Creation failed'));
}
})
(resolve, reject) => tester.newTest(input,
(obj, newTest) => { // "done" handler for do
if (newTest) {
resolve(_sanitizeItemsInTest(newTest));
}
else {
reject(new Error('Creation failed'));
}
},
_confirmCreateExpectedFailTest)
);
}
else if (type == "import" || type == "search") {
Expand Down Expand Up @@ -1947,46 +1961,46 @@ var Scaffold = new function () {
var test = this.testsToUpdate.shift();
_logOutput("Updating test " + (this.numTestsTotal - this.testsToUpdate.length));

var me = this;

if (test.type == 'web') {
_logOutput("Loading web page from " + test.url);
var hiddenBrowser = Zotero.HTTP.loadDocuments(
test.url,
function (doc) {
(doc) => {
_logOutput("Page loaded");
if (test.defer) {
_logOutput("Waiting " + (Zotero_TranslatorTester.DEFER_DELAY / 1000)
+ " second(s) for page content to settle"
);
}
Zotero.setTimeout(
function () {
() => {
doc = hiddenBrowser.contentDocument;
if (doc.location.href != test.url) {
_logOutput("Page URL differs from test. Will be updated. " + doc.location.href);
}
me.tester.newTest(doc, function (obj, newTest) {
Zotero.Browser.deleteHiddenBrowser(hiddenBrowser);
if (test.defer) {
newTest.defer = true;
}
newTest = _sanitizeItemsInTest(newTest);
me.newTests.push(newTest);
me.testDoneCallback(newTest);
me._updateTests();
});
this.tester.newTest(doc,
(obj, newTest) => {
Zotero.Browser.deleteHiddenBrowser(hiddenBrowser);
if (test.defer) {
newTest.defer = true;
}
newTest = _sanitizeItemsInTest(newTest);
this.newTests.push(newTest);
this.testDoneCallback(newTest);
this._updateTests();
},
_confirmCreateExpectedFailTest);
},
test.defer ? Zotero_TranslatorTester.DEFER_DELAY : 0,
true
);
},
null,
function (e) {
(e) => {
Zotero.logError(e);
me.newTests.push(false);
me.testDoneCallback(false);
me._updateTests();
this.newTests.push(false);
this.testDoneCallback(false);
this._updateTests();
},
true
);
Expand All @@ -2004,15 +2018,15 @@ var Scaffold = new function () {

// Re-runs the test.
// TranslatorTester doesn't handle these correctly, so we do it manually
_run(methods[test.type], test.input, null, function (obj, item) {
_run(methods[test.type], test.input, null, (obj, item) => {
if (item) {
test.items.push(Zotero_TranslatorTester._sanitizeItem(item));
}
}, null, function () {
}, null, () => {
if (!test.items.length) test = false;
me.newTests.push(test);
me.testDoneCallback(test);
me._updateTests();
this.newTests.push(test);
this.testDoneCallback(test);
this._updateTests();
});
}
};
Expand Down
8 changes: 3 additions & 5 deletions chrome/content/scaffold/templates/newWeb.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ function getSearchResults(doc, checkOnly) {
async function doWeb(doc, url) {
if (detectWeb(doc, url) == 'multiple') {
let items = await Zotero.selectItems(getSearchResults(doc, false));
if (items) {
await Promise.all(
Object.keys(items)
.map(url => requestDocument(url).then(scrape))
);
if (!items) return;
for (let url of Object.keys(items)) {
await scrape(await requestDocument(url));
}
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
<overlay id="menuOverlay"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<keyset id="mainKeyset">
<key id="key_quitApplication"
key="&quitApplicationCmd.accesskey;"
command="cmd_quitApplication"
modifiers="accel"/>
</keyset>

<menupopup id="menu_FilePopup">
<menuseparator/>
<menuitem id="menu_FileQuitItem"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<menuseparator/>
<menuitem id="menu_FileQuitItem"
label="&quitApplicationCmdWin.label;"
key="key_quitApplication"
accesskey="&quitApplicationCmdWin.accesskey;"
command="cmd_quitApplication"/>
</menupopup>
<menupopup id="menu_EditPopup">
Expand Down
26 changes: 17 additions & 9 deletions chrome/content/zotero/bindings/itembox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,10 @@
if (fieldName == 'itemType') {
val = this.item.itemTypeID;
}
else if (fieldValue) {
val = fieldValue;
}
// XXX JURISM: these lines do not exist on Zotero-side
//else if (fieldValue) {
// val = fieldValue;
//}
else {
val = this.item.getField(fieldName);
}
Expand All @@ -590,10 +591,11 @@
var fieldIsClickable = this._fieldIsClickable(fieldName);
// Start tabindex at 10001 after creators
// XXX Jurism: tabindexValue is provided as an explicit argument
// XXX to this addFieldRow() function.
var tabindex = fieldIsClickable ? tabindexValue : 0;
this._tabIndexMaxFields = Math.max(this._tabIndexMaxFields, tabindex);
// TEMP - NSF
if (fieldIsClickable
&& !Zotero.Items.isPrimaryField(fieldName)
&& (Zotero.ItemFields.isDate(fieldName)
Expand All @@ -606,10 +608,14 @@
let label = document.createElement("label");
label.setAttribute('fieldname', fieldName);
// XXX Jurism: the parentNode flag is provided
// as an explicit argument to this addFieldRow() function
let valueElement = this.createValueElement(
val, fieldName, tabindex, !!parentNode
);
// XXX Jurism: this code block for multilingual support
// is specific to Jurism
if (Zotero.CachedMultiFields.isMultiFieldName(fieldName)) {
var fieldLang = langTag;
if (!fieldLang) {
Expand Down Expand Up @@ -686,11 +692,13 @@
if (this.nextSibling.inputField) {
this.nextSibling.inputField.blur();
}
else {
document.getBindingParent(this).toggleAbstractExpand(
this, this.nextSibling
);
}
// XXX Jurism: this code block does not appear in
// upstream Zotero.
//else {
// document.getBindingParent(this).toggleAbstractExpand(
// this, this.nextSibling
// );
//}
});
}
else {
Expand Down
10 changes: 8 additions & 2 deletions chrome/content/zotero/collectionTree.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,10 @@ var CollectionTree = class CollectionTree extends LibraryTree {
return;
}
if (type == 'feed' && (action == 'unreadCountUpdated' || action == 'statusChanged')) {
this.tree.invalidate();
let feedRow = this.getRowIndexByID("L" + ids[0]);
if (feedRow !== false) {
this.tree.invalidateRow(feedRow);
}
return;
}

Expand Down Expand Up @@ -747,7 +750,7 @@ var CollectionTree = class CollectionTree extends LibraryTree {
// Invalidate parent in case it's become non-empty
let parentRow = this.getRowIndexByID("C" + collection.parentID);
if (parentRow !== false) {
this._treebox.invalidateRow(parentRow);
this.tree.invalidateRow(parentRow);
}
}
break;
Expand All @@ -771,6 +774,9 @@ var CollectionTree = class CollectionTree extends LibraryTree {
}
}
break;

case 'feed':
break;

default:
await this.reload();
Expand Down
2 changes: 2 additions & 0 deletions chrome/content/zotero/components/icons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ i('TreeitemBookSection', 'chrome://zotero/skin/treeitem-bookSection.png');
i('TreeitemCase', 'chrome://zotero/skin/treeitem-case.png');
i('TreeitemComputerProgram', 'chrome://zotero/skin/treeitem-computerProgram.png');
i('TreeitemConferencePaper', 'chrome://zotero/skin/treeitem-conferencePaper.png');
i('TreeitemDataset', 'chrome://zotero/skin/treeitem-dataset.png');
i('TreeitemDictionaryEntry', 'chrome://zotero/skin/treeitem-dictionaryEntry.png');
i('TreeitemEmail', 'chrome://zotero/skin/treeitem-email.png');
i('TreeitemEncyclopediaArticle', 'chrome://zotero/skin/treeitem-encyclopediaArticle.png');
Expand All @@ -147,6 +148,7 @@ i('TreeitemPreprint', 'chrome://zotero/skin/treeitem-preprint.png');
i('TreeitemPresentation', 'chrome://zotero/skin/treeitem-presentation.png');
i('TreeitemRadioBroadcast', 'chrome://zotero/skin/treeitem-radioBroadcast.png', false);
i('TreeitemReport', 'chrome://zotero/skin/treeitem-report.png');
i('TreeitemStandard', 'chrome://zotero/skin/treeitem-standard.png');
i('TreeitemStatute', 'chrome://zotero/skin/treeitem-statute.png');
i('TreeitemThesis', 'chrome://zotero/skin/treeitem-thesis.png');
i('TreeitemTvBroadcast', 'chrome://zotero/skin/treeitem-tvBroadcast.png', false);
Expand Down
2 changes: 1 addition & 1 deletion chrome/content/zotero/createParentDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function doAccept() {
);

// If we successfully created a parent, return it
if (newItems) {
if (newItems.length) {
io.dataOut = { parent: newItems[0] };
window.close();
}
Expand Down
9 changes: 5 additions & 4 deletions chrome/content/zotero/fileInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ Zotero_File_Exporter.prototype.save = async function () {
}
}
}
// Otherwise exclude note export translators
else {
translators = translators.filter(t => !t.configOptions || !t.configOptions.noteTranslator);
}
}

// Exclude note translators if not exporting notes
if (!exportingNotes) {
translators = translators.filter(t => !t.configOptions || !t.configOptions.noteTranslator);
}

// present options dialog
Expand Down
Loading

0 comments on commit 5ffccdb

Please sign in to comment.