Skip to content

Commit

Permalink
add APA-formatted entry
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed Jan 4, 2022
1 parent eb27d45 commit 349dd8b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion content/pubpeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,17 @@ $patch$(Zotero.Integration.Session.prototype, 'addCitation', original => async f
await original.apply(this, arguments)
try {
const ids = citation.citationItems.map(item => item.id)
const style = Zotero.Styles.get('apa')
const cslEngine = style.getCiteProc('en')

if (ids.length) {
Zotero.Items.getAsync(ids).then(items => {
let feedback: Feedback
for (const item of items) {
if (feedback = Zotero.PubPeer.feedback[getDOI(item)]) {
if (!feedback.shown[this.sessionID]) {
flash('ALERT: PubPeer feedback', `This article "${item.getField('title')}" has comments on PubPeer: ${feedback.url}`)
const text = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, 'text')
flash('ALERT: PubPeer feedback', `This article "${item.getField('title')}" has comments on PubPeer: ${feedback.url}\n\n${text}`)
feedback.shown[this.sessionID] = true
}
}
Expand Down
2 changes: 2 additions & 0 deletions typings/zotero.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ declare global {
interface IZotero {
PubPeer: PubPeer

Styles: any
Cite: any
ProgressWindow: any
Integration: any
debug: any
Expand Down

0 comments on commit 349dd8b

Please sign in to comment.