-
Notifications
You must be signed in to change notification settings - Fork 787
/
Copy pathUniversity of Chicago Press Books.js
378 lines (353 loc) · 14.5 KB
/
University of Chicago Press Books.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
{
"translatorID": "2f22b2a9-91c4-4555-8480-792b6551a381",
"label": "University of Chicago Press Books",
"creator": "Sebastian Karcher",
"target": "^https?://(www\\.)?press\\.uchicago\\.edu/(ucp/books/|press/search.html)",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2021-12-07 08:14:56"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2021 Sebastian Karcher
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 (url.includes('/book/')) {
return "book";
}
else if (getSearchResults(doc, true)) {
return "multiple";
}
return false;
}
function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.querySelectorAll('.resultsurl > a[href*="/book/"]');
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) {
var authors = doc.querySelectorAll('.purchase-item-detail-title-desktop .author>a');
var authorString = text(doc, '.author-info');
var type = "author";
if (authorString.includes("Edited by")) {
type = "editor";
}
for (let author of authors) {
item.creators.push(ZU.cleanAuthor(author.textContent, type));
}
// Some authors aren't hyperlinked
if (authorString.includes(",")) {
// grab the text-only content of the author string
var moreAuthors = ZU.xpathText(doc, '//div[@class="purchase-item-detail-title-desktop"]//p[contains(@class, "author")]/text()');
// clean it.
moreAuthors = moreAuthors.replace(/^[^,]*[,\s]*/, "").replace(/^and/, "");
moreAuthors = moreAuthors.split(/,\s(?:and )?|\sand\s/);
for (let author of moreAuthors) {
item.creators.push(ZU.cleanAuthor(author, type));
}
}
var editors = text(doc, '.editor');
if (editors) {
var editorType = "editor";
if (editors.includes("Translated by")) {
editorType = "translator";
}
editors = editors.replace(/.+?\sby\s/, "");
editors = editors.split(/,\s(?:and )?|\sand\s/);
for (let editor of editors) {
item.creators.push(ZU.cleanAuthor(editor, editorType));
}
}
// title in metadata is without subtitle
var subtitle = text(doc, '.purchase-item-detail-title-desktop h2');
if (!item.title.includes(subtitle)) {
item.title += ": " + subtitle;
}
var details = text(doc, '.purchase-item-detail-details');
if (details) {
let numPages = details.match(/(\d+)\s*pages/);
if (numPages) item.numPages = numPages[1];
}
var publisher = text(doc, '.purchase-item-detail-distributor a');
if (publisher) {
item.publisher = publisher;
}
else {
item.publisher = "University of Chicago Press";
item.place = "Chicago, IL";
}
item.series = text(doc, '.series-name');
item.date = ZU.strToISO(text(doc, '.purchase-format-pubdate'));
item.ISBN = ZU.cleanISBN(text(doc, '.purchase-format-isbn'));
item.libraryCatalog = "University of Chicago Press";
item.complete();
});
translator.getTranslatorObject(function (trans) {
trans.addCustomFields({
});
trans.doWeb(doc, url);
});
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "https://press.uchicago.edu/ucp/books/book/chicago/E/bo3684144.html",
"items": [
{
"itemType": "book",
"title": "English Verb Classes and Alternations: A Preliminary Investigation",
"creators": [
{
"firstName": "Beth",
"lastName": "Levin",
"creatorType": "author"
}
],
"abstractNote": "In this rich reference work, Beth Levin classifies over 3,000 English verbs according to shared meaning and behavior. Levin starts with the hypothesis that a verb’s meaning influences its syntactic behavior and develops it into a powerful tool for studying the English verb lexicon. She shows how identifying verbs with similar syntactic behavior provides an effective means of distinguishing semantically coherent verb classes, and isolates these classes by examining verb behavior with respect to a wide range of syntactic alternations that reflect verb meaning. The first part of the book sets out alternate ways in which verbs can express their arguments. The second presents classes of verbs that share a kernel of meaning and explores in detail the behavior of each class, drawing on the alternations in the first part. Levin’s discussion of each class and alternation includes lists of relevant verbs, illustrative examples, comments on noteworthy properties, and bibliographic references. The result is an original, systematic picture of the organization of the verb inventory. Easy to use, English Verb Classes and Alternations sets the stage for further explorations of the interface between lexical semantics and syntax. It will prove indispensable for theoretical and computational linguists, psycholinguists, cognitive scientists, lexicographers, and teachers of English as a second language.",
"language": "en",
"libraryCatalog": "University of Chicago Press",
"numPages": "366",
"place": "Chicago, IL",
"publisher": "University of Chicago Press",
"shortTitle": "English Verb Classes and Alternations",
"url": "https://press.uchicago.edu/ucp/books/book/chicago/E/bo3684144.html",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://press.uchicago.edu/ucp/books/book/distributed/N/bo28224328.html",
"items": [
{
"itemType": "book",
"title": "Not for Patching: A Strategic Welfare Review",
"creators": [
{
"firstName": "Frank",
"lastName": "Field",
"creatorType": "author"
},
{
"firstName": "Andrew",
"lastName": "Forsey",
"creatorType": "author"
}
],
"abstractNote": "In his famous report of 1942, the economist and social reformer William Beveridge wrote that World War II was a “revolutionary moment in the world’s history” and so a time “for revolutions, not for patching.” The Beveridge Report outlined the welfare state that Atlee’s government would go on to implement after 1946, instituting, for the first time, a national system of benefits to protect all from “the cradle to the grave.” Its crowning glory was the National Health Service, established in 1948, which provided free medical care for all at the point of delivery. Since then, the welfare system has been patched, beset by muddled thinking and short-termism. The British government spends more than £171 billion every year on welfare—and yet, since the Beveridge Report, there has been no strategic review of the system, compared to other areas of government and public policy, which have been subject to frequent strategic reviews. Reform of the welfare system need not mean dismantlement, Frank Field and Andrew Forsey argue here, but serious questions nonetheless must be asked about how the welfare state as we understand it can remain sustainable as the twenty-first century progresses.",
"language": "en",
"libraryCatalog": "University of Chicago Press",
"numPages": "120",
"publisher": "Haus Publishing",
"series": "Haus Curiosities",
"shortTitle": "Not for Patching",
"url": "https://press.uchicago.edu/ucp/books/book/distributed/N/bo28224328.html",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://press.uchicago.edu/ucp/books/book/chicago/C/bo3624192.html",
"items": [
{
"itemType": "book",
"title": "Civil Society and the Political Imagination in Africa: Critical Perspectives",
"creators": [
{
"firstName": "John L.",
"lastName": "Comaroff",
"creatorType": "editor"
},
{
"firstName": "Jean",
"lastName": "Comaroff",
"creatorType": "editor"
}
],
"abstractNote": "The essays in this important new collection explore the diverse, unexpected, and controversial ways in which the idea of civil society has recently entered into populist politics and public debate throughout Africa. In a substantial introduction, anthropologists Jean and John Comaroff offer a critical theoretical analysis of the nature and deployment of the concept—and the current debates surrounding it. Building on this framework, the contributors investigate the \"problem\" of civil society across their regions of expertise, which cover the continent. Drawing creatively on one another’s work, they examine the impact of colonial ideology, postcoloniality, and development practice on discourses of civility, the workings of everyday politics, the construction of new modes of selfhood, and the pursuit of moral community. Incisive and original, the book shows how struggles over civil society in Africa reveal much about larger historical forces in the post-Cold War era. It also makes a strong case for the contribution of historical anthropology to contemporary discourses on the rise of a \"new world order.\"",
"language": "en",
"libraryCatalog": "University of Chicago Press",
"numPages": "329",
"place": "Chicago, IL",
"publisher": "University of Chicago Press",
"shortTitle": "Civil Society and the Political Imagination in Africa",
"url": "https://press.uchicago.edu/ucp/books/book/chicago/C/bo3624192.html",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://press.uchicago.edu/ucp/books/book/distributed/S/bo70004539.html",
"items": [
{
"itemType": "book",
"title": "Speaking for Ourselves: Environmental Justice in Canada",
"creators": [
{
"firstName": "Julian",
"lastName": "Agyeman",
"creatorType": "editor"
},
{
"firstName": "Peter",
"lastName": "Cole",
"creatorType": "editor"
},
{
"firstName": "Randolph",
"lastName": "Haluza-DeLay",
"creatorType": "editor"
},
{
"firstName": "Pat",
"lastName": "O’Riley",
"creatorType": "editor"
}
],
"abstractNote": "The concept of environmental justice has offered a new direction for social movements and public policy in recent decades, and researchers worldwide now position social equity as a prerequisite for sustainability. Yet the relationship between social equity and environmental sustainability has been little studied in Canada. Speaking for Ourselves draws together Aboriginal and non-Aboriginal scholars and activists who bring equity issues to the forefront by considering environmental justice from multiple perspectives and in specifically Canadian contexts.",
"language": "en",
"libraryCatalog": "University of Chicago Press",
"numPages": "306",
"publisher": "University of British Columbia Press",
"shortTitle": "Speaking for Ourselves",
"url": "https://press.uchicago.edu/ucp/books/book/distributed/S/bo70004539.html",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://press.uchicago.edu/ucp/books/book/distributed/C/bo38131006.html",
"items": [
{
"itemType": "book",
"title": "Capitalism and Labor: Towards Critical Perspectives",
"creators": [
{
"firstName": "Klaus",
"lastName": "Dörre",
"creatorType": "editor"
},
{
"firstName": "Nicole",
"lastName": "Mayer-Ahuja",
"creatorType": "editor"
},
{
"firstName": "Dieter",
"lastName": "Sauer",
"creatorType": "editor"
},
{
"firstName": "Volker",
"lastName": "Wittke",
"creatorType": "editor"
},
{
"firstName": "Julian",
"lastName": "Müller",
"creatorType": "translator"
}
],
"abstractNote": "Capitalism’s presence in nearly all areas of contemporary life is widely-known and unshakeable. There is perhaps nowhere more true than in the workplace. Why then, ask the authors of this collection, have the broad concepts of work and capitalism become a progressively smaller focus in sociology in recent decades, shunted to the sidelines in favor of more granular subjects in labor studies? Capitalism and Labor calls for sociologists to refocus their research on the unavoidable realities of the capitalist system, particularly in the wake of the global financial and economic unrest of the past decade. Although they provide no easy solutions, the essays in this book will serve as a starting point for sociologists to renew their focus on labor and its inextricable relationship to capitalism in the twenty-first century.",
"language": "en",
"libraryCatalog": "University of Chicago Press",
"numPages": "434",
"publisher": "Campus Verlag",
"series": "International Labour Studies",
"shortTitle": "Capitalism and Labor",
"url": "https://press.uchicago.edu/ucp/books/book/distributed/C/bo38131006.html",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://press.uchicago.edu/press/search.html?clause=labor&division=bo",
"items": "multiple"
}
]
/** END TEST CASES **/