diff --git a/build/open-inline-citation.xpi b/build/open-inline-citation.xpi index 43f2b2d..9b667ff 100644 Binary files a/build/open-inline-citation.xpi and b/build/open-inline-citation.xpi differ diff --git a/make-zips b/make-zips index 3cedd2f..35397e3 100755 --- a/make-zips +++ b/make-zips @@ -4,6 +4,9 @@ set -euo pipefail rm -rf build mkdir build -cd src-1.2 +cd src zip -r ../build/open-inline-citation.xpi * cd ../build + +echo "Hash of current version:" +shasum -a 256 open-inline-citation.xpi | cut -d' ' -f1 \ No newline at end of file diff --git a/open-inline-citations-update.json.tmpl b/open-inline-citations-update.json.tmpl new file mode 100644 index 0000000..743a434 --- /dev/null +++ b/open-inline-citations-update.json.tmpl @@ -0,0 +1,18 @@ +{ + "addons": { + "open-inline-citation@example.com": { + "updates": [ + { + "version": "0.2", + "update_link": "TODO point to release", + "update_hash": "c568d6d2aeec7fda1dea473b3370a8b85b30d745d505bb38d5fcbf868580fc8a", + "applications": { + "gecko": { + "strict_min_version": "60.0" + } + } + } + ] + } + } +} \ No newline at end of file diff --git a/src-1.2/chrome/locale/en-US/open-inline-citation.properties b/src-1.2/chrome/locale/en-US/open-inline-citation.properties deleted file mode 100644 index 98f2112..0000000 --- a/src-1.2/chrome/locale/en-US/open-inline-citation.properties +++ /dev/null @@ -1 +0,0 @@ -makeItGreenInstead.label = Make It Green Instead diff --git a/src-1.2/locale/en-US/open-inline-citation.ftl b/src-1.2/locale/en-US/open-inline-citation.ftl deleted file mode 100644 index e365108..0000000 --- a/src-1.2/locale/en-US/open-inline-citation.ftl +++ /dev/null @@ -1,2 +0,0 @@ -open-inline-citation-green-instead = - .label = Make It Green Instead diff --git a/src-1.2/make-it-red.js b/src-1.2/make-it-red.js deleted file mode 100644 index 83aab44..0000000 --- a/src-1.2/make-it-red.js +++ /dev/null @@ -1,128 +0,0 @@ -if (Zotero.platformMajorVersion < 102) { - Cu.importGlobalProperties(['URL']); -} - -MakeItRed = { - id: null, - version: null, - rootURI: null, - initialized: false, - addedElementIDs: [], - - init({ id, version, rootURI }) { - return; - if (this.initialized) return; - this.id = id; - this.version = version; - this.rootURI = rootURI; - this.initialized = true; - }, - - log(msg) { - return; - Zotero.debug("Open Inline Citation: " + msg); - }, - - addToWindow(window) { - return; - let doc = window.document; - - // createElementNS() necessary in Zotero 6; createElement() defaults to HTML in Zotero 7 - let HTML_NS = "http://www.w3.org/1999/xhtml"; - let XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - - // Add a stylesheet to the main Zotero pane - let link1 = doc.createElementNS(HTML_NS, 'link'); - link1.id = 'open-inline-citation-stylesheet'; - link1.type = 'text/css'; - link1.rel = 'stylesheet'; - link1.href = this.rootURI + 'style.css'; - doc.documentElement.appendChild(link1); - this.storeAddedElement(link1); - - // Add menu option - let menuitem = doc.createElementNS(XUL_NS, 'menuitem'); - menuitem.id = 'make-it-green-instead'; - menuitem.setAttribute('type', 'checkbox'); - menuitem.setAttribute('data-l10n-id', 'open-inline-citation-green-instead'); - menuitem.addEventListener('command', () => { - MakeItRed.toggleGreen(window, menuitem.getAttribute('checked') === 'true'); - }); - doc.getElementById('menu_viewPopup').appendChild(menuitem); - this.storeAddedElement(menuitem); - - // Use strings from open-inline-citation.ftl (Fluent) in Zotero 7 - if (Zotero.platformMajorVersion >= 102) { - window.MozXULElement.insertFTLIfNeeded("open-inline-citation.ftl"); - } - // Use strings from open-inline-citation.properties (legacy properties format) in Zotero 6 - else { - let stringBundle = Services.strings.createBundle( - 'chrome://open-inline-citation/locale/open-inline-citation.properties' - ); - doc.getElementById('make-it-green-instead') - .setAttribute('label', stringBundle.GetStringFromName('makeItGreenInstead.label')); - } - }, - - addToAllWindows() { - return; - var windows = Zotero.getMainWindows(); - for (let win of windows) { - if (!win.ZoteroPane) continue; - this.addToWindow(win); - } - }, - - storeAddedElement(elem) { - return; - if (!elem.id) { - throw new Error("Element must have an id"); - } - this.addedElementIDs.push(elem.id); - }, - - removeFromWindow(window) { - return; - var doc = window.document; - // Remove all elements added to DOM - for (let id of this.addedElementIDs) { - // ?. (null coalescing operator) not available in Zotero 6 - let elem = doc.getElementById(id); - if (elem) elem.remove(); - } - doc.querySelector('[href="open-inline-citation.ftl"]').remove(); - }, - - removeFromAllWindows() { - return; - var windows = Zotero.getMainWindows(); - for (let win of windows) { - if (!win.ZoteroPane) continue; - this.removeFromWindow(win); - } - }, - - toggleGreen(window, enabled) { - return; - let docElem = window.document.documentElement; - // Element#toggleAttribute() is not supported in Zotero 6 - if (enabled) { - docElem.setAttribute('data-green-instead', 'true'); - } - else { - docElem.removeAttribute('data-green-instead'); - } - }, - - async main() { - return; - // Global properties are imported above in Zotero 6 and included automatically in - // Zotero 7 - var host = new URL('https://foo.com/path').host; - this.log(`Host is ${host}`); - - // Retrieve a global pref - this.log(`Intensity is ${Zotero.Prefs.get('extensions.open-inline-citation.intensity', true)}`); - }, -}; diff --git a/src-1.2/prefs.js b/src-1.2/prefs.js deleted file mode 100644 index 543bdff..0000000 --- a/src-1.2/prefs.js +++ /dev/null @@ -1,3 +0,0 @@ -pref("extensions.open-inline-citation.intensity", 100); -pref("extensions.open-inline-citation.openai-api-key", null) -pref("extensions.open-inline-citation.aves-api-key", "QY430HSN45MNZRG5TKH6KPSZDG8F") diff --git a/src-inline/bootstrap.js b/src-inline/bootstrap.js deleted file mode 100644 index 3fb24a8..0000000 --- a/src-inline/bootstrap.js +++ /dev/null @@ -1,46 +0,0 @@ -var MakeItRed; -var addListeners; - -function log(msg) { - Zotero.debug("Open Inline Citation: " + msg); -} - -function install() { - log("Installed 2.0"); -} - -async function startup({ id, version, rootURI }) { - log("Starting 2.0"); - - Zotero.PreferencePanes.register({ - pluginID: 'open-inline-citation@example.com', - }); - - Services.scriptloader.loadSubScript(rootURI + 'inline-citations.js'); - Zotero.Notifier.registerObserver({ - notify: function(event, type, ids, extraData) { - if (event === 'select' && type === 'tab') { - console.log('Tab switched to', ids[0]); - addListeners(); - } - } - }, ['tab']); -} - -function onMainWindowLoad({ window }) { - // MakeItRed.addToWindow(window); -} - -function onMainWindowUnload({ window }) { - // MakeItRed.removeFromWindow(window); -} - -function shutdown() { - log("Shutting down 2.0"); - // MakeItRed.removeFromAllWindows(); - MakeItRed = undefined; -} - -function uninstall() { - log("Uninstalled 2.0"); -} diff --git a/src-1.2/bootstrap.js b/src/bootstrap.js similarity index 93% rename from src-1.2/bootstrap.js rename to src/bootstrap.js index 8c8755e..37e0947 100644 --- a/src-1.2/bootstrap.js +++ b/src/bootstrap.js @@ -1,3 +1,5 @@ +const version = "0.2"; + if (typeof Zotero == "undefined") { var Zotero; } @@ -127,7 +129,7 @@ function setDefaultPrefs(rootURI) { async function install() { await waitForZotero(); - log("Installed 1.2"); + log(`Installed ${version}`); } async function startup({ @@ -138,7 +140,7 @@ async function startup({ }) { await waitForZotero(); - log("Starting 1.2"); + log(`Starting ${version}`); // 'Services' may not be available in Zotero 6 if (typeof Services == "undefined") { @@ -155,7 +157,6 @@ async function startup({ setDefaultPrefs(rootURI); } - Services.scriptloader.loadSubScript(rootURI + "make-it-red.js"); Services.scriptloader.loadSubScript(rootURI + "inline-citations.js"); Zotero.setTimeout(() => addListeners(), 2000); @@ -170,27 +171,19 @@ async function startup({ }, ["tab"] ); - - MakeItRed.init({ id, version, rootURI }); - MakeItRed.addToAllWindows(); - await MakeItRed.main(); } function onMainWindowLoad({ window }) {} function onMainWindowUnload({ window }) { - MakeItRed.removeFromWindow(window); } function shutdown() { - log("Shutting down 1.2"); + log(`Shutting down ${version}`); if (Zotero.platformMajorVersion < 102) { removeMainWindowListener(); } - - MakeItRed.removeFromAllWindows(); - MakeItRed = undefined; } function uninstall() { @@ -200,5 +193,5 @@ function uninstall() { return; } - log("Uninstalled 1.2"); + log(`Uninstalled ${version}`); } diff --git a/src-1.2/chrome.manifest b/src/chrome.manifest similarity index 100% rename from src-1.2/chrome.manifest rename to src/chrome.manifest diff --git a/src/chrome/locale/en-US/open-inline-citation.properties b/src/chrome/locale/en-US/open-inline-citation.properties new file mode 100644 index 0000000..e69de29 diff --git a/src-1.2/inline-citations.js b/src/inline-citations.js similarity index 100% rename from src-1.2/inline-citations.js rename to src/inline-citations.js diff --git a/src-1.2/install.rdf b/src/install.rdf similarity index 83% rename from src-1.2/install.rdf rename to src/install.rdf index 0b917c7..02e0993 100644 --- a/src-1.2/install.rdf +++ b/src/install.rdf @@ -5,10 +5,10 @@ open-inline-citation@example.com Open Inline Citation - 0.1 + 0.2 true - https://zotero-download.s3.amazonaws.com/tmp/open-inline-citation/updates-0.1.json - https://github.com/zotero/open-inline-citation + https://raw.githubusercontent.com/andrew-healey/open-inline-citation/main/updates.json + https://github.com/andrew-healey/open-inline-citation en-US diff --git a/src/locale/en-US/open-inline-citation.ftl b/src/locale/en-US/open-inline-citation.ftl new file mode 100644 index 0000000..e69de29 diff --git a/src/make-it-red.js b/src/make-it-red.js new file mode 100644 index 0000000..30f6658 --- /dev/null +++ b/src/make-it-red.js @@ -0,0 +1,128 @@ +// if (Zotero.platformMajorVersion < 102) { +// Cu.importGlobalProperties(['URL']); +// } + +// MakeItRed = { +// id: null, +// version: null, +// rootURI: null, +// initialized: false, +// addedElementIDs: [], + +// init({ id, version, rootURI }) { +// return; +// if (this.initialized) return; +// this.id = id; +// this.version = version; +// this.rootURI = rootURI; +// this.initialized = true; +// }, + +// log(msg) { +// return; +// Zotero.debug("Open Inline Citation: " + msg); +// }, + +// addToWindow(window) { +// return; +// let doc = window.document; + +// // createElementNS() necessary in Zotero 6; createElement() defaults to HTML in Zotero 7 +// let HTML_NS = "http://www.w3.org/1999/xhtml"; +// let XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; + +// // Add a stylesheet to the main Zotero pane +// let link1 = doc.createElementNS(HTML_NS, 'link'); +// link1.id = 'open-inline-citation-stylesheet'; +// link1.type = 'text/css'; +// link1.rel = 'stylesheet'; +// link1.href = this.rootURI + 'style.css'; +// doc.documentElement.appendChild(link1); +// this.storeAddedElement(link1); + +// // Add menu option +// let menuitem = doc.createElementNS(XUL_NS, 'menuitem'); +// menuitem.id = 'make-it-green-instead'; +// menuitem.setAttribute('type', 'checkbox'); +// menuitem.setAttribute('data-l10n-id', 'open-inline-citation-green-instead'); +// menuitem.addEventListener('command', () => { +// MakeItRed.toggleGreen(window, menuitem.getAttribute('checked') === 'true'); +// }); +// doc.getElementById('menu_viewPopup').appendChild(menuitem); +// this.storeAddedElement(menuitem); + +// // Use strings from open-inline-citation.ftl (Fluent) in Zotero 7 +// if (Zotero.platformMajorVersion >= 102) { +// window.MozXULElement.insertFTLIfNeeded("open-inline-citation.ftl"); +// } +// // Use strings from open-inline-citation.properties (legacy properties format) in Zotero 6 +// else { +// let stringBundle = Services.strings.createBundle( +// 'chrome://open-inline-citation/locale/open-inline-citation.properties' +// ); +// doc.getElementById('make-it-green-instead') +// .setAttribute('label', stringBundle.GetStringFromName('makeItGreenInstead.label')); +// } +// }, + +// addToAllWindows() { +// return; +// var windows = Zotero.getMainWindows(); +// for (let win of windows) { +// if (!win.ZoteroPane) continue; +// this.addToWindow(win); +// } +// }, + +// storeAddedElement(elem) { +// return; +// if (!elem.id) { +// throw new Error("Element must have an id"); +// } +// this.addedElementIDs.push(elem.id); +// }, + +// removeFromWindow(window) { +// return; +// var doc = window.document; +// // Remove all elements added to DOM +// for (let id of this.addedElementIDs) { +// // ?. (null coalescing operator) not available in Zotero 6 +// let elem = doc.getElementById(id); +// if (elem) elem.remove(); +// } +// doc.querySelector('[href="open-inline-citation.ftl"]').remove(); +// }, + +// removeFromAllWindows() { +// return; +// var windows = Zotero.getMainWindows(); +// for (let win of windows) { +// if (!win.ZoteroPane) continue; +// this.removeFromWindow(win); +// } +// }, + +// toggleGreen(window, enabled) { +// return; +// let docElem = window.document.documentElement; +// // Element#toggleAttribute() is not supported in Zotero 6 +// if (enabled) { +// docElem.setAttribute('data-green-instead', 'true'); +// } +// else { +// docElem.removeAttribute('data-green-instead'); +// } +// }, + +// async main() { +// return; +// // Global properties are imported above in Zotero 6 and included automatically in +// // Zotero 7 +// var host = new URL('https://foo.com/path').host; +// this.log(`Host is ${host}`); + +// // Retrieve a global pref +// this.log(`Intensity is ${Zotero.Prefs.get('extensions.open-inline-citation.intensity', true)}`); +// }, +// }; diff --git a/src-1.2/manifest.json b/src/manifest.json similarity index 74% rename from src-1.2/manifest.json rename to src/manifest.json index 346287e..7fa8e63 100644 --- a/src-1.2/manifest.json +++ b/src/manifest.json @@ -1,12 +1,13 @@ { "manifest_version": 2, "name": "Open Inline Citation", - "version": "0.1", + "version": "0.2", "description": "CMD-click any inline citation to read it in a new tab", "homepage_url": "https://github.com/andrew-healey/open-inline-citation", "applications": { "zotero": { "id": "open-inline-citation@example.com", + "update_url": "https://raw.githubusercontent.com/andrew-healey/open-inline-citation/main/updates.json", "strict_min_version": "6.999", "strict_max_version": "7.0.*" } diff --git a/src/prefs.js b/src/prefs.js new file mode 100644 index 0000000..e69de29 diff --git a/src-1.2/style.css b/src/style.css similarity index 100% rename from src-1.2/style.css rename to src/style.css