-
Notifications
You must be signed in to change notification settings - Fork 785
/
Copy pathLibrary Catalog (TIND ILS).js
586 lines (554 loc) · 15.5 KB
/
Library Catalog (TIND ILS).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
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
{
"translatorID": "3f50f41c-0a07-49f7-af14-7fcf2ed5887a",
"label": "Library Catalog (TIND ILS)",
"creator": "Abe Jellinek",
"target": "/search.+p=|record/[0-9]+",
"minVersion": "3.0",
"maxVersion": "",
"priority": 260,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2025-03-28 15:14:15"
}
/*
***** 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 *****
*/
/**
* @type {Map<string, keyof Z.ItemTypes>}
*/
const SCHEMA_ORG_TO_ZOTERO = new Map([
["Thing", "document"],
["CreativeWork", "document"],
["Article", "journalArticle"],
["ScholarlyArticle", "journalArticle"],
["Report", "report"],
["Thesis", "thesis"],
["Manuscript", "manuscript"],
["Dataset", "dataset"],
]);
/**
* @param {Document} doc The page document
*/
function detectWeb(doc, url) {
if (!doc.querySelector('#tindfooter')) {
return false;
}
if (url.includes('/record/')) {
const schemaOrg = getSchemaOrg(doc);
if (schemaOrg) {
const zoteroType = getZoteroTypeFromSchemaOrg(schemaOrg);
if (zoteroType) {
return zoteroType;
}
}
return "book";
}
else if (getSearchResults(doc, true)) {
return "multiple";
}
else if (url.includes('/search')) {
Z.monitorDOMChanges(doc.querySelector('.pagebody'));
}
return false;
}
function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.querySelectorAll('.result-title a');
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;
}
async function doWeb(doc, url) {
if (detectWeb(doc, url) == 'multiple') {
let items = await Zotero.selectItems(getSearchResults(doc, false));
if (!items) return;
for (let url of Object.keys(items)) {
await scrape(await requestDocument(url));
}
}
else {
await scrape(doc);
}
}
/**
*
* @param {Document} doc The page document
*/
async function scrape(doc) {
let translator = Zotero.loadTranslator("import");
// MARCXML
translator.setTranslator("edd87d07-9194-42f8-b2ad-997c4c7deefd");
const schemaOrg = getSchemaOrg(doc);
let marcXMLURL = attr(doc, 'a[href$="/export/xm"], a[download$=".xml"]', 'href');
if (!marcXMLURL) marcXMLURL = attr(doc, 'form[action$="/export/xm"]', 'action');
if (!marcXMLURL) {
throw new Error('Unable to find MARCXML URL');
}
let xml = new DOMParser().parseFromString(await requestText(marcXMLURL), "text/xml");
let marcxml = await translator.getTranslatorObject();
for (let record of await marcxml.parseDocument(xml)) {
let item = new Zotero.Item();
// Set the right item type if schemaorg exists
if (schemaOrg) {
enrichItemWithSchemaOrgItemType(item, schemaOrg);
}
record.translate(item);
//// Enhance the item with TIND-specific information
// Catalog name
item.libraryCatalog = text(doc, '#headerlogo')
|| attr(doc, 'meta[property="og:site_name"]', 'content');
// Url
let erURL = attr(doc, '.er-link', 'href');
if (erURL) {
item.url = erURL;
}
// Tind-specific date field 269. Assume there's only one.
let tindDate = record.getFieldSubfields("269")[0];
if (tindDate && tindDate.a && !item.date) {
// Assign the date if it doesn't already exist.
item.date = tindDate.a;
}
item.complete();
}
}
/**
* @param {Object} schemaOrg
* @returns {keyof Z.ItemTypes | null}
*/
function getZoteroTypeFromSchemaOrg(schemaOrg) {
const schemaOrgType = schemaOrg["@type"];
if (SCHEMA_ORG_TO_ZOTERO.has(schemaOrgType)) {
return SCHEMA_ORG_TO_ZOTERO.get(schemaOrgType);
}
return null;
}
/**
* Enriches the Zotero item with item type found in the Schema.org data.
*
* @param {Z.Item} item The Zotero item
* @param {Object} schemaOrg The parsed Schema.org data
*/
function enrichItemWithSchemaOrgItemType(item, schemaOrg) {
const zoteroType = getZoteroTypeFromSchemaOrg(schemaOrg);
if (zoteroType) {
item.itemType = zoteroType;
}
}
/**
* Obtains the parsed Schema.org data from the page.
*
* @param {Document} doc The page document
* @returns {?Object} The schema.org JSON-LD object
*/
function getSchemaOrg(doc) {
let schemaOrg;
try {
schemaOrg = JSON.parse(text(doc, '#detailed-schema-org'));
}
catch (e) {
return null;
}
if (schemaOrg["@context"] !== "https://schema.org") {
return null;
}
return schemaOrg;
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "https://lawcat.berkeley.edu/record/1234692",
"items": [
{
"itemType": "book",
"title": "International maritime dictionary: an encyclopedic dictionary of useful maritime terms and phrases: together with equivalents in French and German",
"creators": [
{
"firstName": "René de",
"lastName": "Kerchove",
"creatorType": "author"
}
],
"date": "1961",
"callNumber": "K4150 .K47 1961",
"edition": "2nd ed",
"extra": "OCLC: 8350214",
"language": "eng fre ger",
"libraryCatalog": "Berkeley Law",
"numPages": "1018",
"place": "Princeton, N.J",
"publisher": "D. Van Nostrand Co",
"shortTitle": "International maritime dictionary",
"attachments": [],
"tags": [
{
"tag": "Dictionaries"
},
{
"tag": "Dictionaries"
},
{
"tag": "Dictionaries"
},
{
"tag": "Dictionaries, Polyglot"
},
{
"tag": "Naval art and science"
},
{
"tag": "Naval art and science"
},
{
"tag": "Polyglot"
}
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://library.usi.edu/record/312809",
"items": [
{
"itemType": "book",
"title": "Harry Potter and the deathly hallows",
"creators": [
{
"firstName": "J. K.",
"lastName": "Rowling",
"creatorType": "author"
},
{
"firstName": "Mary",
"lastName": "GrandPré",
"creatorType": "author"
}
],
"date": "2007",
"ISBN": "9780545010221",
"abstractNote": "Burdened with the dark, dangerous, and seemingly impossible task of locating and destroying Voldemort's remaining Horcruxes, Harry, feeling alone and uncertain about his future, struggles to find the inner strength he needs to follow the path set out before him",
"callNumber": "PZ7.R79835 Hak 2007",
"edition": "1st ed",
"extra": "OCLC: ocm85443494",
"libraryCatalog": "University of Southern Indiana",
"numPages": "759",
"place": "New York",
"publisher": "Arthur A. Levine Books",
"attachments": [],
"tags": [
{
"tag": "Bildungsromans"
},
{
"tag": "England"
},
{
"tag": "Hogwarts School of Witchcraft and Wizardry (Imaginary organization)"
},
{
"tag": "Juvenile fiction"
},
{
"tag": "Juvenile fiction"
},
{
"tag": "Juvenile fiction"
},
{
"tag": "Juvenile fiction"
},
{
"tag": "Juvenile fiction"
},
{
"tag": "Juvenile fiction"
},
{
"tag": "Magic"
},
{
"tag": "Potter, Harry (Fictitious character)"
},
{
"tag": "Schools"
},
{
"tag": "Wizards"
}
],
"notes": [
{
"note": "Sequel to: Harry Potter and the Half-Blood Prince"
}
],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://lawcat.berkeley.edu/record/1301185",
"items": [
{
"itemType": "book",
"title": "Constitution of the United States of Brazil, 1946 (as amended)",
"creators": [
{
"lastName": "Brazil",
"creatorType": "editor",
"fieldMode": 1
},
{
"lastName": "Pan American Union",
"creatorType": "editor",
"fieldMode": 1
}
],
"date": "1963",
"callNumber": "KHD2914 1946 .A6 1963",
"libraryCatalog": "Berkeley Law",
"numPages": "1",
"place": "Washington, D.C",
"publisher": "Pan American Union",
"url": "https://libproxy.berkeley.edu/login?qurl=https%3A%2F%2Fwww.llmc.com%2FsearchResultVolumes2.aspx%3Fext%3Dtrue%26catalogSet%3D62858",
"attachments": [],
"tags": [
{
"tag": "Brazil"
},
{
"tag": "Brazil"
},
{
"tag": "Constitutional law"
},
{
"tag": "Constitutions"
}
],
"notes": [
{
"note": "\"Published under the direction of the General Legal Division, Department of Legal Affairs, Pan American Union.\" Title page verso"
}
],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://library.usi.edu/record/1416599?v=pdf",
"items": [
{
"itemType": "thesis",
"title": "Let's talk: a common-sense approach to public speaking",
"creators": [
{
"firstName": "Sherry",
"lastName": "Crawford",
"creatorType": "author"
},
{
"firstName": "Thomas A.",
"lastName": "Wilhelmus",
"creatorType": "contributor"
},
{
"firstName": "Helen R.",
"lastName": "Sands",
"creatorType": "contributor"
},
{
"firstName": "Laurence E.",
"lastName": "Musgrove",
"creatorType": "contributor"
}
],
"date": "1996",
"abstractNote": "No abstract",
"language": "eng",
"libraryCatalog": "University of Southern Indiana",
"shortTitle": "Let's talk",
"attachments": [],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://library.usi.edu/search?p=test AND 336%3AThesis&fct__3=2017",
"items": "multiple"
},
{
"type": "web",
"url": "https://pegasus.law.columbia.edu/record/511151",
"items": [
{
"itemType": "book",
"title": "Sex and race differences on standardized tests: oversight hearings before the Subcommittee on Civil and Constitutional Rights of the Committee on the Judiciary, House of Representatives, One Hundredth Congress, first session ... April 23, 1987",
"creators": [
{
"lastName": "United States",
"creatorType": "editor",
"fieldMode": 1
}
],
"date": "1989",
"callNumber": "KF27 .J847 1987e",
"extra": "OCLC: 19420020",
"libraryCatalog": "CLS Pegasus Library Catalog",
"numPages": "305",
"place": "Washington",
"publisher": "U.S. G.P.O",
"shortTitle": "Sex and race differences on standardized tests",
"attachments": [],
"tags": [
{
"tag": "Educational tests and measurements"
},
{
"tag": "SAT (Educational test)"
},
{
"tag": "Sexism in educational tests"
},
{
"tag": "Test bias"
},
{
"tag": "United States"
},
{
"tag": "United States"
},
{
"tag": "United States"
}
],
"notes": [
{
"note": "Distributed to some depository libraries in microfiche Shipping list number: 89-175-P \"Serial number 93.\" Item 1020-A, 1020-B (microfiche)"
}
],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://socialmediaarchive.org/record/70?v=pdf",
"items": [
{
"itemType": "dataset",
"title": "Diffusion Time Metrics for Facebook Posts with 100 or More Reshares",
"creators": [
{
"firstName": "Inc",
"lastName": "Meta Platforms",
"creatorType": "contributor"
}
],
"date": "2024-12-10",
"abstractNote": "This dataset contains aggregated information about all content reshared 100 or more times from July 1, 2020 through February 1, 2021. Each row of the dataset corresponds to an individual tree and its size and depth at specific hours and days from initial posting",
"libraryCatalog": "Social Media Archive at ICPSR - SOMAR",
"attachments": [],
"tags": [
{
"tag": "United States"
},
{
"tag": "elections"
},
{
"tag": "political attitudes"
},
{
"tag": "political behavior"
},
{
"tag": "social media"
},
{
"tag": "web platform data"
}
],
"notes": [
{
"note": "The U.S. 2020 Facebook and Instagram Election Study (US 2020 FIES) is a partnership between Meta and academic researchers to understand the impact of Facebook and Instagram on key political attitudes and behaviors during the US 2020 election"
}
],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://socialmediaarchive.org/record/60",
"items": [
{
"itemType": "dataset",
"title": "Not With a Bang But a Tweet: Democracy, Culture Wars, and the Memeification of T.S. Eliot",
"creators": [
{
"firstName": "Melanie",
"lastName": "Walsh",
"creatorType": "contributor"
},
{
"firstName": "Anna",
"lastName": "Preus",
"creatorType": "contributor"
}
],
"date": "2024-10-04",
"abstractNote": "This dataset includes posts from Twitter (now X) from 2006 to early 2022 that mentioned a variation of T.S. Eliot's famous lines \"This is the way the world ends / Not with a bang but a whimper\" (see \"Design\" for specific search terms used).\n<br><br>\nModernist poet T.S. Eliot concluded his 1925 poem \"The Hollow Men\" with the iconic lines: \"This is the way the world ends / Not with a bang but a whimper.\" When Eliot died in 1965, the New York Times claimed in his obituary that these lines were “probably the most quoted lines of any 20th-century poet writing in English.” They may be among the most memed lines, as well. Through a computational analysis of Twitter data, we have found that at least 350,000 tweets have referenced or remixed Eliot’s lines since the beginning of Twitter’s history in 2006. While references to the poem vary widely, we focus on two prominent political usages of the phrase — cases where Twitter users invoke it to warn about the state of modern democracy, often from the left side of the political spectrum, and cases where they use the phrase to critique political correctness and “cancel culture” or to mock people for non-normatized aspects of their identities, often from the right side of the political spectrum. Though some of the tweets cite Eliot directly, most do not, and in many cases the phrase almost seems to be moving from an authored quotation into a common idiom or turn-of-phrase. Linguistics experts increasingly refer to this kind of construction as a “snowclone” —a fixed phrasal template, often with a culturally salient source (e.g., a quotation from a book, TV show, or movie), that has “one or more variable slots” into which users insert various “lexical substitutions\" (Hartmann and Ungerer). This data thus enables researchers to study both the circulation of literature and the evolution of linguistic forms",
"libraryCatalog": "Social Media Archive at ICPSR - SOMAR",
"shortTitle": "Not With a Bang But a Tweet",
"attachments": [],
"tags": [
{
"tag": "literature"
},
{
"tag": "presidential election"
},
{
"tag": "social media"
},
{
"tag": "web platform data"
}
],
"notes": [],
"seeAlso": []
}
]
}
]
/** END TEST CASES **/