-
Notifications
You must be signed in to change notification settings - Fork 787
/
Copy pathPubPub.js
530 lines (506 loc) · 15.2 KB
/
PubPub.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
{
"translatorID": "25f28dc9-901f-4920-8b9a-5baefad91493",
"label": "PubPub",
"creator": "Abe Jellinek",
"target": "/pub/[^/]+/release/\\d+|^https?://[^/]+\\.pubpub\\.org/search\\?",
"minVersion": "3.0",
"maxVersion": "",
"priority": 270,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2021-09-14 20:35:00"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2021 Abe Jellinek
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
function detectWeb(doc, url) {
if (!doc.querySelector('.built-on > a[href*="pubpub"]')
&& !url.includes('pubpub.org')) {
return false;
}
// this won't match search result pages not hosted on pubpub.org, but the
// results URL (/search?q=) is just too generic to justify including it in
// the target.
if (getSearchResults(doc, true)) {
return "multiple";
}
else if (doc.querySelector('#search-container')) {
Z.monitorDOMChanges(doc.querySelector('#search-container'));
}
else if (doc.querySelector('meta[name="citation_title"]')) {
if (doc.querySelector('meta[name="citation_inbook_title"]')) {
return "bookSection";
}
// this is, of course, a bad heuristic, but it's unlikely to lead to
// false positives and PubPub doesn't give us anything better.
else if (attr(doc, 'meta[property="og:site_name"]', 'content').endsWith('Rxiv')) {
return "report";
}
else {
return "journalArticle";
}
}
return false;
}
function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.querySelectorAll('.title > a.pub-title');
for (let row of rows) {
let href = row.href;
let title = ZU.trimInternal(row.textContent);
if (!href || !title) continue;
if (checkOnly) return true;
found = true;
items[href] = title;
}
return found ? items : false;
}
function doWeb(doc, url) {
if (detectWeb(doc, url) == "multiple") {
Zotero.selectItems(getSearchResults(doc, false), function (items) {
if (items) ZU.processDocuments(Object.keys(items), scrape);
});
}
else {
scrape(doc, url);
}
}
function scrape(doc, url) {
var translator = Zotero.loadTranslator('web');
// Embedded Metadata
translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48');
translator.setDocument(doc);
translator.setHandler('itemDone', function (obj, item) {
if (!item.publicationTitle) {
item.publicationTitle = attr(doc, 'meta[property="og:site_name"]', 'content');
}
if (item.publicationTitle.endsWith('Rxiv')) {
item.itemType = 'report';
item.extra = (item.extra || '') + '\nType: article';
}
if (item.itemType == 'bookSection' && item.bookTitle) {
delete item.publicationTitle;
}
if (item.publisher == 'PubPub') {
delete item.publisher;
}
delete item.institution;
delete item.company;
delete item.label;
delete item.distributor;
if (item.date) {
item.date = ZU.strToISO(item.date);
}
if (item.ISSN == ',') {
delete item.ISSN;
}
if (item.attachments.length > 1) {
item.attachments = item.attachments.filter(at => at.title != 'Snapshot');
}
item.complete();
});
translator.getTranslatorObject(function (trans) {
trans.itemType = detectWeb(doc, url);
trans.doWeb(doc, url);
});
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "https://cursor.pubpub.org/pub/teuchert-isenheimeraltar/release/5",
"items": [
{
"itemType": "journalArticle",
"title": "Christus als Infektionstoter: Der Isenheimer Altar und die Corona-Pandemie",
"creators": [
{
"firstName": "Lisanne",
"lastName": "Teuchert",
"creatorType": "author"
}
],
"date": "2020-04-03",
"abstractNote": "Von der Corona-Krise aus fällt ein neuer Blick auf den Isenheimer Altar: Der Gekreuzigte trägt Spuren einer Infektionskrankheit, der Pest. Der Artikel erklärt den Hintergrund und stellt Gedanken zur theologischen Rezeption heute an.",
"language": "en",
"libraryCatalog": "cursor.pubpub.org",
"publicationTitle": "Cursor_ Zeitschrift für explorative Theologie",
"shortTitle": "Christus als Infektionstoter",
"url": "https://cursor.pubpub.org/pub/teuchert-isenheimeraltar/release/5",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://hdsr.mitpress.mit.edu/pub/w075glo6/release/2?readingCollection=c6a3a10e",
"items": [
{
"itemType": "journalArticle",
"title": "Designing for Interactive Exploratory Data Analysis Requires Theories of Graphical Inference",
"creators": [
{
"firstName": "Jessica",
"lastName": "Hullman",
"creatorType": "author"
},
{
"firstName": "Andrew",
"lastName": "Gelman",
"creatorType": "author"
}
],
"date": "2021-07-30",
"DOI": "10.1162/99608f92.3ab8a587",
"abstractNote": "Research and development in computer science and statistics have produced increasingly sophisticated software interfaces for interactive and exploratory analysis, optimized for easy pattern finding and data exposure. But design philosophies that emphasize exploration over other phases of analysis risk confusing a need for flexibility with a conclusion that exploratory visual analysis is inherently “model free” and cannot be formalized. We describe how without a grounding in theories of human statistical inference, research in exploratory visual analysis can lead to contradictory interface objectives and representations of uncertainty that can discourage users from drawing valid inferences. We discuss how the concept of a model check in a Bayesian statistical framework unites exploratory and confirmatory analysis, and how this understanding relates to other proposed theories of graphical inference. Viewing interactive analysis as driven by model checks suggests new directions for software and empirical research around exploratory and visual analysis. For example, systems might enable specifying and explicitly comparing data to null and other reference distributions and better representations of uncertainty. Implications of Bayesian and other theories of graphical inference can be tested against outcomes of interactive analysis by people to drive theory development.",
"language": "en",
"libraryCatalog": "hdsr.mitpress.mit.edu",
"publicationTitle": "Harvard Data Science Review",
"url": "https://hdsr.mitpress.mit.edu/pub/w075glo6/release/2",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.crimrxiv.com/pub/xbjbnyb8/release/1?readingCollection=e3ec78b4",
"items": [
{
"itemType": "report",
"title": "The Impact of COVID-19 on the Spatial Distribution of Shooting Violence in Buffalo, NY",
"creators": [
{
"firstName": "Gregory",
"lastName": "Drake",
"creatorType": "author"
},
{
"firstName": "Andrew",
"lastName": "Wheeler",
"creatorType": "author"
},
{
"firstName": "Dae-Young",
"lastName": "Kim",
"creatorType": "author"
},
{
"firstName": "Scott W.",
"lastName": "Phillips",
"creatorType": "author"
},
{
"firstName": "Kathryn",
"lastName": "Mendolera",
"creatorType": "author"
}
],
"date": "2021-09-01",
"abstractNote": "Objectives: This paper examines the extent to which hotspots of shooting violence changed following the emergence of Covid-19. Methods: This analysis uses Andresen's Spatial Point Pattern test, correcting for multiple comparisons, on a 10-year sample of geocoded shooting data from Buffalo New York. Results: This work finds zero micro grid cells are statistically different from pre to post Covid stay at home orders and instead that the observed rise in shootings in the sample appears to be a consistent proportional increase across the city. Conclusions: These findings provide law enforcement with useful information about how to respond to the recent rise in shooting violence but additional work is needed to better understand what, among a number of competing theories, is driving the increase.",
"extra": "DOI: 10.21428/cb6ab371.e187aede\nType: article",
"language": "en",
"libraryCatalog": "www.crimrxiv.com",
"url": "https://www.crimrxiv.com/pub/xbjbnyb8/release/1",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.crimrxiv.com/pub/auhg43cx/release/1",
"items": [
{
"itemType": "report",
"title": "Fault lines of food fraud: key issues in research and policy",
"creators": [
{
"firstName": "Nicholas",
"lastName": "Lord",
"creatorType": "author"
},
{
"firstName": "Cecilia Flores",
"lastName": "Elizondo",
"creatorType": "author"
},
{
"firstName": "Jon",
"lastName": "Davies",
"creatorType": "author"
},
{
"firstName": "Jon",
"lastName": "Spencer",
"creatorType": "author"
}
],
"date": "2021-09-14",
"extra": "Type: article",
"language": "en",
"libraryCatalog": "www.crimrxiv.com",
"shortTitle": "Fault lines of food fraud",
"url": "https://www.crimrxiv.com/pub/auhg43cx/release/1",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://wip.mitpress.mit.edu/pub/pnxgvubq/release/2",
"items": [
{
"itemType": "bookSection",
"title": "2. Data Cooperatives",
"creators": [
{
"firstName": "Alex",
"lastName": "Pentland",
"creatorType": "author"
},
{
"firstName": "Thomas",
"lastName": "Hardjono",
"creatorType": "author"
}
],
"date": "2020-04-30",
"bookTitle": "Building the New Economy",
"language": "en",
"libraryCatalog": "wip.mitpress.mit.edu",
"url": "https://wip.mitpress.mit.edu/pub/pnxgvubq/release/2",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.sustainabilityscience.org/pub/eto8m67b/release/2",
"items": [
{
"itemType": "bookSection",
"title": "Capacity to Promote Equity",
"creators": [
{
"firstName": "Alicia G.",
"lastName": "Harley",
"creatorType": "author"
},
{
"firstName": "William C.",
"lastName": "Clark",
"creatorType": "author"
}
],
"date": "2020-09-10",
"abstractNote": "Achieving fair or equitable distribution of the fruits of the earth’s resources both within and between generations is a central objective of sustainable development. Accelerating progress requires above all more effective means for empowering those who are now losing out.",
"bookTitle": "Sustainability Science: A guide for researchers",
"extra": "DOI: 10.21428/f8d85a02.e1e84ad7",
"language": "en",
"libraryCatalog": "www.sustainabilityscience.org",
"url": "https://www.sustainabilityscience.org/pub/eto8m67b/release/2",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://pandemics-and-games-essay-jam.pubpub.org/pub/xj5pgzcn/release/2",
"items": [
{
"itemType": "journalArticle",
"title": "The Void: Turgor and Porousness",
"creators": [
{
"firstName": "Andrew",
"lastName": "McCarrell",
"creatorType": "author"
}
],
"date": "2021-01-10",
"language": "en",
"libraryCatalog": "pandemics-and-games-essay-jam.pubpub.org",
"publicationTitle": "Pandemics and Games Essay Jam",
"shortTitle": "The Void",
"url": "https://pandemics-and-games-essay-jam.pubpub.org/pub/xj5pgzcn/release/2",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://covid-19.mitpress.mit.edu/pub/m72dtwsg/release/1",
"items": [
{
"itemType": "bookSection",
"title": "1. Theory and Exegesis: On Health and the Body Politic",
"creators": [
{
"lastName": "Andrew T. Price-Smith",
"creatorType": "author"
}
],
"date": "2020-04-16",
"ISBN": "9780262162487",
"bookTitle": "Contagion and Chaos",
"language": "en",
"libraryCatalog": "covid-19.mitpress.mit.edu",
"shortTitle": "1. Theory and Exegesis",
"url": "https://covid-19.mitpress.mit.edu/pub/m72dtwsg/release/1",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://beexml.pubpub.org/pub/sz2ok365/release/1",
"items": [
{
"itemType": "journalArticle",
"title": "The Bee Corp’s Method of Hive Strength Assessment for Pollination Effectiveness",
"creators": [
{
"firstName": "Ellie",
"lastName": "Symes",
"creatorType": "author"
},
{
"firstName": "Joseph",
"lastName": "Cazier",
"creatorType": "author"
}
],
"date": "2021-04-26",
"language": "en",
"libraryCatalog": "beexml.pubpub.org",
"publicationTitle": "Bee XML Journal",
"url": "https://beexml.pubpub.org/pub/sz2ok365/release/1",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://association.aap.cornell.edu/pub/oefofyds/release/2",
"items": [
{
"itemType": "journalArticle",
"title": "Reverse Turing Test",
"creators": [
{
"firstName": "Sabrina",
"lastName": "Haertig",
"creatorType": "author"
}
],
"date": "2020-05-28",
"language": "en",
"libraryCatalog": "association.aap.cornell.edu",
"publicationTitle": "ASSOCIATION",
"url": "https://association.aap.cornell.edu/pub/oefofyds/release/2",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://cursor.pubpub.org/search?q=sprache",
"defer": true,
"items": "multiple"
}
]
/** END TEST CASES **/