From a2697d1dfbaf572e952c156f7074a0fa58611ece Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:03:48 +0800 Subject: [PATCH] update: remove support to Zotero 6 --- README.md | 56 +++++-------------------------------------- addon/bootstrap.js | 2 -- addon/chrome.manifest | 3 --- addon/install.rdf | 35 --------------------------- scripts/build.mjs | 2 -- src/utils/locale.ts | 9 +++---- typing/global.d.ts | 2 ++ update-template.rdf | 30 ----------------------- update.rdf | 30 ----------------------- 9 files changed, 13 insertions(+), 156 deletions(-) delete mode 100644 addon/chrome.manifest delete mode 100644 addon/install.rdf delete mode 100644 update-template.rdf delete mode 100644 update.rdf diff --git a/README.md b/README.md index 43dcf97..8ec3c34 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,6 @@ This is a plugin template for [Zotero](https://www.zotero.org/). Plugins using t πŸ“Œ[Zotero Plugin Template](https://github.com/windingwind/zotero-plugin-template)(This repo) -> πŸ‘You are currently in `bootstrap` extension mode. To use `overlay` mode, please switch to `overlay` branch in git. - > πŸ‘ Watch this repo so that you can be notified whenever there are fixes & updates. If you are using this repo, I recommended that you put this badge ([![Using Zotero Plugin Template](https://img.shields.io/badge/Using-Zotero%20Plugin%20Template-blue?style=flat-square&logo=github)](https://github.com/windingwind/zotero-plugin-template)) on your README: @@ -40,7 +38,7 @@ If you are using this repo, I recommended that you put this badge ([![Using Zote ## Features -> ❗The localization system is upgraded (dtd is deprecated and we do not use .properties anymore). Only supports Zotero 7.0.0-beta.12 or higher now. If you want to support Zotero 6, you may need to use `dtd`, `properties`, and `ftl` at the same time. +> ❗The localization system is upgraded (dtd is deprecated and we do not use .properties anymore). Only supports Zotero 7.0.0-beta.12 or higher now. If you want to support Zotero 6, you may need to use `dtd`, `properties`, and `ftl` at the same time. See the staled branch `zotero6-bootstrap`. - Event-driven, functional programming, under extensive skeleton; - Simple and user-friendly, works out-of-the-box. @@ -53,7 +51,6 @@ If you are using this repo, I recommended that you put this badge ([![Using Zote - Automatically generate/update plugin id/version, update configrations, and set environment variables(`development/production`); - Automatically build and reload code in Zotero; - Automatically release to GitHub(using [release-it](https://github.com/release-it/release-it)); -- Compatibilities for Zotero 6 & Zotero 7.(using [zotero-plugin-toolkit](https://github.com/windingwind/zotero-plugin-toolkit)) ## Examples @@ -180,7 +177,7 @@ npm run release 1. Install a beta version of Zotero: https://www.zotero.org/support/beta_builds (Zotero 7 beta: https://www.zotero.org/support/dev/zotero_7_for_developers) -2. Install Firefox 60(for Zotero 6)/Firefox 102(for Zotero 7) +2. Install Firefox 102(for Zotero 7) 3. Copy zotero command line config file. Modify the commands that starts your installation of the beta Zotero. @@ -196,19 +193,15 @@ vim ./scripts/zotero-cmd.json 5. Build plugin and restart Zotero with `npm run restart`. -6. Launch Firefox 60(Zotero 6)/Firefox 102(Zotero 7) +6. Launch Firefox 102(Zotero 7) 7. In Firefox, go to devtools, go to settings, click "enable remote debugging" and the one next to it that's also about debugging -> Press `shift+F8` in FF 60, or enter `about:debugging#/setup` in FF 102. +> Enter `about:debugging#/setup` in FF 102. 8. In Zotero, go to setting, advanced, config editor, look up "debugging" and click on "allow remote debugging". -9. Connect to Zotero in Firefox. - -> In FF 60, click the hamburger menu in the top right -> web developer -> Connect..., then enter `localhost:6100`. - -> In FF 102, enter `localhost:6100` in the bottom input of remote-debugging page and click `add`. +9. Connect to Zotero in Firefox. In FF 102, enter `localhost:6100` in the bottom input of remote-debugging page and click `add`. 10. Click `connect` in the leftside-bar of Firefox remote-debugging page. @@ -270,37 +263,6 @@ This template registers the following variables to the global scope: Zotero, ZoteroPane, Zotero_Tabs, window, document, rootURI, ztoolkit, addon; ``` -### About Preference - -Zotero 6 doesn't support preference pane injection in bootstrap mode, thus I write a register for Zotero 6 or lower. - -You only need to maintain one `preferences.xhtml` which runs natively on Zotero 7 and let the plugin template handle it when it is running on Zotero 6. - - - - - - -
- -
Zotero 7
-
- -
Zotero 6
-
- -https://github.com/windingwind/zotero-plugin-template/blob/08d72a4e2b3bacff574f537bbd06cb33e6b22480/src/modules/examples.ts#L73-L85 - -> `` element is deprecated. Please use the full pref-key in the elements' `preference` attribute. Like: - -```xml - -``` - -The elements with `preference` attributes will bind to Zotero preferences. - -Remember to call `unregister()` on plugin unload. - ### Create Elements API The plugin template provides new APIs for bootstrap plugins. We have two reasons to use these APIs, instead of the `createElement/createElementNS`: @@ -363,9 +325,7 @@ This section shows the directory structure of a template. β”œβ”€.github # github conf β”‚ β”œβ”€addon # addon dir -β”‚ β”‚ chrome.manifest # for Zotero 6 -β”‚ β”‚ manifest.json # for Zotero 7 -β”‚ β”‚ install.rdf # addon install conf, for Zotero 6 +β”‚ β”‚ manifest.json # addon config β”‚ β”‚ bootstrap.js # addon load/unload script, like a main.c β”‚ β”‚ β”‚ └─chrome @@ -406,7 +366,3 @@ This section shows the directory structure of a template. Use this code under AGPL. No warranties are provided. Keep the laws of your locality in mind! If you want to change the license, please contact me at wyzlshx@foxmail.com - -Part of the code of this repo refers to other open-source projects within the allowed scope. - -- zotero-better-bibtex(`d.ts`) diff --git a/addon/bootstrap.js b/addon/bootstrap.js index 7045b97..752b416 100644 --- a/addon/bootstrap.js +++ b/addon/bootstrap.js @@ -78,8 +78,6 @@ async function startup({ id, version, resourceURI, rootURI }, reason) { var manifestURI = Services.io.newURI(rootURI + "manifest.json"); chromeHandle = aomStartup.registerChrome(manifestURI, [ ["content", "__addonRef__", rootURI + "chrome/content/"], - ["locale", "__addonRef__", "en-US", rootURI + "chrome/locale/en-US/"], - ["locale", "__addonRef__", "zh-CN", rootURI + "chrome/locale/zh-CN/"], ]); } else { setDefaultPrefs(rootURI); diff --git a/addon/chrome.manifest b/addon/chrome.manifest deleted file mode 100644 index 713e1b0..0000000 --- a/addon/chrome.manifest +++ /dev/null @@ -1,3 +0,0 @@ -content __addonRef__ chrome/content/ -locale __addonRef__ en-US chrome/locale/en-US/ -locale __addonRef__ zh-CN chrome/locale/zh-CN/ diff --git a/addon/install.rdf b/addon/install.rdf deleted file mode 100644 index 3b73c4f..0000000 --- a/addon/install.rdf +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - zotero@chnm.gmu.edu - 5.0 - * - - - - - juris-m@juris-m.github.io - 5.0 - * - - - - diff --git a/scripts/build.mjs b/scripts/build.mjs index 1f1dca3..7e5079a 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -100,7 +100,6 @@ async function main() { copyFolderRecursiveSync("addon", buildDir); copyFileSync("update-template.json", "update.json"); - copyFileSync("update-template.rdf", "update.rdf"); await build({ entryPoints: ["src/index.ts"], @@ -142,7 +141,6 @@ async function main() { join(buildDir, "addon/manifest.json"), join(buildDir, "addon/bootstrap.js"), "update.json", - "update.rdf", ], from: replaceFrom, to: replaceTo, diff --git a/src/utils/locale.ts b/src/utils/locale.ts index d31f676..516dec5 100644 --- a/src/utils/locale.ts +++ b/src/utils/locale.ts @@ -6,10 +6,11 @@ export { initLocale, getString }; * Initialize locale data */ function initLocale() { - const l10n = new (ztoolkit.getGlobal("Localization"))( - [`${config.addonRef}-addon.ftl`], - true - ); + const l10n = new ( + typeof Localization === "undefined" + ? ztoolkit.getGlobal("Localization") + : Localization + )([`${config.addonRef}-addon.ftl`], true); addon.data.locale = { current: l10n, }; diff --git a/typing/global.d.ts b/typing/global.d.ts index ae6b862..8906d0b 100644 --- a/typing/global.d.ts +++ b/typing/global.d.ts @@ -17,3 +17,5 @@ declare const rootURI: string; declare const addon: import("../src/addon").default; declare const __env__: "production" | "development"; + +declare class Localization {} diff --git a/update-template.rdf b/update-template.rdf deleted file mode 100644 index 4d57597..0000000 --- a/update-template.rdf +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - __buildVersion__ - - - zotero@chnm.gmu.edu - 5.999 - * - __releasepage__ - - - - - juris-m@juris-m.github.io - 5.999 - * - __releasepage__ - - - - - - - - \ No newline at end of file diff --git a/update.rdf b/update.rdf deleted file mode 100644 index fcb8298..0000000 --- a/update.rdf +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - 0.1.6 - - - zotero@chnm.gmu.edu - 5.999 - * - https://github.com/windingwind/zotero-addon-template/releases/latest/download/zotero-addon-template.xpi - - - - - juris-m@juris-m.github.io - 5.999 - * - https://github.com/windingwind/zotero-addon-template/releases/latest/download/zotero-addon-template.xpi - - - - - - - - \ No newline at end of file