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