Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: chrome/content -> content #213

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 36 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ Steps of build:
- Prepare locale files to [avoid conflict](https://www.zotero.org/support/dev/zotero_7_for_developers#avoiding_localization_conflicts)
- Rename `**/*.flt` to `**/${addonRef}-*.flt`
- Prefix each fluent message with `addonRef-`
- Use ESBuild to build `.ts` source code to `.js`, build `src/index.ts` to `./build/addon/chrome/content/scripts`.
- Use ESBuild to build `.ts` source code to `.js`, build `src/index.ts` to `./build/addon/content/scripts`.
- (Production mode only) Zip the `./build/addon` to `./build/*.xpi`
- (Production mode only) Prepare `update.json` or `update-beta.json`

Expand All @@ -271,7 +271,7 @@ npm run release

> [!note]
> This will use [Bumpp](https://github.com/antfu-collective/bumpp) to prompt for the new version number, locally bump the version, run any (pre/post)version scripts defined in `package.json`, commit, build (optional), tag the commit with the version number and push commits and git.tags. Bumpp can be configured in `zotero-plugin-config.ts`; for example, add `release: { bumpp: { execute: "npm run build" } }` to also build before committing.
>
>
> Subsequently GitHub Action will rebuild the plugin and use `zotero-plugin-scaffold`'s `release` script to publish the XPI to GitHub Release. In addition, a separate release (tag: `release`) will be created or updated that includes update manifests `update.json` and `update-beta.json` as assets. These will be available at `https://github.com/{{owner}}/{{repo}}/releases/download/release/update*.json`.

#### About Prerelease
Expand Down Expand Up @@ -340,70 +340,63 @@ This section shows the directory structure of a template.

- All `.js/.ts` code files are in `./src`;
- Addon config files: `./addon/manifest.json`;
- UI files: `./addon/chrome/content/*.xhtml`.
- UI files: `./addon/content/*.xhtml`.
- Locale files: `./addon/locale/**/*.flt`;
- Preferences file: `./addon/prefs.js`;
> Don't break the lines in the `prefs.js`

```shell
.
|-- .eslintrc.json # eslint conf
|-- .gitattributes # git conf
|-- .github/ # github conf
|-- .gitignore # git conf
|-- .prettierrc # prettier conf
|-- .release-it.json # release-it conf
|-- .vscode # vs code conf
| |-- extensions.json
| |-- launch.json
| |-- setting.json
| `-- toolkit.code-snippets
|-- package-lock.json # npm conf
|-- package.json # npm conf
|-- LICENSE
|-- README.md
|-- addon
| |-- bootstrap.js # addon load/unload script, like a main.c
| |-- chrome
| | `-- content
| | |-- icons/
| | |-- preferences.xhtml # preference panel
| | `-- zoteroPane.css
| |-- locale # locale
|-- .vscode/ # vscode conf
|-- addon # static files
| |-- bootstrap.js
| |-- content
| | |-- icons
| | | |-- favicon.png
| | | `-- [email protected]
| | |-- preferences.xhtml
| | `-- zoteroPane.css
| |-- locale
| | |-- en-US
| | | |-- addon.ftl
| | | |-- mainWindow.ftl
| | | `-- preferences.ftl
| | `-- zh-CN
| | |-- addon.ftl
| | |-- mainWindow.ftl
| | `-- preferences.ftl
| |-- manifest.json # addon config
| |-- manifest.json
| `-- prefs.js
|-- build/ # build dir
|-- scripts # scripts for dev
| |-- build.mjs # script to build plugin
| |-- scripts.mjs # scripts send to Zotero, such as reload, openDevTool, etc
| |-- server.mjs # script to start a development server
| |-- start.mjs # script to start Zotero process
| |-- stop.mjs # script to kill Zotero process
| |-- utils.mjs # utils functions for dev scripts
| |-- update-template.json # template of `update.json`
| `-- zotero-cmd-template.json # template of local env
|-- src # source code
|-- build # build dir
|-- node_modules
|-- src # source code of scripts
| |-- addon.ts # base class
| |-- hooks.ts # lifecycle hooks
| |-- index.ts # main entry
| |-- modules # sub modules
| | |-- examples.ts
| | `-- preferenceScript.ts
| `-- utils # utilities
| `-- utils # utilities
| |-- locale.ts
| |-- prefs.ts
| |-- wait.ts
| `-- window.ts
|-- tsconfig.json # https://code.visualstudio.com/docs/languages/jsconfig
|-- typings # ts typings
| |-- window.ts
| `-- ztoolkit.ts
|-- typings # ts typings
| `-- global.d.ts
`-- update.json

|-- .env # enviroment config (do not check into repo)
|-- .env.example # template of enviroment config, https://github.com/northword/zotero-plugin-scaffold
|-- .gitignore # git conf
|-- .gitattributes # git conf
|-- .prettierrc # prettier conf, https://prettier.io/
|-- eslint.config.mjs # eslint conf, https://eslint.org/
|-- LICENSE
|-- package-lock.json
|-- package.json
|-- tsconfig.json # typescript conf, https://code.visualstudio.com/docs/languages/jsconfig
|-- README.md
`-- zotero-plugin.config.ts # scaffold conf, https://github.com/northword/zotero-plugin-scaffold
```

## Disclaimer
Expand Down
6 changes: 3 additions & 3 deletions addon/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function startup({ id, version, resourceURI, rootURI }, reason) {
].getService(Components.interfaces.amIAddonManagerStartup);
var manifestURI = Services.io.newURI(rootURI + "manifest.json");
chromeHandle = aomStartup.registerChrome(manifestURI, [
["content", "__addonRef__", rootURI + "chrome/content/"],
["content", "__addonRef__", rootURI + "content/"],
]);

/**
Expand All @@ -39,7 +39,7 @@ async function startup({ id, version, resourceURI, rootURI }, reason) {
ctx._globalThis = ctx;

Services.scriptloader.loadSubScript(
`${rootURI}/chrome/content/scripts/__addonRef__.js`,
`${rootURI}/content/scripts/__addonRef__.js`,
ctx,
);
Zotero.__addonInstance__.hooks.onStartup();
Expand Down Expand Up @@ -69,7 +69,7 @@ function shutdown({ id, version, resourceURI, rootURI }, reason) {
.getService(Components.interfaces.nsIStringBundleService)
.flushBundles();

Cu.unload(`${rootURI}/chrome/content/scripts/__addonRef__.js`);
Cu.unload(`${rootURI}/content/scripts/__addonRef__.js`);

if (chromeHandle) {
chromeHandle.destruct();
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions addon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"homepage_url": "__homepage__",
"author": "__author__",
"icons": {
"48": "chrome/content/icons/[email protected]",
"96": "chrome/content/icons/favicon.png"
"48": "content/icons/[email protected]",
"96": "content/icons/favicon.png"
},
"applications": {
"zotero": {
Expand Down
77 changes: 35 additions & 42 deletions doc/README-zhCN.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ Obsidian风格的指令输入模块,它通过接受文本来运行插件,并
- 准备本地化文件以避免冲突,查看官方文档了解更多(<https://www.zotero.org/support/dev/zotero_7_for_developers#avoiding_localization_conflicts)>
- 重命名`**/*.flt` 为 `**/${addonRef}-*.flt`
- 在每个消息前加上 `addonRef-`
- 使用 Esbuild 来将 `.ts` 源码构建为 `.js`,从 `src/index.ts` 构建到`./build/addon/chrome/content/scripts`
- 使用 Esbuild 来将 `.ts` 源码构建为 `.js`,从 `src/index.ts` 构建到`./build/addon/content/scripts`
- (仅在生产模式下工作) 压缩 `./build/addon` 目录为 `./build/*.xpi`
- (仅在生产模式下工作) 准备 `update.json` 或 `update-beta.json`

Expand Down Expand Up @@ -340,70 +340,63 @@ Zotero 文档已过时且不完整,克隆 <https://github.com/zotero/zotero>

- 所有的 `.js/.ts` 代码都在 `./src`;
- 插件配置文件:`./addon/manifest.json`;
- UI 文件: `./addon/chrome/content/*.xhtml`.
- UI 文件: `./addon/content/*.xhtml`.
- 区域设置文件: `./addon/locale/**/*.flt`;
- 首选项文件: `./addon/prefs.js`;
> 不要在 `prefs.js` 中换行

```shell
.
|-- .eslintrc.json # eslint conf
|-- .gitattributes # git conf
|-- .github/ # github conf
|-- .gitignore # git conf
|-- .prettierrc # prettier conf
|-- .release-it.json # release-it conf
|-- .vscode # vs code conf
| |-- extensions.json
| |-- launch.json
| |-- setting.json
| `-- toolkit.code-snippets
|-- package-lock.json # npm conf
|-- package.json # npm conf
|-- LICENSE
|-- README.md
|-- addon
| |-- bootstrap.js # addon load/unload script, like a main.c
| |-- chrome
| | `-- content
| | |-- icons/
| | |-- preferences.xhtml # preference panel
| | `-- zoteroPane.css
| |-- locale # locale
|-- .vscode/ # vscode conf
|-- addon # static files
| |-- bootstrap.js
| |-- content
| | |-- icons
| | | |-- favicon.png
| | | `-- [email protected]
| | |-- preferences.xhtml
| | `-- zoteroPane.css
| |-- locale
| | |-- en-US
| | | |-- addon.ftl
| | | |-- mainWindow.ftl
| | | `-- preferences.ftl
| | `-- zh-CN
| | |-- addon.ftl
| | |-- mainWindow.ftl
| | `-- preferences.ftl
| |-- manifest.json # addon config
| |-- manifest.json
| `-- prefs.js
|-- build/ # build dir
|-- scripts # scripts for dev
| |-- build.mjs # script to build plugin
| |-- scripts.mjs # scripts send to Zotero, such as reload, openDevTool, etc
| |-- server.mjs # script to start a development server
| |-- start.mjs # script to start Zotero process
| |-- stop.mjs # script to kill Zotero process
| |-- utils.mjs # utils functions for dev scripts
| |-- update-template.json # template of `update.json`
| `-- zotero-cmd-template.json # template of local env
|-- src # source code
|-- build # build dir
|-- node_modules
|-- src # source code of scripts
| |-- addon.ts # base class
| |-- hooks.ts # lifecycle hooks
| |-- index.ts # main entry
| |-- modules # sub modules
| | |-- examples.ts
| | `-- preferenceScript.ts
| `-- utils # utilities
| `-- utils # utilities
| |-- locale.ts
| |-- prefs.ts
| |-- wait.ts
| `-- window.ts
|-- tsconfig.json # https://code.visualstudio.com/docs/languages/jsconfig
|-- typings # ts typings
| |-- window.ts
| `-- ztoolkit.ts
|-- typings # ts typings
| `-- global.d.ts
`-- update.json

|-- .env # enviroment config (do not check into repo)
|-- .env.example # template of enviroment config, https://github.com/northword/zotero-plugin-scaffold
|-- .gitignore # git conf
|-- .gitattributes # git conf
|-- .prettierrc # prettier conf, https://prettier.io/
|-- eslint.config.mjs # eslint conf, https://eslint.org/
|-- LICENSE
|-- package-lock.json
|-- package.json
|-- tsconfig.json # typescript conf, https://code.visualstudio.com/docs/languages/jsconfig
|-- README.md
`-- zotero-plugin.config.ts # scaffold conf, https://github.com/northword/zotero-plugin-scaffold
```

## Disclaimer 免责声明
Expand Down
2 changes: 1 addition & 1 deletion src/modules/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class BasicExampleFactory {
static registerPrefs() {
Zotero.PreferencePanes.register({
pluginID: config.addonID,
src: rootURI + "chrome/content/preferences.xhtml",
src: rootURI + "content/preferences.xhtml",
label: getString("prefs-title"),
image: `chrome://${config.addonRef}/content/icons/favicon.png`,
});
Expand Down
2 changes: 1 addition & 1 deletion src/modules/preferenceScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getString } from "../utils/locale";

export async function registerPrefsScripts(_window: Window) {
// This function is called when the prefs window is opened
// See addon/chrome/content/preferences.xul onpaneload
// See addon/content/preferences.xhtml onpaneload
if (!addon.data.prefs) {
addon.data.prefs = {
window: _window,
Expand Down
2 changes: 1 addition & 1 deletion zotero-plugin.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default defineConfig({
},
bundle: true,
target: "firefox115",
outfile: `build/addon/chrome/content/scripts/${pkg.config.addonRef}.js`,
outfile: `build/addon/content/scripts/${pkg.config.addonRef}.js`,
},
],
},
Expand Down