Skip to content

Commit

Permalink
First beta version for Zotero 7 (beta)
Browse files Browse the repository at this point in the history
  • Loading branch information
frianasoa committed Nov 9, 2023
1 parent b660af4 commit e9967a7
Show file tree
Hide file tree
Showing 77 changed files with 2,022 additions and 2,196 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build
build/
run.cmd
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Ze Notes
[![zotero](https://raw.githubusercontent.com/frianasoa/zenotes/main/assets/images/for-zotero-6.svg)](https://zotero.org)

Start working on Zotero 7. Could take some time.
Start working on Zotero 7. Still has some bugs. No auto update yet.

## Description
ZeNotes is a Zotero plugin that will help you manage and visualize your notes. It is helpfull if you intend to make a systematic review directly on your Zotero using notes. This tool will help you organize your notes on Zotero. It will show you on a table what you have been writing. You can edit your notes right on the table or add new notes.
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
200 changes: 83 additions & 117 deletions bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,131 +1,97 @@
/* Copyright 2012 Will Shanks.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

if (typeof Zotero == "undefined") {
var Zotero;
var Zotero_Tabs;
}

var ZeNotes;
var Zotero_Tabs;
var Menu;
var Prefs;
var Data;
var Database;
var Ui;
var Format;
var chromeHandle;

// In Zotero 6, bootstrap methods are called before Zotero is initialized, and using include.js
// to get the Zotero XPCOM service would risk breaking Zotero startup. Instead, wait for the main
// Zotero window to open and get the Zotero object from there.
//
// In Zotero 7, bootstrap methods are not called until Zotero is initialized, and the 'Zotero' is
// automatically made available.
async function waitForZotero() {
if (typeof Zotero != "undefined") {
await Zotero.initializationPromise;
}

var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var windows = Services.wm.getEnumerator("navigator:browser");
var found = false;
while (windows.hasMoreElements()) {
let win = windows.getNext();
if (win.Zotero) {
Zotero = win.Zotero;
Zotero_Tabs = win.Zotero_Tabs;
found = true;
break;
}
}
if (!found) {
await new Promise((resolve) => {
var listener = {
onOpenWindow: function (aWindow) {
// Wait for the window to finish loading
let domWindow = aWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
domWindow.addEventListener(
"load",
function () {
domWindow.removeEventListener("load", arguments.callee, false);
if (domWindow.Zotero) {
Services.wm.removeListener(listener);
Zotero = domWindow.Zotero;
Zotero_Tabs = domWindow.Zotero_Tabs;
resolve();
}
},
false
);
},
};
Services.wm.addListener(listener);
});
}
await Zotero.initializationPromise;
}

function install(data, reason) {}

async function startup({ id, version, resourceURI, rootURI }, reason) {
await waitForZotero();
const ANNOTATION = 1;
const ATTACHMENT = 3;
const NOTE = 28;

// String 'rootURI' introduced in Zotero 7
if (!rootURI) {
rootURI = resourceURI.spec;
}

const window = Zotero.getMainWindow();

// Global variables for plugin code
const ctx = {
Zotero,
Zotero_Tabs: Zotero_Tabs,
rootURI,
window,
document: window.document,
ZoteroPane: Zotero.getActiveZoteroPane(),
};
function log(msg) {
Zotero.debug("ZeNotes: " + msg);
}

Services.scriptloader.loadSubScript(
`chrome://zenotes/content/zenotes.js`,
ctx
);

Zotero.ZeNotes.initdisplay();
function install() {
log("Installed 2.0");
}

if (Zotero.platformMajorVersion >= 102)
{
var aomStartup = Components.classes[
"@mozilla.org/addons/addon-manager-startup;1"
].getService(Components.interfaces.amIAddonManagerStartup);
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__", "ja-JA", rootURI + "chrome/locale/ja-JA/"],
function registerchrome(rootURI){
var aomStartup = Cc["@mozilla.org/addons/addon-manager-startup;1"].getService(Ci.amIAddonManagerStartup);

var manifestURI = Services.io.newURI(rootURI + "manifest.json");
chromeHandle = aomStartup.registerChrome(manifestURI, [
["content", "ze-notes-7", "pages/"],
]);
}
}

function shutdown({ id, version, resourceURI, rootURI }, reason) {
if (reason === APP_SHUTDOWN) {
return;
}
if (typeof Zotero === "undefined") {
Zotero = Components.classes["@zotero.org/Zotero;1"].getService(
Components.interfaces.nsISupports
).wrappedJSObject;
}
Zotero.AddonTemplate.events.onUnInit(Zotero);
async function startup({ id, version, rootURI }) {
log("Starting 2.0");
registerchrome(rootURI);
Zotero.PreferencePanes.register({
pluginID: '[email protected]',
id: '[email protected]',
stylesheets: [
rootURI + 'pages/settings/preferences.css',
rootURI + 'pages/lib/fontawesome/6.1.1/css/all.min.css',
],
src: rootURI + 'pages/settings/preferences.xhtml',
scripts: [
rootURI + 'pages/settings/zntable.js',
rootURI + 'pages/settings/preferences.js',
],
image: rootURI+"/assets/zenotes-settings.png"
});

Services.scriptloader.loadSubScript(rootURI + 'core/ui.js');
Services.scriptloader.loadSubScript(rootURI + 'core/zenotes.js');
Services.scriptloader.loadSubScript(rootURI + 'core/menu.js');
Services.scriptloader.loadSubScript(rootURI + 'core/data.js');
Services.scriptloader.loadSubScript(rootURI + 'core/database.js');
Services.scriptloader.loadSubScript(rootURI + 'core/prefs.js');
Services.scriptloader.loadSubScript(rootURI + 'core/format.js');

ZeNotes.init({ id, version, rootURI});
ZeNotes.addToAllWindows();
Menu.addToAllWindows();

// Zotero_Tabs is set in addToAllWindows in Menu
Zotero_Tabs = ZeNotes.window.Zotero_Tabs;
ZeNotes.Menu = Menu;
ZeNotes.Ui = Ui;
// ZeNotes.browser = browser;
ZeNotes.Data = Data;
ZeNotes.Database = Database;
ZeNotes.Prefs = Prefs;
ZeNotes.Format = Format;
Zotero.ZeNotes = ZeNotes;

Database.create();

await Zotero.ZeNotes.main();
}

Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService)
.flushBundles();
function onMainWindowLoad({ window }) {
ZeNotes.addToWindow(window);
}

Cu.unload(`chrome://zenotes/content/zenotes.js`);
function onMainWindowUnload({ window }) {
ZeNotes.removeFromWindow(window);
}

if (chromeHandle) {
chromeHandle.destruct();
chromeHandle = null;
}
function shutdown() {
log("Shutting down 2.0");
ZeNotes.removeFromAllWindows();
ZeNotes = undefined;
chromeHandle.destruct();
chromeHandle = null;
}

function uninstall(data, reason) {}
function uninstall() {
log("Uninstalled 2.0");
}
7 changes: 0 additions & 7 deletions chrome.manifest

This file was deleted.

Loading

0 comments on commit e9967a7

Please sign in to comment.