Skip to content

Commit

Permalink
Add date to citation counts
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Sep 29, 2020
1 parent 9c3a843 commit 6fdefc2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

This is an add-on for Zotero, a research source management tool. The
add-on can auto-fetch citation counts for journal articles using
various APIs, including Crossref, Inspire HEP, NASA/ADS (astrophysics
data system), and Semantic Scholar. (Google Scholar is not supported
because automated access is againts its terms of service.)
various APIs, including Crossref (and in the future probably Inspire
HEP, NASA/ADS, and Semantic Scholar). (Google Scholar is not supported
because automated access is against its terms of service.)

Please report any bugs, questions, or feature requests in the Github
repository.
Expand All @@ -26,7 +26,7 @@ Code for this extension is based on the [Zotero DOI
- Run Zotero (version 5.x)
- Go to `Tools -> Add-ons`
- `Install Add-on From File`
- Choose the file `zotero-citationcounts-0.1.0.xpi`
- Choose the file `zotero-citationcounts-0.1.1.xpi`
- Restart Zotero

## License
Expand Down
10 changes: 8 additions & 2 deletions chrome/content/scripts/zoterocitationcounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getCitationCount(item, tag) {
return -1;
}
let extras = extra.split("\n");
const patt = new RegExp("^Citations \\(" + tag + "\\): \\d+", "i");
const patt = new RegExp("^Citations \\(" + tag + "\\): (\\d+).*", "i");
extras = extras.filter(ex => patt.test(ex));
if (length(extras) == 0) {
return -1;
Expand All @@ -43,8 +43,14 @@ function setCitationCount(item, tag, count) {
}
let extras = extra.split("\n");
const patt = new RegExp("^Citations \\(" + tag + "\\):", "i");
// Remove old count
extras = extras.filter(ex => !patt.test(ex));
extras.push("Citations (" + tag + "): " + count);
const today = new Date();
const dd = String(today.getDate()).padStart(2, '0');
const mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
const yyyy = today.getFullYear();
const date = yyyy + '-' + mm + '-' + dd
extras.push("Citations (" + tag + "): " + count) + " [" + date + "]";
extra = extras.join("\n");
item.setField('extra', extra);
}
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
RDF:about="urn:mozilla:install-manifest"
em:id="[email protected]"
em:name="Zotero Citation Counts Manager"
em:version="0.1.0"
em:version="0.1.1"
em:type="2"
em:creator="Erik Schnetter"
em:description="Automatically fetch and update citation counts"
Expand Down
4 changes: 2 additions & 2 deletions update.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<rdf:Seq>
<rdf:li>
<rdf:Description>
<em:version>0.1.0</em:version>
<em:version>0.1.1</em:version>
<em:targetApplication>
<rdf:Description>
<em:id>[email protected]</em:id>
<em:minVersion>5.0</em:minVersion>
<em:maxVersion>5.*</em:maxVersion>
<em:updateLink>https://github.com/eschnett/zotero-citationcounts/releases/download/v0.1.0/zotero-citationcounts-0.1.0.xpi</em:updateLink>
<em:updateLink>https://github.com/eschnett/zotero-citationcounts/releases/download/v0.1.1/zotero-citationcounts-0.1.1.xpi</em:updateLink>
</rdf:Description>
</em:targetApplication>
</rdf:Description>
Expand Down

0 comments on commit 6fdefc2

Please sign in to comment.