Skip to content

Commit

Permalink
full locale
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed Jan 5, 2022
1 parent 349dd8b commit 42ceebe
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
19 changes: 17 additions & 2 deletions content/debug.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
declare const Zotero: IZotero

export function debug(...msg) {
const str = `PubPeer: ${msg.map(s => s.toString()).join(' ')}`
function to_s(obj: any): string {
if (typeof obj === 'string') return obj
const s = `${obj}`
switch (s) {
case '[object Object]':
return JSON.stringify(obj)
case '[object Set]':
return JSON.stringify(Array.from(obj)) // eslint-disable-line @typescript-eslint/no-unsafe-argument
default:
return s
}
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function debug(...msg): void {
const str = `Cite Columns: ${msg.map(to_s).join(' ')}`
// console.error(str) // tslint:disable-line:no-console
Zotero.debug(str)
}
4 changes: 2 additions & 2 deletions content/itemPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ export class ItemPane {

const html = this.dom.parser.parseFromString(summary, 'text/xml')
for (const a of html.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'a')) {
if (!a.getAttribute('href')) continue
if (!a.getAttribute('url')) continue

a.setAttribute('onclick', 'Zotero.launchURL(this.getAttribute("href")); return false;')
a.setAttribute('onclick', 'Zotero.launchURL(this.getAttribute("url")); return false;')
a.setAttribute('style', 'color: blue')
}
summary = this.dom.serializer.serializeToString(html)
Expand Down
7 changes: 4 additions & 3 deletions content/pubpeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +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')

const style = Zotero.Styles.get('http://www.zotero.org/styles/apa')
const cslEngine = style.getCiteProc('en-US')

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]) {
const text = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, items, 'text')
const text = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, [item], '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: 1 addition & 1 deletion locale/en-US/zotero-pubpeer.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
itemPane.summary = <p>{{total_comments}} <b>PubPeer</b> comments.</p><p><a href="{{url}}">{{url}}</a></p><p>Most recent comment on {{last_commented_at}}</p>
itemPane.summary = <p>{{total_comments}} <b>PubPeer</b> comments.</p><p><a href="#" url="{{url}}">{{url}}</a></p><p>Most recent comment on {{last_commented_at}}</p>
itemPane.noComment = No <b>PubPeer</b> comments
12 changes: 8 additions & 4 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import argparse
import shlex
import xml.etree.ElementTree as ET
import subprocess

config = configparser.ConfigParser()
if os.path.isfile('start.ini'):
Expand Down Expand Up @@ -51,10 +52,13 @@
with open(prefs, 'w') as f:
f.write(''.join(user_prefs))

os.system('npm run build')
def system(cmd):
subprocess.run(cmd, shell=True, check=True)

#os.system(f'rm -rf {profile}extensions.json')
os.system(f"rm -rf {shlex.quote(plugin + '*')}")
system('npm run build')

#system(f'rm -rf {profile}extensions.json')
system(f"rm -rf {shlex.quote(plugin + '*')}")

with open(os.path.expanduser(plugin), 'w') as f:
path = os.path.join(os.getcwd(), 'build')
Expand All @@ -68,4 +72,4 @@
cmd += ' &'

print(cmd)
os.system(cmd)
system(cmd)

0 comments on commit 42ceebe

Please sign in to comment.