Skip to content

Commit

Permalink
added new placeholder
Browse files Browse the repository at this point in the history
stefanopagliari committed Jan 31, 2023
1 parent 21aa6fc commit 5174073
Showing 8 changed files with 51 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,8 @@ All notable changes to this project will be documented in this file.

### Improvement

- Added field "{{filePath}}" in the template that links to the specific attachment within zotero. This is different from {{file}} that opens the attachment in an external reader
- Added field "{{zoteroReaderLink}}" in the template that links to the specific attachment within zotero the Zotero reader. This is different from {{file}} that opens the attachment in an external reader
- Added field "{{filePath}}" in the template that links to the specific attachment within zotero (without opening the reader).
- Added the setting to retain the original colour of the highlight. This is achieved by using a html tag instead of the markdown simbol (`==`).
- Added placeholder {{citationInLine}} in the template which generates a citation in the format "AUTHOR (YEAR)". This can be added as an alias in the metadata of the note generated by bibnotes to add an in-text citation to that note
- Added placeholder {{citationInLineInitials}} in the template which generates a citation in the format "SURNAME, FIRST NAME INITIALS (YEAR)", such as "Collier, D., Laporte, J. and Seawright, J. (2009)"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -75,7 +75,8 @@ By default the plugin will export both the metadata and the notes stored in Zote
- {{uri}}: link to the entry on the Zotero website
- {{eprint}}
- {{file}}: local path of the file attached to the entry
- {{filePath}}: links to the attachments associated with the entry within Zotero.
- {{filePath}}: links to the attachments associated with this entry within zotero (without opening the reader).
- "{{zoteroReaderLink}}": links to open the specific attachment within the Zotero reader. This is different from {{file}} that opens the attachment in an external reader
- {{localLibrary}}: link to the entry on the Zotero app
- {{select}}: link to the attachment on the Zotero app
- {{keywordsZotero}}: tags found in the metadata of the entry
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "bibnotes",
"name": "BibNotes Formatter",
"version": "0.9.217",
"version": "0.9.219",
"minAppVersion": "0.12.0",
"description": "Plugin to import and format annotations from Zotero.",
"author": "Stefano Pagliari",
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bibnotes",
"version": "0.9.217",
"version": "0.9.219",
"description": "Plugin to export and format annotations from Zotero into Obsidian",
"main": "main.js",
"scripts": {
7 changes: 6 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
import * as fs from "fs";
import { Debugout } from "debugout.js";
import ColorClassifier, { Palette, AlgorithmTypes } from "color-classifier"
//import Database from "better-sqlite3";
//import Database from "better-sqlite3";
//import DB from "better-sqlite3";

//import { info, setLevel } from "loglevel";
@@ -36,6 +36,7 @@ import {
createAuthorKey,
createLocalFileLink,
createLocalFilePathLink,
createZoteroReaderPathLink,
createCreatorList,
createNoteTitle,
makeWiki,
@@ -407,6 +408,10 @@ export default class MyPlugin extends Plugin {
selectedEntry.file = createLocalFileLink(selectedEntry);
//create field path field
selectedEntry.filePath = createLocalFilePathLink(selectedEntry);
//create Zotero reader path field
console.log(selectedEntry.filePath)
selectedEntry.zoteroReaderLink = createZoteroReaderPathLink(selectedEntry);
console.log(selectedEntry.zoteroReaderLink)



5 changes: 2 additions & 3 deletions src/modal.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ import MyPlugin from "./main";
import * as fs from "fs";
import { App, Modal, FuzzySuggestModal, Notice, Platform } from "obsidian";


import { Reference, AnnotationElements } from "./types";

import {
@@ -42,9 +41,9 @@ export class fuzzySelectEntryFromJson extends FuzzySuggestModal<Reference> {
this.focusInput();
}

// Import 'better-sqlite3' (not working)
//const db = new Database('/Users/sbbj963/Zotero/zotero.sqlite');

//Check sqlite 3
this.plugin.checkSQLite();

//Load the Json file

1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -119,6 +119,7 @@ export interface Reference {
}[];
file: string;
filePath: string;
zoteroReaderLink: string;
localLibrary: string;
localLibraryLink: string;
select: string;
36 changes: 36 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -636,6 +636,42 @@ export function createLocalFilePathLink(reference: Reference) {
return filesPathListString;
}


export function createZoteroReaderPathLink(reference: Reference) {
//if there is no attachment, return placeholder
if (reference.attachments.length == 0) return "{{localFilePathLink}}";
const filesPathList: string[] = [];

for (
let attachmentindex = 0;
attachmentindex < reference.attachments.length;
attachmentindex++
) {
if (reference.attachments[attachmentindex].itemType !== "attachment")
continue;

//remove white spaces from file name
if (reference.attachments[attachmentindex].select == undefined) {
reference.attachments[attachmentindex].select = "";
}

const selectedFilePath: string =
"[" +
reference.attachments[attachmentindex].title +
"](" +
encodeURI(reference.attachments[attachmentindex].select).replace(
"select",
"open-pdf"
) + ")"; //select the author


filesPathList.push(selectedFilePath);
}
//turn the array into a string
const filesPathListString = filesPathList.join("; ");
return filesPathListString;
}

export function createNoteTitle(
selectedEntry: Reference,
exportTitle: string,

0 comments on commit 5174073

Please sign in to comment.