change: package.json config
This commit is contained in:
parent
969a5274c6
commit
67fb288be5
@ -30,11 +30,13 @@ This is an addon/plugin template for [Zotero](https://www.zotero.org/).
|
||||
author,
|
||||
description,
|
||||
homepage,
|
||||
config {
|
||||
releasepage,
|
||||
updaterdf,
|
||||
addonName,
|
||||
addonID,
|
||||
addonRef
|
||||
}
|
||||
```
|
||||
|
||||
> Be careful to set the addonID and addonRef to avoid confliction.
|
||||
|
16
build.js
16
build.js
@ -9,12 +9,8 @@ const {
|
||||
author,
|
||||
description,
|
||||
homepage,
|
||||
releasepage,
|
||||
updaterdf,
|
||||
addonName,
|
||||
addonID,
|
||||
addonRef,
|
||||
version,
|
||||
config,
|
||||
} = require("./package.json");
|
||||
|
||||
function copyFileSync(source, target) {
|
||||
@ -141,11 +137,11 @@ async function main() {
|
||||
author,
|
||||
description,
|
||||
homepage,
|
||||
releasepage,
|
||||
updaterdf,
|
||||
addonName,
|
||||
addonID,
|
||||
addonRef,
|
||||
config.releasepage,
|
||||
config.updaterdf,
|
||||
config.addonName,
|
||||
config.addonID,
|
||||
config.addonRef,
|
||||
version,
|
||||
buildTime,
|
||||
],
|
||||
|
12
package.json
12
package.json
@ -1,11 +1,15 @@
|
||||
{
|
||||
"name": "zotero-addon-template",
|
||||
"version": "0.0.4",
|
||||
"description": "Zotero Addon Template",
|
||||
"config": {
|
||||
"addonName": "Zotero Addon Template",
|
||||
"addonID": "addontemplate@euclpts.com",
|
||||
"addonRef": "addontemplate",
|
||||
"version": "0.0.4",
|
||||
"description": "Zotero Addon Template",
|
||||
"main": "src/index.js",
|
||||
"releasepage": "https://github.com/windingwind/zotero-addon-template/releases/latest/download/zotero-addon-template.xpi",
|
||||
"updaterdf": "https://raw.githubusercontent.com/windingwind/zotero-addon-template/master/update.json"
|
||||
},
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
"build": "node build.js",
|
||||
"start": "node start.js",
|
||||
@ -25,8 +29,6 @@
|
||||
"url": "https://github.com/windingwind/zotero-addon-template/issues"
|
||||
},
|
||||
"homepage": "https://github.com/windingwind/zotero-addon-template#readme",
|
||||
"releasepage": "https://github.com/windingwind/zotero-addon-template/releases/latest/download/zotero-addon-template.xpi",
|
||||
"updaterdf": "https://raw.githubusercontent.com/windingwind/zotero-addon-template/master/update.json",
|
||||
"dependencies": {
|
||||
"zotero-plugin-toolkit": "^0.0.1"
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Addon from "./addon";
|
||||
import AddonModule from "./module";
|
||||
import { addonName, addonID, addonRef } from "../package.json";
|
||||
import { config } from "../package.json";
|
||||
|
||||
class AddonEvents extends AddonModule {
|
||||
private notifierCallback: any;
|
||||
@ -33,7 +33,7 @@ class AddonEvents extends AddonModule {
|
||||
// @ts-ignore
|
||||
this._Addon.rootURI = rootURI;
|
||||
// This function is the setup code of the addon
|
||||
this._Addon.toolkit.Tool.log(`${addonName}: init called`);
|
||||
this._Addon.toolkit.Tool.log(`${config.addonName}: init called`);
|
||||
|
||||
// Register the callback in Zotero as an item observer
|
||||
let notifierID = Zotero.Notifier.registerObserver(this.notifierCallback, [
|
||||
@ -59,11 +59,11 @@ class AddonEvents extends AddonModule {
|
||||
public initPrefs() {
|
||||
this._Addon.toolkit.Tool.log(this._Addon.rootURI);
|
||||
const prefOptions = {
|
||||
pluginID: addonID,
|
||||
pluginID: config.addonID,
|
||||
src: this._Addon.rootURI + "chrome/content/preferences.xhtml",
|
||||
label: "Template",
|
||||
image: `chrome://${addonRef}/content/icons/favicon.png`,
|
||||
extraDTD: [`chrome://${addonRef}/locale/overlay.dtd`],
|
||||
image: `chrome://${config.addonRef}/content/icons/favicon.png`,
|
||||
extraDTD: [`chrome://${config.addonRef}/locale/overlay.dtd`],
|
||||
defaultXUL: true,
|
||||
onload: (win: Window) => {
|
||||
this._Addon.prefs.initPreferences(win);
|
||||
@ -84,7 +84,7 @@ class AddonEvents extends AddonModule {
|
||||
|
||||
public onUnInit(): void {
|
||||
const Zotero = this._Addon.Zotero;
|
||||
this._Addon.toolkit.Tool.log(`${addonName}: uninit called`);
|
||||
this._Addon.toolkit.Tool.log(`${config.addonName}: uninit called`);
|
||||
this.unInitPrefs();
|
||||
// Remove elements and do clean up
|
||||
this._Addon.views.unInitViews();
|
||||
|
10
src/prefs.ts
10
src/prefs.ts
@ -1,6 +1,6 @@
|
||||
import Addon from "./addon";
|
||||
import AddonModule from "./module";
|
||||
import { addonName, addonRef } from "../package.json";
|
||||
import { config } from "../package.json";
|
||||
|
||||
class AddonPrefs extends AddonModule {
|
||||
private _window!: Window;
|
||||
@ -11,7 +11,7 @@ class AddonPrefs extends AddonModule {
|
||||
// This function is called when the prefs window is opened
|
||||
// See addon/chrome/content/preferences.xul onpaneload
|
||||
this._window = _window;
|
||||
this._Addon.toolkit.Tool.log(`${addonName}: init preferences`);
|
||||
this._Addon.toolkit.Tool.log(`${config.addonName}: init preferences`);
|
||||
this.updatePrefsUI();
|
||||
this.bindPrefEvents();
|
||||
}
|
||||
@ -20,12 +20,12 @@ class AddonPrefs extends AddonModule {
|
||||
// You can initialize some UI elements on prefs window
|
||||
// with this._window.document
|
||||
// Or bind some events to the elements
|
||||
this._Addon.toolkit.Tool.log(`${addonName}: init preferences UI`);
|
||||
this._Addon.toolkit.Tool.log(`${config.addonName}: init preferences UI`);
|
||||
}
|
||||
|
||||
private bindPrefEvents() {
|
||||
this._window.document
|
||||
.querySelector(`#zotero-prefpane-${addonRef}-enable`)
|
||||
.querySelector(`#zotero-prefpane-${config.addonRef}-enable`)
|
||||
?.addEventListener("command", (e) => {
|
||||
this._Addon.toolkit.Tool.log(e);
|
||||
this._window.alert(
|
||||
@ -34,7 +34,7 @@ class AddonPrefs extends AddonModule {
|
||||
});
|
||||
|
||||
this._window.document
|
||||
.querySelector(`#zotero-prefpane-${addonRef}-input`)
|
||||
.querySelector(`#zotero-prefpane-${config.addonRef}-input`)
|
||||
?.addEventListener("change", (e) => {
|
||||
this._Addon.toolkit.Tool.log(e);
|
||||
this._window.alert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Addon from "./addon";
|
||||
import AddonModule from "./module";
|
||||
const { addonRef } = require("../package.json");
|
||||
import { config } from "../package.json";
|
||||
|
||||
class AddonViews extends AddonModule {
|
||||
// You can store some element in the object attributes
|
||||
@ -11,7 +11,7 @@ class AddonViews extends AddonModule {
|
||||
this.progressWindowIcon = {
|
||||
success: "chrome://zotero/skin/tick.png",
|
||||
fail: "chrome://zotero/skin/cross.png",
|
||||
default: `chrome://${addonRef}/content/icons/favicon.png`,
|
||||
default: `chrome://${config.addonRef}/content/icons/favicon.png`,
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user