Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
RoadToDream committed Sep 11, 2023
0 parents commit 5580f04
Showing 18 changed files with 982 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Define variables
SRC_DIR := src
BUILD_DIR := build
VERSION:=$(shell grep em:version src/install.rdf | head -n 1 | sed -e 's/ *<em:version>//' -e 's/<\/em:version>//')
ZIP_FILE_NAME := zotmeta-$(VERSION).xpi
ZIP_FILE_PATH := $(BUILD_DIR)/$(ZIP_FILE_NAME)
JSON_FILE := updates.json


# Default target
all: $(ZIP_FILE_PATH) $(JSON_FILE)

# Target to zip all files in the source folder
$(ZIP_FILE_PATH): | $(BUILD_DIR)
(cd $(SRC_DIR) && zip -r $(abspath $@) .)

# Target to generate a updates.json file
$(JSON_FILE): | $(BUILD_DIR)
jq ".addons[\"zotmeta@roadtodream.tech\"].updates[0].update_hash = \"sha256:`shasum -a 256 $(ZIP_FILE_PATH) | cut -d' ' -f1`\"" updates.json.tmpl | \
jq ".addons[\"zotmeta@roadtodream.tech\"].updates[0].update_link = \"https://github.com/RoadToDream/ZotMeta/releases/download/v$(VERSION)/$(ZIP_FILE_NAME)\"" > $@

# Create the build directory if it doesn't exist
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)

# Clean up generated files
clean:
rm -rf $(BUILD_DIR)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ZotMeta: Metadata update tool
ZotMeta is a Zotero plugin to update articles metadata.
37 changes: 37 additions & 0 deletions src/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var ZotMeta;

function log(msg) {
Zotero.debug("ZotMeta: " + msg);
}

function install() {
log("Installed");
}

async function startup({ id, version, rootURI }) {
log("Starting");

// Load chrome/content file directly via file:/// URL
Services.scriptloader.loadSubScript(rootURI + 'chrome/content/utilities.js');
Services.scriptloader.loadSubScript(rootURI + 'chrome/content/threadpool.js');
Services.scriptloader.loadSubScript(rootURI + 'chrome/content/zotmeta.js');
ZotMeta.init({ id, version, rootURI });
ZotMeta.addToAllWindows();
}

function onMainWindowLoad({ window }) {
ZotMeta.addToWindow(window);
}

function onMainWindowUnload({ window }) {
ZotMeta.removeFromWindow(window);
}

function shutdown() {
log("Shutting down");
ZotMeta.removeFromAllWindows();
}

function uninstall() {
log("Uninstalled");
}
4 changes: 4 additions & 0 deletions src/chrome.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
content zotmeta chrome/content/
skin zotmeta default chrome/skin/
locale zotmeta en-US chrome/locale/en-US/
overlay chrome://zotero/content/zoteroPane.xul chrome://zotmeta/content/overlay.xul
5 changes: 5 additions & 0 deletions src/chrome/content/overlay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
window.addEventListener('load', async function (event) {
await Zotero.initializationPromise;
ZotMeta.init();
ZotMeta.addToWindow(window);
});
9 changes: 9 additions & 0 deletions src/chrome/content/overlay.xul
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>

<overlay id="zotmeta-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="overlay.js"/>
<script src="threadpool.js"/>
<script src="utilities.js"/>
<script src="zotmeta.js"/>
</overlay>
Loading

0 comments on commit 5580f04

Please sign in to comment.