1
+ {
2
+ "translatorID" : "83d2ed27-40a5-4dc7-bd87-baddc8fb35da" ,
3
+ "label" : "SORA" ,
4
+ "creator" : "Philipp Zumstein" ,
5
+ "target" : "^https?://sora\\.unm\\.edu/(node/|search/node/|advancedsearch\\?)" ,
6
+ "minVersion" : "3.0" ,
7
+ "maxVersion" : "" ,
8
+ "priority" : 100 ,
9
+ "inRepository" : true ,
10
+ "translatorType" : 4 ,
11
+ "browserSupport" : "gcsbv" ,
12
+ "lastUpdated" : "2015-01-02 22:03:36"
13
+ }
14
+
15
+ /*
16
+ ***** BEGIN LICENSE BLOCK *****
17
+
18
+ Copyright © 2014 Philipp Zumstein
19
+
20
+ This file is part of Zotero.
21
+
22
+ Zotero is free software: you can redistribute it and/or modify
23
+ it under the terms of the GNU Affero General Public License as published by
24
+ the Free Software Foundation, either version 3 of the License, or
25
+ (at your option) any later version.
26
+
27
+ Zotero is distributed in the hope that it will be useful,
28
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
29
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
+ GNU Affero General Public License for more details.
31
+
32
+ You should have received a copy of the GNU Affero General Public License
33
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
34
+
35
+ ***** END LICENSE BLOCK *****
36
+ */
37
+
38
+ var mapping = {
39
+ "journal" : "publicationTitle" ,
40
+ "volume" : "volume" ,
41
+ "issue" : "issue" ,
42
+ "year" : "date" ,
43
+ "pages" : "pages" ,
44
+ "section" : "extra"
45
+ }
46
+
47
+
48
+ function detectWeb ( doc , url ) {
49
+ if ( ZU . xpath ( doc , '//div[contains(@class, "content")]/fieldset/legend' ) . length ) { // Publication Information
50
+ if ( getSearchResults ( doc , true ) ) {
51
+ return "multiple" ;
52
+ } else {
53
+ return "journalArticle" ;
54
+ }
55
+ }
56
+ if ( url . indexOf ( 'search' ) > - 1 && getSearchResults ( doc , true ) ) {
57
+ return "multiple" ;
58
+ }
59
+ }
60
+
61
+ function getSearchResults ( doc , checkOnly ) {
62
+ var items = { } ;
63
+ var found = false ;
64
+ var rows = ZU . xpath ( doc , '//div[contains(@class, "content")]//dt//a|//strong[contains(@class, "field-content")]/a' ) ;
65
+ for ( var i = 0 ; i < rows . length ; i ++ ) {
66
+ var href = rows [ i ] . href ;
67
+ var title = ZU . trimInternal ( rows [ i ] . textContent ) ;
68
+ if ( ! href || ! title ) continue ;
69
+ if ( checkOnly ) return true ;
70
+ found = true ;
71
+ items [ href ] = title ;
72
+ }
73
+ return found ? items : false ;
74
+ }
75
+
76
+ function doWeb ( doc , url ) {
77
+ if ( detectWeb ( doc , url ) == "multiple" ) {
78
+ Zotero . selectItems ( getSearchResults ( doc , false ) , function ( items ) {
79
+ if ( ! items ) {
80
+ return true ;
81
+ }
82
+ var articles = new Array ( ) ;
83
+ for ( var i in items ) {
84
+ articles . push ( i ) ;
85
+ }
86
+ ZU . processDocuments ( articles , scrape ) ;
87
+ } ) ;
88
+ } else {
89
+ scrape ( doc , url ) ;
90
+ }
91
+ }
92
+
93
+
94
+ function scrape ( doc , url ) {
95
+ var item = new Zotero . Item ( detectWeb ( doc , url ) ) ;
96
+
97
+ //title
98
+ var title = ZU . xpathText ( doc , '//h1[contains(@class, "title")]' ) ;
99
+ item . title = title ;
100
+
101
+ //authors
102
+ //Examples:
103
+ //Edward H. Burtt, Jr.
104
+ //James Hengeveld, Keith A. Mcmullen, Geoffrey A. Williamson
105
+ //==> The author string is splitted by ',' into the individual
106
+ //authors, but for suffixes this will be corrected again by
107
+ //some heuristic. This heuristic seperates another autor
108
+ //from a suffix by checking if the string consists any space
109
+ //and its length is less than 5.
110
+ var authors = ZU . xpathText ( doc , '//div[contains(@class, "content")]/div[contains(@class, "field-field-authors")]/div/div/text()' ) ;
111
+ if ( authors ) {
112
+ var authorsSplit = authors . split ( ',' ) ;
113
+ var index = 0 ;
114
+ for ( var m = 0 ; m < authorsSplit . length ; m ++ ) {
115
+ var value = ZU . trim ( authorsSplit [ m ] ) ;
116
+ if ( value != '' ) {
117
+ if ( value . indexOf ( ' ' ) == - 1 && value . length < 5 && index > 0 ) {
118
+ item . creators [ index - 1 ] . firstName += ', ' + value ; //Jr. or III.
119
+ } else {
120
+ item . creators . push ( ZU . cleanAuthor ( value , "author" ) ) ;
121
+ index ++ ;
122
+ }
123
+
124
+ }
125
+ }
126
+ }
127
+
128
+ //other fields
129
+ var fields = ZU . xpath ( doc , '//div[contains(@class, "content")]/fieldset/div' ) ;
130
+ for ( var k = 0 ; k < fields . length ; k ++ ) {
131
+ var fieldName = ZU . trim ( ZU . xpathText ( fields [ k ] , './div/div/div' ) . replace ( ':' , '' ) . toLowerCase ( ) ) ;
132
+ var fieldValue = ZU . trim ( ZU . xpathText ( fields [ k ] , './div/div/text()' ) . replace ( ',' , '' ) ) ;
133
+ if ( mapping [ fieldName ] ) {
134
+ item [ mapping [ fieldName ] ] = fieldValue ;
135
+ } else {
136
+ Z . debug ( 'Unrecognized field: ' + fieldName ) ;
137
+ }
138
+ }
139
+
140
+
141
+ //PDF
142
+ var attachments = doc . getElementById ( 'attachments' ) ;
143
+ if ( attachments ) {
144
+ var link = attachments . getElementsByTagName ( 'a' ) ;
145
+ if ( link . length ) {
146
+ item . attachments . push ( {
147
+ title : "Full Text PDF" ,
148
+ url : link [ 0 ] . href ,
149
+ mimeType : "application/pdf"
150
+ } ) ;
151
+ }
152
+ }
153
+ //link to SORA entry
154
+ item . attachments . push ( {
155
+ title : "SORA Entry" ,
156
+ url : url ,
157
+ mimeType : "text/html" ,
158
+ snapshot : false
159
+ } ) ;
160
+
161
+ item . complete ( ) ;
162
+ } /** BEGIN TEST CASES **/
163
+ var testCases = [
164
+ {
165
+ "type" : "web" ,
166
+ "url" : "https://sora.unm.edu/node/99151" ,
167
+ "items" : [
168
+ {
169
+ "itemType" : "journalArticle" ,
170
+ "title" : "The Passing of Coragyps Shastensis Miller" ,
171
+ "creators" : [
172
+ {
173
+ "firstName" : "Loye" ,
174
+ "lastName" : "Miller" ,
175
+ "creatorType" : "author"
176
+ }
177
+ ] ,
178
+ "date" : "1941" ,
179
+ "issue" : "3 (May-June)" ,
180
+ "libraryCatalog" : "SORA" ,
181
+ "pages" : "140-141" ,
182
+ "publicationTitle" : "Condor" ,
183
+ "volume" : "43" ,
184
+ "attachments" : [
185
+ {
186
+ "title" : "Full Text PDF" ,
187
+ "mimeType" : "application/pdf"
188
+ } ,
189
+ {
190
+ "title" : "SORA Entry" ,
191
+ "mimeType" : "text/html" ,
192
+ "snapshot" : false
193
+ }
194
+ ] ,
195
+ "tags" : [ ] ,
196
+ "notes" : [ ] ,
197
+ "seeAlso" : [ ]
198
+ }
199
+ ]
200
+ } ,
201
+ {
202
+ "type" : "web" ,
203
+ "url" : "https://sora.unm.edu/node/2035" ,
204
+ "items" : "multiple"
205
+ } ,
206
+ {
207
+ "type" : "web" ,
208
+ "url" : "https://sora.unm.edu/node/116567" ,
209
+ "items" : [
210
+ {
211
+ "itemType" : "journalArticle" ,
212
+ "title" : "Illinois and Indiana" ,
213
+ "creators" : [
214
+ {
215
+ "firstName" : "James" ,
216
+ "lastName" : "Hengeveld" ,
217
+ "creatorType" : "author"
218
+ } ,
219
+ {
220
+ "firstName" : "Keith A." ,
221
+ "lastName" : "Mcmullen" ,
222
+ "creatorType" : "author"
223
+ } ,
224
+ {
225
+ "firstName" : "Geoffrey A." ,
226
+ "lastName" : "Williamson" ,
227
+ "creatorType" : "author"
228
+ }
229
+ ] ,
230
+ "date" : "2006" ,
231
+ "issue" : "3" ,
232
+ "libraryCatalog" : "SORA" ,
233
+ "pages" : "376-378" ,
234
+ "publicationTitle" : "North American Birds" ,
235
+ "volume" : "60" ,
236
+ "attachments" : [
237
+ {
238
+ "title" : "Full Text PDF" ,
239
+ "mimeType" : "application/pdf"
240
+ } ,
241
+ {
242
+ "title" : "SORA Entry" ,
243
+ "mimeType" : "text/html" ,
244
+ "snapshot" : false
245
+ }
246
+ ] ,
247
+ "tags" : [ ] ,
248
+ "notes" : [ ] ,
249
+ "seeAlso" : [ ]
250
+ }
251
+ ]
252
+ } ,
253
+ {
254
+ "type" : "web" ,
255
+ "url" : "https://sora.unm.edu/node/162" ,
256
+ "items" : [
257
+ {
258
+ "itemType" : "journalArticle" ,
259
+ "title" : "An Analysis of Physical, Physiological, and Optical Aspects of Avian Coloration With Emphasis On Wood-Warblers" ,
260
+ "creators" : [
261
+ {
262
+ "firstName" : "Edward H., Jr." ,
263
+ "lastName" : "Burtt" ,
264
+ "creatorType" : "author"
265
+ }
266
+ ] ,
267
+ "date" : "1986" ,
268
+ "issue" : "38" ,
269
+ "libraryCatalog" : "SORA" ,
270
+ "pages" : "1-126" ,
271
+ "publicationTitle" : "Ornithological Monographs" ,
272
+ "attachments" : [
273
+ {
274
+ "title" : "Full Text PDF" ,
275
+ "mimeType" : "application/pdf"
276
+ } ,
277
+ {
278
+ "title" : "SORA Entry" ,
279
+ "mimeType" : "text/html" ,
280
+ "snapshot" : false
281
+ }
282
+ ] ,
283
+ "tags" : [ ] ,
284
+ "notes" : [ ] ,
285
+ "seeAlso" : [ ]
286
+ }
287
+ ]
288
+ } ,
289
+ {
290
+ "type" : "web" ,
291
+ "url" : "https://sora.unm.edu/advancedsearch?field_authors_value=&title=condor&field_fulltext_value=&field_year_value=" ,
292
+ "items" : "multiple"
293
+ } ,
294
+ {
295
+ "type" : "web" ,
296
+ "url" : "https://sora.unm.edu/search/node/eagle%20type%3Aarticle" ,
297
+ "items" : "multiple"
298
+ } ,
299
+ {
300
+ "type" : "web" ,
301
+ "url" : "https://sora.unm.edu/node/53338" ,
302
+ "items" : [
303
+ {
304
+ "itemType" : "journalArticle" ,
305
+ "title" : "A Comparison of Home Range Estimates for a Bald Eagle Wintering in New Mexico" ,
306
+ "creators" : [
307
+ {
308
+ "firstName" : "Dale W." ,
309
+ "lastName" : "Stahlecker" ,
310
+ "creatorType" : "author"
311
+ } ,
312
+ {
313
+ "firstName" : "Timothy G." ,
314
+ "lastName" : "Smith" ,
315
+ "creatorType" : "author"
316
+ }
317
+ ] ,
318
+ "date" : "1993" ,
319
+ "extra" : "Short Communications" ,
320
+ "issue" : "1 (March)" ,
321
+ "libraryCatalog" : "SORA" ,
322
+ "pages" : "42-45" ,
323
+ "publicationTitle" : "Journal of Raptor Research" ,
324
+ "volume" : "27" ,
325
+ "attachments" : [
326
+ {
327
+ "title" : "Full Text PDF" ,
328
+ "mimeType" : "application/pdf"
329
+ } ,
330
+ {
331
+ "title" : "SORA Entry" ,
332
+ "mimeType" : "text/html" ,
333
+ "snapshot" : false
334
+ }
335
+ ] ,
336
+ "tags" : [ ] ,
337
+ "notes" : [ ] ,
338
+ "seeAlso" : [ ]
339
+ }
340
+ ]
341
+ }
342
+ ]
343
+ /** END TEST CASES **/
0 commit comments