diff --git a/bootstrap.js b/bootstrap.js index f25243b..25e7335 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -20,6 +20,7 @@ var Utils var Filter; var Image; var Ai; +var Io; var CryptoJS; var Actions; var Annotations; @@ -267,6 +268,7 @@ async function startup({ id, version, resourceURI, rootURI = resourceURI.spec }) Services.scriptloader.loadSubScript(rootURI + 'core/data.js'); Services.scriptloader.loadSubScript(rootURI + 'core/format.js'); Services.scriptloader.loadSubScript(rootURI + 'core/ai.js'); + Services.scriptloader.loadSubScript(rootURI + 'core/io.js'); Services.scriptloader.loadSubScript(rootURI + 'content/notes/actions.js'); Services.scriptloader.loadSubScript(rootURI + 'core/annotations.js'); Services.scriptloader.loadSubScript(rootURI + 'core/languages.js'); @@ -295,6 +297,7 @@ async function startup({ id, version, resourceURI, rootURI = resourceURI.spec }) ZeNotes.Filter = Filter; ZeNotes.Image = Image; ZeNotes.Ai = Ai; + ZeNotes.Io = Io; ZeNotes.CryptoJS = CryptoJS; ZeNotes.Actions = Actions; ZeNotes.Annotations = Annotations; diff --git a/content/notes/io.js b/content/notes/io.js index db7e7b9..1823982 100644 --- a/content/notes/io.js +++ b/content/notes/io.js @@ -67,6 +67,7 @@ Io = { Zotero.ZeNotes.Prefs.set("export-default-ext", fp.defaultExtension); } }, + savebinary(file, url) { fetch(url) @@ -75,6 +76,7 @@ Io = { Zotero.File.putContentsAsync(file, blob); }); }, + assets(directory, files) { Zotero.File.createDirectoryIfMissingAsync(directory).then(()=>{ diff --git a/content/settings/dropbox.xhtml b/content/settings/dropbox.xhtml index 095a1a3..c1c4908 100644 --- a/content/settings/dropbox.xhtml +++ b/content/settings/dropbox.xhtml @@ -30,6 +30,13 @@ + + From file + + + + + diff --git a/core/io.js b/core/io.js new file mode 100644 index 0000000..2f447e9 --- /dev/null +++ b/core/io.js @@ -0,0 +1,31 @@ +var { OS } = ChromeUtils.importESModule("chrome://zotero/content/osfile.mjs"); +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); + +Io = { + async savedialog(title, filter, extension, defaultstring, contents) + { + let fp = new FilePicker(); + fp.init(window, title, fp.modeSave); + fp.appendFilter(filter, extension); + fp.defaultString = defaultstring; + var rv = await fp.show(); + if(rv == fp.returnOK || rv == fp.returnReplace) + { + let outputFile = fp.file; + Zotero.File.putContentsAsync(outputFile, contents); + } + }, + async loaddialog(title, filter, extension, defaultstring) + { + let fp = new FilePicker(); + fp.init(window, title, fp.modeOpen); + fp.appendFilter(filter, extension); + fp.defaultString = defaultstring; + var rv = await fp.show(); + if(rv == fp.returnOK) + { + let outputFile = fp.file; + return await Zotero.File.getContentsAsync("file:///"+outputFile); + } + } +} \ No newline at end of file diff --git a/core/nsync.js b/core/nsync.js index c798f7a..7293a89 100644 --- a/core/nsync.js +++ b/core/nsync.js @@ -355,5 +355,49 @@ NSync = { } } return true; + }, + + loadsettings() + { + let title = "Export Dropbox settings"; + let filter = "ZeNotes Dropbox Settings (*.zdb)"; + let extension = "*.zdb"; + let defaultstring = "zenotes-dropbox-settings.zdb"; + Zotero.ZeNotes.Io.loaddialog(title, filter, extension, defaultstring).then(settings=>{ + try { + let s = JSON.parse(Zotero.ZeNotes.decrypt(settings)); + if(!confirm("Do you want to import the settings for Dropbox?")) + { + return; + } + + Zotero.ZeNotes.Prefs.setb('dropbox-access-token', s["dropbox-access-token"]); + Zotero.ZeNotes.Prefs.setb('dropbox-refresh-token', s["dropbox-refresh-token"]); + Zotero.ZeNotes.Prefs.setb('dropbox-client-id', s["dropbox-client-id"]); + Zotero.ZeNotes.Prefs.setb('dropbox-client-secret', s["dropbox-client-secret"]); + Zotero.ZeNotes.Prefs.set("dropbox-target-user", s["dropbox-target-user"]); + } + catch(e) + { + alert(e); + } + }) + }, + + exportsettings() + { + let settings = Zotero.ZeNotes.encrypt(JSON.stringify( + { + "dropbox-access-token": Zotero.ZeNotes.Prefs.getb('dropbox-access-token', ''), + "dropbox-refresh-token": Zotero.ZeNotes.Prefs.getb('dropbox-refresh-token', ''), + "dropbox-client-id": Zotero.ZeNotes.Prefs.getb('dropbox-client-id', ''), + "dropbox-client-secret": Zotero.ZeNotes.Prefs.getb('dropbox-client-secret', ''), + "dropbox-target-user": Zotero.Prefs.get("extensions.zotero.sync.server.username", true) + })); + let title = "Export Dropbox settings"; + let filter = "ZeNotes Dropbox Settings (*.zdb)"; + let extension = "*.zdb"; + let defaultstring = "zenotes-dropbox-settings.zdb"; + Zotero.ZeNotes.Io.savedialog(title, filter, extension, defaultstring, settings); } } \ No newline at end of file diff --git a/install.rdf b/install.rdf index f0c73e3..72af4d9 100644 --- a/install.rdf +++ b/install.rdf @@ -5,7 +5,7 @@ zenotes@alefa.net ZeNotes - 0.9.4 + 0.9.5 true https://github.com/frianasoa/Ze-Notes/releases/download/release/zenotes-update.rdf https://github.com/frianasoa/zenotes diff --git a/manifest.json b/manifest.json index 9ead098..ecc0276 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Ze Notes", - "version": "0.9.4", + "version": "0.9.5", "description": "Advanced notes manager", "author": "Fanantenana Rianasoa Andriariniaina", "homepage_url": "https://github.com/frianasoa/zenotes", @@ -13,7 +13,7 @@ "zotero": { "id": "zenotes@alefa.net", "update_url": "https://github.com/frianasoa/Ze-Notes/releases/download/release/zenotes-update.json", - "strict_min_version": "6.0", + "strict_min_version": "7.0.0-beta.70", "strict_max_version": "7.0.*" }, "gecko": { diff --git a/zenotes-update.json b/zenotes-update.json index 8428537..8bf8cb3 100644 --- a/zenotes-update.json +++ b/zenotes-update.json @@ -3,9 +3,9 @@ "zenotes@alefa.net": { "updates": [ { - "version": "0.9.4", - "update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.9.4/zenotes-v0.9.4.xpi", - "update_hash": "sha512:d320b6a7b5c6f6357f67d1a7a8a052e043f85cf9ddb3313fc27c95d4e6984a9b106df7e9504a2cc288e2da14a75b5b783b78b4c98ce6b4759a3d58f9309e4b24", + "version": "0.9.5", + "update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.9.5/zenotes-v0.9.5.xpi", + "update_hash": "sha512:7e1c7631c12b5dd9c1649527d4f1673baf03efe47529af97a29f3b0297771cf90a2587e14a8a7eccd7647ab90dec89363814ad7d9a83575a1021d16714b57dc0", "applications": { "gecko": { "strict_min_version": "6.0", diff --git a/zenotes-update.rdf b/zenotes-update.rdf index f269e45..f9211fe 100644 --- a/zenotes-update.rdf +++ b/zenotes-update.rdf @@ -5,13 +5,13 @@ - 0.9.4 + 0.9.5 zotero@chnm.gmu.edu 5.0.0 6.* - https://github.com/frianasoa/Ze-Notes/releases/download/v0.9.4/zenotes-v0.9.4.xpi + https://github.com/frianasoa/Ze-Notes/releases/download/v0.9.5/zenotes-v0.9.5.xpi @@ -20,7 +20,7 @@ juris-m@juris-m.github.io 4.999 6.* - https://github.com/frianasoa/Ze-Notes/releases/download/v0.9.4/zenotes-v0.9.4.xpi + https://github.com/frianasoa/Ze-Notes/releases/download/v0.9.5/zenotes-v0.9.5.xpi