forked from zotero/translators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cornell University Press.js
204 lines (185 loc) · 9.62 KB
/
Cornell University Press.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
{
"translatorID": "4363275e-5cc5-4627-9a7f-951fb58a02c3",
"label": "Cornell University Press",
"creator": "Sebastian Karcer",
"target": "^https?://www\\.cornellpress\\.cornell\\.edu/",
"minVersion": "2.1.9",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcs",
"lastUpdated": "2012-04-03 13:56:46"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2012 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.match("/book/")) {
return "book";
} else if (url.match("/search/?") || url.match("/catalog/?")) {
return "multiple";
}
}
function doWeb(doc, url) {
var books = new Array();
if (detectWeb(doc, url) == "multiple") {
var items = new Object();
var rows = ZU.xpath(doc, '//div[@class="GCOIblockcontents"]')
for (var i in rows) {
titles = ZU.xpathText(rows[i], './a/div[@class="MainTitle"]')
urls = ZU.xpathText(rows[i], './a/@href')
items[urls] = titles;
}
Zotero.selectItems(items, function (items) {
if (!items) {
return true;
}
for (var i in items) {
books.push(i);
}
Zotero.Utilities.processDocuments(books, scrape, function () {
Zotero.done();
});
Zotero.wait();
});
} else {
scrape(doc, url);
}
}
function associateData(newItem, dataTags, field, zoteroField) {
if (dataTags[field]) {
newItem[zoteroField] = dataTags[field];
}
}
function scrape(doc, url) {
var newItem = new Zotero.Item("book");
var dataTags = new Object();
var fields = ZU.xpath(doc, '//table[@id="detailsTable"]/tbody/tr/td[1]');
var titles = ZU.xpath(doc, '//table[@id="detailsTable"]/tbody/tr/td[2]');
for (var i in fields) {
var field = fields[i].textContent.trim();
dataTags[field] = titles[i].textContent;
if (field == "Author") {
newItem.creators.push(ZU.cleanAuthor(dataTags["Author"], "author"));
} else if (field == "Authors") {
var author = dataTags["Authors"].split(/\s*,\s*/);
for (var j in author) {
newItem.creators.push(ZU.cleanAuthor(author[j], "author"));
}
}
if (field == "Edited by") {
var editor = dataTags["Edited by"].split(/\s*,\s*/);
for (var j in editor) {
newItem.creators.push(ZU.cleanAuthor(editor[j], "editor"));
}
}
if (field == "Translated by") {
var translator = dataTags["Translated by"].split(/\s*,\s*/);
for (var j in translator) {
newItem.creators.push(ZU.cleanAuthor(translator[j], "translator"));
}
}
if (field == "Subtitle") {
var fulltitle = dataTags["Title"] + ": " + dataTags["Subtitle"];
newItem.title = fulltitle;
} else if (!fulltitle) newItem.title = dataTags["Title"];
if (field == "BISAC") {
var tags = ZU.xpath(titles[i], './div');
for (var j in tags) {
newItem.tags[j] = tags[j].textContent.replace(/.+\//, "").trim();
}
}
if (field == "Publisher") {
newItem.publisher = dataTags["Publisher"];
if (newItem.publisher.indexOf("Leuven") != -1) newItem.place = "Leuven";
else newItem.place = "Ithaca, NY"
} else if (!newItem.publisher) {
newItem.publisher = "Cornell University Press";
newItem.place = "Ithaca, NY";
}
}
associateData(newItem, dataTags, "ISBN-13", "ISBN");
associateData(newItem, dataTags, "Publication Date", "date");
associateData(newItem, dataTags, "Collection", "series");
associateData(newItem, dataTags, "Language", "language");
associateData(newItem, dataTags, "Languages", "language");
associateData(newItem, dataTags, "Nb of pages", "numPages");
newItem.abstractNote = ZU.xpathText(doc, '//div[@id="bookpagedescription"]');
newItem.complete();
} /** BEGIN TEST CASES **/
var testCases = [{
"type": "web",
"url": "http://www.cornellpress.cornell.edu/book/?GCOI=80140100486370",
"items": [{
"itemType": "book",
"creators": [{
"firstName": "Jenny",
"lastName": "Edkins",
"creatorType": "author"
}],
"notes": [],
"tags": ["History & Theory", "Human Rights", "Demography"],
"seeAlso": [],
"attachments": [],
"title": "Missing: Persons and Politics",
"ISBN": "978-0-8014-5029-7",
"date": "September 2011",
"numPages": "280",
"publisher": "Cornell University Press",
"place": "Ithaca, NY",
"abstractNote": "Stories of the missing offer profound insights into the tension between how political systems see us and how we see each other. The search for people who go missing as a result of war, political violence, genocide, or natural disaster reveals how forms of governance that objectify the person are challenged. Contemporary political systems treat persons instrumentally, as objects to be administered rather than as singular beings: the apparatus of government recognizes categories, not people. In contrast, relatives of the missing demand that authorities focus on a particular person: families and friends are looking for someone who to them is unique and irreplaceable. In Missing, Jenny Edkins highlights stories from a range of circumstances that shed light on this critical tension: the aftermath of World War II, when millions in Europe were displaced; the period following the fall of the World Trade Center towers in Manhattan in 2001 and the bombings in London in 2005; searches for military personnel missing in action; the thousands of political \"disappearances\" in Latin America; and in more quotidian circumstances where people walk out on their families and disappear of their own volition. When someone goes missing we often find that we didn't know them as well as we thought: there is a sense in which we are \"missing\" even to our nearest and dearest and even when we are present, not absent. In this thought-provoking book, Edkins investigates what this more profound \"missingness\" might mean in political terms.",
"libraryCatalog": "Cornell University Press",
"shortTitle": "Missing"
}]
}, {
"type": "web",
"url": "http://www.cornellpress.cornell.edu/book/?GCOI=80140100195440",
"items": [{
"itemType": "book",
"creators": [{
"firstName": "Hans",
"lastName": "Blumenberg",
"creatorType": "author"
}, {
"firstName": "Robert L.",
"lastName": "Savage",
"creatorType": "translator"
}],
"notes": [],
"tags": ["Methodology", "Criticism", "Semiotics & Theory"],
"seeAlso": [],
"attachments": [],
"title": "Paradigms for a Metaphorology",
"publisher": "Cornell University Press",
"place": "Ithaca, NY",
"ISBN": "978-0-8014-4925-3",
"date": "August 2010",
"series": "Signale: Modern German Letters, Cultures, and Thought",
"numPages": "160",
"abstractNote": "\"Paradigms for a Metaphorology may be read as a kind of beginner's guide to Blumenberg, a programmatic introduction to his vast and multifaceted oeuvre. Its brevity makes it an ideal point of entry for readers daunted by the sheer bulk of Blumenberg's later writings, or distracted by their profusion of historical detail. Paradigms expresses many of Blumenberg’s key ideas with a directness, concision, and clarity he would rarely match elsewhere. What is more, because it served as a beginner’s guide for its author as well, allowing him to undertake an initial survey of problems that would preoccupy him for the remainder of his life, it has the additional advantage that it can offer us a glimpse into what might be called the 'genesis of the Blumenbergian world.’\"—from the Afterword by Robert Savage What role do metaphors play in philosophical language? Are they impediments to clear thinking and clear expression, rhetorical flourishes that may well help to make philosophy more accessible to a lay audience, but that ought ideally to be eradicated in the interests of terminological exactness? Or can the images used by philosophers tell us more about the hopes and cares, attitudes and indifferences that regulate an epoch than their carefully elaborated systems of thought? In Paradigms for a Metaphorology, originally published in 1960 and here made available for the first time in English translation, Hans Blumenberg (1920–1996) approaches these questions by examining the relationship between metaphors and concepts. Blumenberg argues for the existence of \"absolute metaphors\" that cannot be translated back into conceptual language. These metaphors answer the supposedly naïve, theoretically unanswerable questions whose relevance lies quite simply in the fact that they cannot be brushed aside, since we do not pose them ourselves but find them already posed in the ground of our existence. They leap into a void that concepts are unable to fill. An afterword by the translator, Robert Savage, positions the book in the intellectual context of its time and explains its continuing importance for work in the history of ideas.",
"libraryCatalog": "Cornell University Press"
}]
}, {
"type": "web",
"url": "http://www.cornellpress.cornell.edu/catalog/?category_id=19",
"items": "multiple"
}, {
"type": "web",
"url": "http://www.cornellpress.cornell.edu/search/?fa=rechercheA&keyType=all&keywords=translated&title=&author=&isbnORissn=&Collection_ID=&Format_id=&Editeur=&LanguageCode=&StartYear=----&EndYear=2012&formfield1234567893=39860609%2C19953448&formfield1234567894=",
"items": "multiple"
}]
/** END TEST CASES **/