Skip to content

Commit

Permalink
Remove pandoc reference list
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Jul 12, 2023
1 parent 50e9da6 commit 919a182
Show file tree
Hide file tree
Showing 20 changed files with 7,839 additions and 1,412 deletions.
11 changes: 1 addition & 10 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,8 @@ import builtins from 'builtin-modules';
import esbuild from 'esbuild';
import process from 'process';

const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;

const prod = process.argv[2] === 'production';

const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ['./src/main.ts'],
bundle: true,
external: [
Expand Down Expand Up @@ -49,6 +39,7 @@ const context = await esbuild.context({
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js',
minify: prod,
});

if (prod) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-zotero-desktop-connector",
"name": "Zotero Integration",
"version": "3.0.3",
"version": "3.0.4",
"minAppVersion": "1.1.1",
"description": "Insert and import citations, bibliographies, notes, and PDF annotations from Zotero.",
"author": "mgmeyers",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"builtin-modules": "3.3.0",
"cross-env": "7.0.3",
"esbuild": "0.18.11",
"escape-string-regexp": "^5.0.0",
"eslint": "8.44.0",
"eslint-plugin-react": "7.32.2",
"import-sort-cli": "6.0.0",
Expand All @@ -52,7 +53,6 @@
"escape-path-with-spaces": "1.0.2",
"execa": "7.1.1",
"fuse.js": "6.6.2",
"lru-cache": "^10.0.0",
"nunjucks": "3.2.4",
"preact": "10.15.1",
"react": "npm:@preact/compat",
Expand Down
15 changes: 14 additions & 1 deletion src/bbt/cayw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CitationFormat, DatabaseWithPort } from '../types';
import { LoadingModal } from './LoadingModal';
import { defaultHeaders, getPort } from './helpers';
import { getBibFromCiteKeys } from './jsonRPC';
import { ZQueue } from './queue';

export function getCiteKeyFromAny(item: any): CiteKey | null {
if (!item.citekey && !item.citationKey) return null;
Expand All @@ -22,7 +23,7 @@ export async function isZoteroRunning(
database: DatabaseWithPort,
silent?: boolean
) {
if (cachedIsRunning && Date.now() - lastCheck < 1000 * 60) {
if (cachedIsRunning && Date.now() - lastCheck < 1000 * 30) {
return cachedIsRunning;
}

Expand All @@ -31,7 +32,9 @@ export async function isZoteroRunning(
modal = new LoadingModal(app, 'Fetching data from Zotero...');
modal.open();
}
const qid = Symbol();
try {
await ZQueue.wait(qid);
const res = await request({
method: 'GET',
url: `http://127.0.0.1:${getPort(
Expand All @@ -44,6 +47,7 @@ export async function isZoteroRunning(
modal?.close();
cachedIsRunning = res === 'ready';
lastCheck = Date.now();
ZQueue.end(qid);
return cachedIsRunning;
} catch (e) {
modal?.close();
Expand All @@ -52,6 +56,7 @@ export async function isZoteroRunning(
'Cannot connect to Zotero. Please ensure it is running and the Better BibTeX plugin is installed',
10000
);
ZQueue.end(qid);
return false;
}
}
Expand Down Expand Up @@ -85,13 +90,15 @@ export async function getCAYW(
const modal = new LoadingModal(app, 'Awaiting item selection from Zotero...');
modal.open();

const qid = Symbol();
try {
if (format.format === 'formatted-bibliography') {
modal.close();
const citeKeys = await getCiteKeys(database);
return await getBibFromCiteKeys(citeKeys, database, format.cslStyle);
}

await ZQueue.wait(qid);
const res = await request({
method: 'GET',
url: `http://127.0.0.1:${getPort(
Expand All @@ -103,12 +110,14 @@ export async function getCAYW(

win.show();
modal.close();
ZQueue.end(qid);
return res;
} catch (e) {
win.show();
console.error(e);
modal.close();
new Notice(`Error processing citation: ${e.message}`, 10000);
ZQueue.end(qid);
return null;
}
}
Expand Down Expand Up @@ -151,7 +160,9 @@ export async function getCAYWJSON(database: DatabaseWithPort) {
const modal = new LoadingModal(app, 'Awaiting item selection from Zotero...');
modal.open();

const qid = Symbol();
try {
await ZQueue.wait(qid);
const res = await request({
method: 'GET',
url: `http://127.0.0.1:${getPort(
Expand All @@ -164,6 +175,7 @@ export async function getCAYWJSON(database: DatabaseWithPort) {
win.show();

modal.close();
ZQueue.end(qid);
if (res) {
return JSON.parse(res).items || [];
} else {
Expand All @@ -174,6 +186,7 @@ export async function getCAYWJSON(database: DatabaseWithPort) {
console.error(e);
modal.close();
new Notice(`Error retrieving cite key: ${e.message}`, 10000);
ZQueue.end(qid);
return null;
}
}
Loading

0 comments on commit 919a182

Please sign in to comment.