Skip to content

Commit

Permalink
Add a function for getting the non-deprecated link.
Browse files Browse the repository at this point in the history
This is mostly just adapted from Zutilo, but it seems to be considered
the "blessed" version, so I'm keeping it for now.
  • Loading branch information
NorwegianRockCat committed Mar 11, 2023
1 parent 46138f0 commit e27db71
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
20 changes: 20 additions & 0 deletions extension/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ function loadZotero () {
return new Promise(callback);
}

function buildZoteroLink(item) {
// This is almost a direct copy from Zutilo
let libraryType = Zotero.Libraries.get(item.libraryID).libraryType;
var path = "undefined"
switch (libraryType) {
case 'group':
path = Zotero.URI.getLibraryPath(item.libraryID)
break;
case 'user':
path = 'library'
break;
default:
break;
}
return 'zotero://select/' + path + '/items/'+ item.key
}


function collectionSearch(name) {
let collections = Zotero.Collections.getByLibrary(Zotero.Libraries.userLibraryID, true);
for (let collection of collections) {
Expand Down Expand Up @@ -148,6 +166,8 @@ function buildResponse(items, format, style, locale) {
return [okCode, 'application/json', jsonStringify(items.map(item2key))];
} else if (format === 'easykey') {
return buildEasyKeyResponse(items);
} else if (format === 'zoteroLink') {
return [okCode, 'application/json', jsonStringify(items.map(buildZoteroLink))];
} else if (format === 'betterbibtexkey' || format === 'citekey') {
return buildBBTKeyResponse(items);
} else if (format === 'bibtex') {
Expand Down
2 changes: 1 addition & 1 deletion extension/install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>zotxt@e6h.org</em:id>
<em:version>6.0.2</em:version>
<em:version>6.0.2.1</em:version>
<em:type>2</em:type>
<em:bootstrap>true</em:bootstrap>
<em:unpack>true</em:unpack>
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e27db71

Please sign in to comment.