-
Notifications
You must be signed in to change notification settings - Fork 761
/
Art Institute of Chicago.js
279 lines (261 loc) · 7.07 KB
/
Art Institute of Chicago.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
{
"translatorID": "8e98b11a-5648-42b2-8542-5f366cb953f6",
"label": "Art Institute of Chicago",
"creator": "nikhil trivedi, Illya Moskvin",
"target": "^https?://(www\\.)?artic\\.edu/(artworks/|collection)",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2021-06-04 20:08:22"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2021 Art Institute of Chicago
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) {
if (ZU.xpathText(doc, '//html[contains(@class, "p-artwork-show")]')) {
return 'artwork';
}
else if (ZU.xpathText(doc, '//html[contains(@class, "p-collection-index")]')) {
return 'multiple';
}
return false;
}
function doWeb(doc) {
if (detectWeb(doc) == "multiple") {
Zotero.selectItems(getSearchResults(doc, false), function (items) {
if (!items) {
return true;
}
var articles = [];
for (var i in items) {
articles.push(i);
}
ZU.processDocuments(articles, scrape);
return true;
});
} else {
scrape(doc);
}
}
function scrape(doc) {
var item = new Zotero.Item('artwork');
item.title = ZU.xpathText(doc, '//h1');
var artists = ZU.xpath(doc, '//meta[contains(@name, "citation_author")]');
for (var i = 0; i < artists.length; i++) {
var cleaned = artists[i].content.replace(/\(.*\)$/, '').trim();
item.creators.push(ZU.cleanAuthor(cleaned, 'artist'));
}
item.attachments.push({
title: 'Snapshot',
document: doc
});
item.date = ZU
.xpath(doc, '//dl[@id="dl-artwork-details"]/dd[@itemprop="dateCreated"]/*/a')
.map(function (date) {
return date.textContent;
})
.join(', ');
item.artworkMedium = ZU.xpathText(doc, '//dl[@id="dl-artwork-details"]/dd[@itemprop="material"]');
item.artworkSize = ZU.xpathText(doc, '//dl[@id="dl-artwork-details"]/dd[@itemprop="size"]');
item.callNumber = ZU.xpathText(doc, '//dl[@id="dl-artwork-details"]/dd[@itemprop="identifier"]');
item.url = ZU.xpathText(doc, '//link[@rel="canonical"]/@href');
item.complete();
}
function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = ZU.xpath(doc, '//ul[@id="artworksList"]/li/a');
for (var i = 0; i < rows.length; i++) {
var href = rows[i].href;
var title = ZU.trimInternal(rows[i].textContent);
if (!href || !title) continue;
if (checkOnly) return true;
found = true;
items[href] = title;
}
return found ? items : false;
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "https://www.artic.edu/artworks/129884/starry-night-and-the-astronauts",
"items": [
{
"itemType": "artwork",
"title": "Starry Night and the Astronauts",
"creators": [
{
"firstName": "Alma",
"lastName": "Thomas",
"creatorType": "artist"
}
],
"date": "1972",
"artworkMedium": "Acrylic on canvas",
"artworkSize": "152.4 × 134.6 cm (60 × 53 in.)",
"callNumber": "1994.36",
"libraryCatalog": "Art Institute of Chicago",
"url": "https://www.artic.edu/artworks/129884/starry-night-and-the-astronauts",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.artic.edu/artworks/156538/chicago-stock-exchange-trading-room-reconstruction-at-the-art-institute-of-chicago",
"items": [
{
"itemType": "artwork",
"title": "Chicago Stock Exchange Trading Room: Reconstruction at the Art Institute of Chicago",
"creators": [
{
"lastName": "Architects",
"creatorType": "artist",
"firstName": "Adler & Sullivan"
}
],
"date": "Built 1893–1894",
"artworkMedium": "Mixed media recreation of room",
"artworkSize": "Room is roughly 5,704 square feet (not including gallery)",
"callNumber": "RX23310/0002",
"libraryCatalog": "Art Institute of Chicago",
"shortTitle": "Chicago Stock Exchange Trading Room",
"url": "https://www.artic.edu/artworks/156538/chicago-stock-exchange-trading-room-reconstruction-at-the-art-institute-of-chicago",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.artic.edu/artworks/28560/the-bedroom",
"items": [
{
"itemType": "artwork",
"title": "The Bedroom",
"creators": [
{
"lastName": "Gogh",
"creatorType": "artist",
"firstName": "Vincent van"
}
],
"date": "1889",
"artworkMedium": "Oil on canvas",
"artworkSize": "73.6 × 92.3 cm (29 × 36 5/8 in.)",
"callNumber": "1926.417",
"libraryCatalog": "Art Institute of Chicago",
"url": "https://www.artic.edu/artworks/28560/the-bedroom",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.artic.edu/artworks/52273/platform-bench",
"items": [
{
"itemType": "artwork",
"title": "Platform Bench",
"creators": [
{
"firstName": "George",
"lastName": "Nelson",
"creatorType": "artist"
},
{
"lastName": "Inc",
"creatorType": "artist",
"firstName": "Herman Miller"
}
],
"date": "Designed 1946, Made 1946-1967, c. 1946-1967",
"artworkMedium": "Birch",
"artworkSize": "35.5 × 47 × 183.5 cm (14 × 18 1/2 × 72 1/4 in.)",
"callNumber": "1978.141",
"libraryCatalog": "Art Institute of Chicago",
"url": "https://www.artic.edu/artworks/52273/platform-bench",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.artic.edu/artworks/7691/gathering-seaweed-at-omori",
"items": [
{
"itemType": "artwork",
"title": "Gathering Seaweed at Omori",
"creators": [
{
"firstName": "Utagawa",
"lastName": "Kuniyoshi",
"creatorType": "artist"
}
],
"artworkMedium": "Ink and red pigment on paper",
"callNumber": "1958.191",
"libraryCatalog": "Art Institute of Chicago",
"url": "https://www.artic.edu/artworks/7691/gathering-seaweed-at-omori",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
}
]
/** END TEST CASES **/