Skip to content

Commit

Permalink
Add citekey as a template string key. Closes #3.
Browse files Browse the repository at this point in the history
  • Loading branch information
wbthomason committed Aug 11, 2020
1 parent dcdcc09 commit 39dda30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions content/zotodo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,9 @@ const Zotodo = // tslint:disable-line:variable-name
private async makeTaskForItem(item: ZoteroItem) {
// Get the current preference values
const due_string: string = getPref('due_string')
const label_names_string: string = (getPref('labels') as string)
const label_names_string: string = getPref('labels') as string
let label_names: string[] = []
if(label_names_string !== ''){
if (label_names_string !== '') {
label_names = label_names_string.split(',')
}

Expand Down Expand Up @@ -616,6 +616,16 @@ const Zotodo = // tslint:disable-line:variable-name
}

const select_uri = `zotero://select/${library_path}/items/${item_id}`
let citekey = ''
if (
typeof Zotero.BetterBibTeX === 'object' &&
Zotero.BetterBibTeX !== null
) {
citekey = Zotero.BetterBibTeX.KeyManager.get(
item.getField('id', false, true)
).citekey
}

const tokens = {
title,
abstract,
Expand All @@ -627,6 +637,7 @@ const Zotodo = // tslint:disable-line:variable-name
authors,
item_id,
select_uri,
citekey,
}

for (const token_name of Object.keys(tokens)) {
Expand Down
2 changes: 1 addition & 1 deletion locale/en-US/zotodo.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!ENTITY priority "Priority for new tasks">
<!ENTITY zotero-settings "Zotero-related settings">
<!ENTITY task-format "Javascript template string for new tasks">
<!ENTITY list-of-wildcards "Acceptable tokens: ${authors}, ${title}, ${abstract}, ${url}, ${doi}, ${pdf_path} ${pdf_id}, ${item_id}, ${select_uri}, ${et_al}. Use ?${token}:text? to only include 'text' if ${token} is defined for an item. Use !${token}:text! to only include 'text' if ${token} is not defined for an item.">
<!ENTITY list-of-wildcards "Acceptable tokens: ${authors}, ${title}, ${abstract}, ${url}, ${doi}, ${pdf_path} ${pdf_id}, ${item_id}, ${select_uri}, ${citekey}, ${et_al}. Use ?${token}:text? to only include 'text' if ${token} is defined for an item. Use !${token}:text! to only include 'text' if ${token} is not defined for an item.">
<!ENTITY include-note "Should Zotodo add a comment to new tasks?">
<!ENTITY note-format "Javascript template string for comments">
<!ENTITY automatic-add "Should Zotodo add tasks for every newly added item?">
Expand Down

0 comments on commit 39dda30

Please sign in to comment.