Skip to content

Commit

Permalink
make warning more informative
Browse files Browse the repository at this point in the history
  • Loading branch information
daeh committed May 17, 2022
1 parent 2b324f9 commit 829fc3e
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Opens an existing Markdown note in [Obsidian](https://obsidian.md) from the cont
- Run Zotero (version 5.x or 6.x)
- Go to `Tools -> Add-ons`
- `Install Add-on From File`
- Choose the file `zotero-obsidian-citations-0.0.15.xpi`
- Choose the file `zotero-obsidian-citations-0.0.16.xpi`
- Restart Zotero

## Setup
Expand Down
2 changes: 1 addition & 1 deletion bin/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

version='0.0.15'
version='0.0.16'

rm -f zotero-obsidian-citations-${version}.xpi
zip -r zotero-obsidian-citations-${version}.xpi chrome/* defaults/* chrome.manifest install.rdf
Expand Down
13 changes: 13 additions & 0 deletions chrome/content/options.xul
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@
<separator/>

<!-- vault name -->
<label value="&obscite.preferences.vaultname-break;"/>

<separator/>

<label value="&obscite.preferences.vaultname-label0;"/>
<label value="&obscite.preferences.vaultname-label;"/>
<hbox style="margin: 0" align="center">
<label value="&obscite.preferences.vaultname-label2;"/>
Expand All @@ -162,6 +167,14 @@
<button id="id-obscite-rundebug-button" label="&obscite.preferences.rundebug-button-label;" oncommand="Zotero.ObsCite.runAndSaveDebug();"/>
<separator/>
</groupbox>

<!-- open github issues -->
<!-- <hbox style="margin: 0">
<label style="margin-right:0px" value="&...;"/>
<label style="margin-left:0px; margin-right:0px" class="text-link" onclick="Zotero.ObsCite.loadURL('https://github.com/daeh/zotero-obsidian-citations/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc');" value="&...;"/>
<label style="margin-left:0px; margin-right:0px" value="."/>
</hbox> -->

</tabpanel>

</tabpanels>
Expand Down
45 changes: 21 additions & 24 deletions chrome/content/scripts/zoteroobscite.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (typeof Zotero === 'undefined') {
}

Zotero.ObsCite = {
version: '0.0.15',
version: '0.0.16',
folderSep: null,
cleanrun: true,
suppressNotifications: false,
Expand Down Expand Up @@ -195,8 +195,6 @@ Zotero.ObsCite = {
}
},



// _getParam_bbtjson: function () {
// try {
// const bbtjson = this.getPref('bbtjson');
Expand All @@ -223,7 +221,7 @@ Zotero.ObsCite = {
throw new Error("bbtjson is not set or does not exist.");
}
} catch (e) {
this.showNotification("User Defined RegEx Invalid", "The RegEx you specifed in the ZoteroObsidianCitations preferences is invalid: " + e, false);
this.showNotification("User Defined RegEx Invalid", "The RegEx you specified in the ZoteroObsidianCitations preferences is invalid: " + e, false);
Zotero.debug(`ObsVault Error: ${e}`);
return null;
}
Expand Down Expand Up @@ -339,7 +337,7 @@ Zotero.ObsCite = {
return false;
}
} else {
this.showNotification("ZoteroObsidianCitations", 'Zotero IDs Source Not Specified: ' + matchstrategy, false);
this.showNotification("ZotObsCite Error", 'Zotero IDs Source Not Specified: ' + matchstrategy, false);
checkSettings_trace.matchstrategy = matchstrategy;
this.debugSettingsFail = checkSettings_trace;
return false;
Expand Down Expand Up @@ -597,9 +595,9 @@ Zotero.ObsCite = {
if (promptSaveErrors) {
const dataErrors = JSON.stringify(reserrs, null, 1);
const warningTitle = "Markdown Import Error";
const warningMessage = "There were " + nerr.toString() + " Markdown notes that could note be parsed. \n\nWould you like to save these errors to a json file? \n\n(There were " + (res.length - reserrs.length).toString() + " notes parsed successfully.)";
const warningMessage = "There were " + nerr.toString() + " Markdown notes that could not be parsed. \n\nWould you like to save these errors to a json file? \n\n(There were " + (res.length - reserrs.length).toString() + " notes parsed successfully.)";
const saveDialogTitle = "Save ZoteroObsidianCitations Errors To...";
const filenamesuggest = 'ZoteroObsidianCitations-md-parsing-errors.json';
const filenamesuggest = 'ZotObsCite-md-parsing-errors.json';
await this.offerToSaveErrors(dataErrors, warningTitle, warningMessage, saveDialogTitle, filenamesuggest);
} else {
this.showNotification("scanVault", "Unable to parse " + nerr.toString() + " of " + mdFiles.length.toString() + " notes.", false);
Expand Down Expand Up @@ -699,9 +697,9 @@ Zotero.ObsCite = {
if (promptSaveErrors) {
const dataErrors = JSON.stringify(reserrs, null, 1);
const warningTitle = "Markdown Import Error";
const warningMessage = "There were " + nerr.toString() + " Markdown notes that could note be parsed. \n\nWould you like to save these errors to a json file? \n\n(There were " + (res.length - reserrs.length).toString() + " notes parsed successfully.)";
const warningMessage = "There were " + nerr.toString() + " Markdown notes that could not be parsed. \n\nWould you like to save these errors to a json file? \n\n(There were " + (res.length - reserrs.length).toString() + " notes parsed successfully.)";
const saveDialogTitle = "Save ZoteroObsidianCitations Errors To...";
const filenamesuggest = 'ZoteroObsidianCitations-md-parsing-errors.json';
const filenamesuggest = 'ZotObsCite-md-parsing-errors.json';
await this.offerToSaveErrors(dataErrors, warningTitle, warningMessage, saveDialogTitle, filenamesuggest);
} else {
this.showNotification("scanVaultCustomRegex", "Unable to parse " + nerr.toString() + " of " + mdFiles.length.toString() + " notes.", false);
Expand All @@ -710,7 +708,6 @@ Zotero.ObsCite = {
return res;
},


// mapCitekeysBBTJSON: async function () {
// /*
// * make dict of BBTcitekey:zoteroID for every item in the BBTJSON file
Expand Down Expand Up @@ -904,13 +901,13 @@ Zotero.ObsCite = {

if (promptSaveErrors) {
const dataErrors = JSON.stringify(reserr, null, 1);
const warningTitle = "Umatched citekeys";
const warningTitle = "ZotObsCite Warning: Unmatched citekeys";
const warningMessage = "There were " + nerr.toString() + " citekeys in your Markdown notes that could not be matched to items in your Zotero library. \n\nWould you like to save the names of these citekeys in a json file? \n\n(Matches for " + (res.length - reserr.length).toString() + " citekeys were found successfully.)";
const saveDialogTitle = "Save ZoteroObsidianCitations Errors To...";
const filenamesuggest = 'ZoteroObsidianCitations-missing-entries.json';
const filenamesuggest = 'ZotObsCite-missing-entries.json';
await this.offerToSaveErrors(dataErrors, warningTitle, warningMessage, saveDialogTitle, filenamesuggest);
} else {
this.showNotification("ZoteroObsidianCitations", "sliceObj Error: " + nerr.toString() + ".", false);
this.showNotification("ZotObsCite Warning", "" + nerr.toString() + " unmatched citekeys. Run Sync from Tools menu to generate report.", false);
}
}
return res;
Expand Down Expand Up @@ -944,13 +941,13 @@ Zotero.ObsCite = {

if (promptSaveErrors) {
const dataErrors = JSON.stringify(reserr, null, 1);
const warningTitle = "Umatched zoteroKeys";
const warningTitle = "ZotObsCite Warning: Unmatched zoteroKeys";
const warningMessage = "There were " + nerr.toString() + " zoteroKeys in your Markdown notes that could not be matched to items in your Zotero library. \n\nWould you like to save the names of these in a json file? \n\n(Matches for " + (res.length - reserr.length).toString() + " zoteroIDs were found successfully.)";
const saveDialogTitle = "Save ZoteroObsidianCitations Errors To...";
const filenamesuggest = 'ZoteroObsidianCitations-missing-entries.json';
const filenamesuggest = 'ZotObsCite-missing-entries.json';
await this.offerToSaveErrors(dataErrors, warningTitle, warningMessage, saveDialogTitle, filenamesuggest);
} else {
this.showNotification("ZoteroObsidianCitations", "sliceObjCustomRegex Error: " + nerr.toString() + ".", false);
this.showNotification("ZotObsCite sliceObjCustomRegex Warning", "" + nerr.toString() + " unmatched zoteroKeys. Run Sync from Tools menu to generate report.", false);
}
}
return res;
Expand Down Expand Up @@ -1065,10 +1062,10 @@ Zotero.ObsCite = {

if (!this.cleanrun && promptSaveErrors) {
const dataErrors = JSON.stringify(res, null, 1);
const warningTitle = "ZoteroObsidianCitations Warning";
const warningMessage = "There an issue matching some of your Markdown notes (" + this.dataKeys.length.toString() + " notes were matched successfully).\n\nWould you like to save the data extracted from the notes to a json file?";
const warningTitle = "ZotObsCite Warning";
const warningMessage = "There was an issue matching some of your Markdown notes (" + this.dataKeys.length.toString() + " notes were matched successfully).\n\nWould you like to save the data extracted from the notes to a json file?";
const saveDialogTitle = "Save ZoteroObsidianCitations Data To...";
const filenamesuggest = 'ZoteroObsidianCitations-all-data.json';
const filenamesuggest = 'ZotObsCite-alldata.json';
await this.offerToSaveErrors(dataErrors, warningTitle, warningMessage, saveDialogTitle, filenamesuggest);
}

Expand Down Expand Up @@ -1138,7 +1135,7 @@ Zotero.ObsCite = {
ndataKeys: 'unreached',
updateItems: 'unreached'
};
let notifData = ["ZoteroObsidianCitations Syncing Error", "Some Error Occurred", false];
let notifData = ["ZotObsCite Syncing Error", "Some Error Occurred", false];
if (await this.checkSettings()) {
trace.checkSetting = 'pass';
await this.processData(promptSaveErrors, debug);
Expand All @@ -1153,10 +1150,10 @@ Zotero.ObsCite = {
message = "Found " + this.dataKeys.length.toString() + " notes.";
trace.updateItems = 'skipped';
}
notifData = ["ZoteroObsidianCitations Synced", message, true];
notifData = ["ZotObsCite Synced", message, true];
} else {
message = "Found " + this.dataKeys.length.toString() + " notes.";
notifData = ["ZoteroObsidianCitations", message, false];
notifData = ["ZotObsCite", message, false];
}
} else {
const failedSetting = JSON.stringify(this.debugSettingsFail);
Expand Down Expand Up @@ -1443,15 +1440,15 @@ Zotero.ObsCite = {
saveDebug: async function () {
const dataDebug = JSON.stringify(this.debuglog, null, 1);
const saveDialogTitle = "Save ZoteroObsidianCitations Debug Log To...";
const filenamesuggest = 'ZoteroObsidianCitations-debug.json';
const filenamesuggest = 'ZotObsCite-debug.json';
await this.writeToFile(dataDebug, saveDialogTitle, filenamesuggest);
},

runAndSaveDebug: async function (includeResults) {
includeResults = (typeof includeResults === 'boolean') ? includeResults : true;
const dataDebug = JSON.stringify(await this.runDebug(includeResults), null, 1);
const saveDialogTitle = "Save ZoteroObsidianCitations Debug Log To...";
const filenamesuggest = 'ZoteroObsidianCitations-debug.json';
const filenamesuggest = 'ZotObsCite-debug.json';
await this.writeToFile(dataDebug, saveDialogTitle, filenamesuggest);
},

Expand Down
16 changes: 9 additions & 7 deletions chrome/locale/en-US/options.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<!ENTITY obscite.preferences.matchstrategy-bbtcitekey-title "Use BetterBibTeX citekeys to link markdown files to Zotero items (Option 1)">
<!ENTITY obscite.preferences.matchstrategy-bbtcitekey-label "Match notes based on BetterBibTeX citekey">
<!ENTITY obscite.preferences.matchstrategy-bbtcitekey-desc "ZoteroObsidianCitations will search the markdown files for BetterBibTeX citekeys.">
<!ENTITY obscite.preferences.matchstrategy-bbtcitekey-desc "ZoteroObsidianCitations will search for a BetterBibTeX citekey in the filename and/or metadata.">

<!ENTITY obscite.preferences.metadata-keyword-title "(Optional) Markdown Metadata Keyword">
<!ENTITY obscite.preferences.metadata-keyword-label "yaml keyword:">
Expand All @@ -31,7 +31,7 @@

<!ENTITY obscite.preferences.matchstrategy-zotitemkey-title "Use Zotero-Item-Keys to link markdown files to Zotero items (Option 2)">
<!ENTITY obscite.preferences.matchstrategy-zotitemkey-label "Match notes based on Zotero-Item-Key">
<!ENTITY obscite.preferences.matchstrategy-zotitemkey-desc "ZoteroObsidianCitations will search the markdown file contents for Zotero-Item-Keys.">
<!ENTITY obscite.preferences.matchstrategy-zotitemkey-desc "ZoteroObsidianCitations will search for a Zotero-Item-Key in the file's contents.">

<!ENTITY obscite.preferences.zotkeyregex-title1 "Required: Specify a RegEx to match the Zotero-Item-Key from the markdown contents">
<!ENTITY obscite.preferences.zotkeyregex-title2 " ( e.g. match 'ABCD1234' in 'zotero://select/library/items/ABCD1234' )">
Expand All @@ -44,17 +44,19 @@
<!ENTITY obscite.preferences.spacer " ">

<!ENTITY obscite.preferences.customtag-title "Specify a Custom Tag Name">
<!ENTITY obscite.preferences.customtag-desc "The default tag is 'ObsCite'. If would prefer the tag to be something else, specify the tag name here.">
<!ENTITY obscite.preferences.customtag-desc "The default Zotero tag is 'ObsCite'. If would prefer the tag to be something else, specify the tag name here.">
<!ENTITY obscite.preferences.customtag-label "tag:">

<!ENTITY obscite.preferences.vaultresolution-title "Obsidian URI - File Resolution Protocol">
<!ENTITY obscite.preferences.vaultresolution-desc "The Obsidian URI can resolve files using a file path or a file name. The 'path' option is advised since file names are not necessarily unique.">
<!ENTITY obscite.preferences.vaultresolution-label "Resolve Obsidian notes using the file">
<!ENTITY obscite.preferences.vaultresolution-path-label "path (default)">
<!ENTITY obscite.preferences.vaultresolution-file-label "name (only advised if 'path' is not working)">
<!ENTITY obscite.preferences.vaultresolution-label "Resolve Obsidian notes using the MD file's">
<!ENTITY obscite.preferences.vaultresolution-path-label "path (recommended)">
<!ENTITY obscite.preferences.vaultresolution-file-label "name (only advised if 'path' option is not working)">
<!ENTITY obscite.preferences.vaultname-break "- - - - - - - - - - ">
<!ENTITY obscite.preferences.vaultname-label0 "(Optional) Obsidian Vault Name">
<!ENTITY obscite.preferences.vaultname-label "If you use multiple Vaults, you can specify which Vault should open your markdown reading notes.">
<!ENTITY obscite.preferences.vaultname-label2 "Obsidian Vault Name:">

<!ENTITY obscite.preferences.rundebug-label "Save Debugging Log">
<!ENTITY obscite.preferences.rundebug-desc "If you're encounternig errors, you can generate a debugging file to examine yourself and/or to include in a github issue.">
<!ENTITY obscite.preferences.rundebug-desc "If you're encountering errors, you can generate a debugging file to examine yourself and/or to include in a GitHub issue.">
<!ENTITY obscite.preferences.rundebug-button-label "Generate Debugging File">
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>daeda@mit.edu</em:id>
<em:name>ZoteroObsidianCitations</em:name>
<em:version>0.0.15</em:version>
<em:version>0.0.16</em:version>
<em:type>2</em:type>
<em:creator>Dae Houlihan</em:creator>
<em:description>Add a tag to Zotero items that have a external note.</em:description>
Expand Down
4 changes: 2 additions & 2 deletions update.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<rdf:Seq>
<rdf:li>
<rdf:Description>
<em:version>0.0.15</em:version>
<em:version>0.0.16</em:version>
<em:targetApplication>
<rdf:Description>
<em:id>zotero@chnm.gmu.edu</em:id>
<em:minVersion>5.0.0</em:minVersion>
<em:maxVersion>6.0.*</em:maxVersion>
<em:updateLink>https://github.com/daeh/zotero-obsidian-citations/releases/download/v0.0.15/zotero-obsidian-citations-0.0.15.xpi</em:updateLink>
<em:updateLink>https://github.com/daeh/zotero-obsidian-citations/releases/download/v0.0.16/zotero-obsidian-citations-0.0.16.xpi</em:updateLink>
</rdf:Description>
</em:targetApplication>

Expand Down

0 comments on commit 829fc3e

Please sign in to comment.