Skip to content

Commit 466b553

Browse files
committed
improve init, add obsidianMD menu for multiple files
1 parent e7739b7 commit 466b553

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Opens an existing Markdown note in [Obsidian](https://obsidian.md) from the cont
2828
- Run Zotero (version 5.x)
2929
- Go to `Tools -> Add-ons`
3030
- `Install Add-on From File`
31-
- Choose the file `zotero-obsidian-citations-0.0.12.xpi`
31+
- Choose the file `zotero-obsidian-citations-0.0.13.xpi`
3232
- Restart Zotero
3333

3434
## Setup
@@ -40,13 +40,14 @@ A Markdown file can specify which Zotero item it's linked to using either a [Bet
4040
- This is recommended if you created the Markdown notes with [obsidian-citation-plugin](https://github.com/hans/obsidian-citation-plugin).
4141

4242
- The Markdown file names should start with `@mycitekey` but can include extra information after it (e.g. a reading note might have the file name `@shepard1987science.md` or `@shepard1987science Toward a universal law of generalization for psychological science.md`, where `shepard1987science` is the BetterBibTeX citekey).
43+
4344
2. Link Markdown files to Zotero items using **Zotero Item Keys**.
4445

4546
- This is recommended if you created the Markdown notes with the `Export Note` feature of Zotero.
4647
- The Markdown file names should start with `@` and the file contents should include the Zotero-Item-Key in a consistent format
4748
(Zotero automatically generates Item Keys; they take the form of `ABCD1234`, as in `zotero://select/library/items/ABCD1234`).
4849

49-
NOTE: _ZoteroObsidianCitations_ assumes that a given Markdown file corresponds to a single Zotero item. (A Markdown reading note can reference multiple Zotero items throughout the file, but _ZoteroObsidianCitations_ will only link the Markdown note to one BetterBibTeX-citekey / Zotero-Item-Key.) Multiple Markdown files can point to the same Zotero item.
50+
NOTE: _ZoteroObsidianCitations_ assumes that a given Markdown file corresponds to a single Zotero item. (A Markdown reading note can reference multiple Zotero items throughout the file, but _ZoteroObsidianCitations_ will only link the Markdown note to one BetterBibTeX-citekey / Zotero-Item-Key.) Multiple Markdown files can point to the same Zotero item.
5051

5152
---
5253

bin/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
version='0.0.12'
3+
version='0.0.13'
44

55
rm -f zotero-obsidian-citations-${version}.xpi
66
zip -r zotero-obsidian-citations-${version}.xpi chrome/* defaults/* chrome.manifest install.rdf

chrome/content/scripts/zoteroobscite.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (typeof Zotero === 'undefined') {
1313
}
1414

1515
Zotero.ObsCite = {
16-
version: '0.0.12',
16+
version: '0.0.13',
1717
folderSep: null,
1818
cleanrun: true,
1919
suppressNotifications: false,
@@ -37,25 +37,32 @@ Zotero.ObsCite = {
3737

3838
init: async function () {
3939
///TODO display waiting for schema message https://github.com/retorquere/zotero-better-bibtex/blob/26a48f6a85705eeb18f31d87269d34906b1d1a94/test/fixtures/schema-logger/bootstrapped/bootstrap.js
40+
4041
await Zotero.Schema.schemaUpdatePromise;
4142

4243
// only do this stuff for the first run
4344
if (!this._initialized) {
4445

45-
setTimeout(() => {
46-
if (!['bbtcitekey', 'zotitemkey'].includes(this.getPref('matchstrategy'))) {
47-
this.setPref('matchstrategy', 'bbtcitekey');
48-
}
49-
}, 1000);
46+
if (!['bbtcitekey', 'zotitemkey'].includes(this.getPref('matchstrategy'))) {
47+
this.setPref('matchstrategy', 'bbtcitekey');
48+
}
5049

5150
// run in future to not burden start-up
52-
this.futureRun(function () {
51+
this.futureRun(async function () {
5352
// determine folder seperator depending on OS
5453
this.folderSep = Zotero.isWin ? '\\' : '/';
5554

56-
setTimeout(() => {
57-
this.startupDependencyCheck();
58-
}, 2000);
55+
// if BBT is needed, wait for it to load
56+
if (this.getPref('matchstrategy') === 'bbtcitekey') {
57+
let win = Services.wm.getMostRecentWindow("navigator:browser");
58+
win.Zotero.BetterBibTeX.ready.then(async function () {
59+
await this.startupDependencyCheck();
60+
}.bind(this));
61+
} else {
62+
setTimeout(async function () {
63+
await this.startupDependencyCheck();
64+
}.bind(this), 2000);
65+
}
5966

6067
}.bind(this));
6168
}

install.rdf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Description about="urn:mozilla:install-manifest">
66
<em:id>[email protected]</em:id>
77
<em:name>ZoteroObsidianCitations</em:name>
8-
<em:version>0.0.12</em:version>
8+
<em:version>0.0.13</em:version>
99
<em:type>2</em:type>
1010
<em:creator>Dae Houlihan</em:creator>
1111
<em:description>Add a tag to Zotero items that have a external note.</em:description>

update.rdf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<rdf:Seq>
77
<rdf:li>
88
<rdf:Description>
9-
<em:version>0.0.12</em:version>
9+
<em:version>0.0.13</em:version>
1010
<em:targetApplication>
1111
<rdf:Description>
1212
<em:id>[email protected]</em:id>
1313
<em:minVersion>5.0.0</em:minVersion>
1414
<em:maxVersion>5.*</em:maxVersion>
15-
<em:updateLink>https://github.com/daeh/zotero-obsidian-citations/releases/download/v0.0.12/zotero-obsidian-citations-0.0.12.xpi</em:updateLink>
15+
<em:updateLink>https://github.com/daeh/zotero-obsidian-citations/releases/download/v0.0.13/zotero-obsidian-citations-0.0.13.xpi</em:updateLink>
1616
</rdf:Description>
1717
</em:targetApplication>
1818

0 commit comments

Comments
 (0)