1
1
{
2
- "translatorID" : "ab5983ab-6ad9-4060-aff1-4b455c89a3b3" ,
3
- "label" : "Figshare" ,
4
- "creator" : "Sebatian Karcher" ,
5
- "target" : "^https?://figshare\\.com" ,
6
- "minVersion" : "1.0" ,
7
- "maxVersion" : "" ,
8
- "priority" : 100 ,
9
- "inRepository" : true ,
10
- "translatorType" : 4 ,
11
- "browserSupport" : "gc " ,
12
- "lastUpdated" : "2013-11-19 08:23:18 "
2
+ "translatorID" : "ab5983ab-6ad9-4060-aff1-4b455c89a3b3" ,
3
+ "label" : "Figshare" ,
4
+ "creator" : "Sebatian Karcher" ,
5
+ "target" : "^https?://figshare\\.com" ,
6
+ "minVersion" : "1.0" ,
7
+ "maxVersion" : "" ,
8
+ "priority" : 100 ,
9
+ "inRepository" : true ,
10
+ "translatorType" : 4 ,
11
+ "browserSupport" : "gcsb " ,
12
+ "lastUpdated" : "2013-12-10 16:57:47 "
13
13
}
14
14
15
15
/*
36
36
37
37
38
38
function detectWeb ( doc , url ) {
39
- if ( url . indexOf ( "search?q" ) != - 1 || url . indexOf ( "/browse" ) != - 1 ) {
40
- return "multiple" ;
41
- } else if ( url . indexOf ( "/article" ) != - 1 ) {
42
- //no great item type here - switch once we have dataset.
43
- return "document" ;
44
- }
39
+ if ( url . indexOf ( "search?q" ) != - 1 || url . indexOf ( "/browse" ) != - 1 ) {
40
+ return "multiple" ;
41
+ } else if ( url . indexOf ( "/article" ) != - 1 ) {
42
+ //no great item type here - switch once we have dataset.
43
+ return "document" ;
44
+ }
45
45
}
46
46
47
47
function doWeb ( doc , url ) {
48
- var arts = new Array ( ) ;
49
- if ( detectWeb ( doc , url ) == "multiple" ) {
50
- var items = new Object ( ) ;
51
- var title ;
48
+ var arts = new Array ( ) ;
49
+ if ( detectWeb ( doc , url ) == "multiple" ) {
50
+ var items = new Object ( ) ;
51
+ var title ;
52
52
53
- var titles = doc . evaluate ( '//div[@class="list_elem"]//a[contains(@href, "article")]' , doc , null , XPathResult . ANY_TYPE , null ) ;
54
- if ( titles . iterateNext ( ) ) {
55
- while ( title = titles . iterateNext ( ) ) {
56
- items [ title . href ] = title . textContent ;
57
- }
58
- } else {
59
- var titles = doc . evaluate ( '//div[@class="textthumb"]/p' , doc , null , XPathResult . ANY_TYPE , null ) ;
60
- var links = doc . evaluate ( '//div[@class="imgthumb"]//a[contains(@href, "article")]' , doc , null , XPathResult . ANY_TYPE , null ) ;
61
- var link ;
62
- while ( ( title = titles . iterateNext ( ) ) && ( link = links . iterateNext ( ) ) ) {
63
- items [ link . href ] = title . textContent ;
64
- }
65
- }
66
- Zotero . selectItems ( items , function ( items ) {
67
- if ( ! items ) {
68
- return true ;
69
- }
70
- for ( var i in items ) {
71
- arts . push ( i ) ;
72
- }
73
- Zotero . Utilities . processDocuments ( arts , scrape ) ;
74
- } ) ;
75
- } else {
76
- scrape ( doc , url ) ;
77
- }
53
+ var titles = doc . evaluate ( '//div[@class="list_elem"]//a[contains(@href, "article")]' , doc , null , XPathResult . ANY_TYPE , null ) ;
54
+ if ( titles . iterateNext ( ) ) {
55
+ while ( title = titles . iterateNext ( ) ) {
56
+ items [ title . href ] = title . textContent ;
57
+ }
58
+ } else {
59
+ var titles = doc . evaluate ( '//div[@class="textthumb"]/p' , doc , null , XPathResult . ANY_TYPE , null ) ;
60
+ var links = doc . evaluate ( '//div[@class="imgthumb"]//a[contains(@href, "article")]' , doc , null , XPathResult . ANY_TYPE , null ) ;
61
+ var link ;
62
+ while ( ( title = titles . iterateNext ( ) ) && ( link = links . iterateNext ( ) ) ) {
63
+ items [ link . href ] = title . textContent ;
64
+ }
65
+ }
66
+ Zotero . selectItems ( items , function ( items ) {
67
+ if ( ! items ) {
68
+ return true ;
69
+ }
70
+ for ( var i in items ) {
71
+ arts . push ( i ) ;
72
+ }
73
+ Zotero . Utilities . processDocuments ( arts , scrape ) ;
74
+ } ) ;
75
+ } else {
76
+ scrape ( doc , url ) ;
77
+ }
78
78
}
79
79
80
80
function scrape ( doc , url ) {
81
- var id = url . match ( / \/ ( \d + ) / ) ;
82
- if ( id ) id = id [ 1 ] ;
83
- var get = 'http://figshare.com/articles/exportref?id=' + id ;
84
- var downloadlink = ZU . xpathText ( doc , '//div[@id="download_all"]/a/@href' ) ;
85
- if ( downloadlink . indexOf ( "javascript:void" ) != - 1 ) downloadlink = "" ;
86
- var DOI = ZU . xpathText ( doc , '//meta[@name="citation_doi"]/@content' )
87
- ZU . HTTP . doGet ( get , function ( text ) {
88
- //Z.debug(text)
89
- text = text . trim ( )
90
- var translator = Zotero . loadTranslator ( "import" ) ;
91
- translator . setTranslator ( "32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7" ) ;
92
- translator . setString ( text ) ;
93
- translator . setHandler ( "itemDone" , function ( obj , item ) {
94
- //Authors are firstName LastName - fix
95
- for ( i in item . creators ) {
96
- //sometimes there _is_ a comma delimiter
97
- if ( ! item . creators [ i ] . firstName ) {
98
- item . creators [ i ] = ZU . cleanAuthor ( item . creators [ i ] . lastName , "author" )
99
- }
100
- }
101
- //Remove period at end of title
102
- item . title = item . title . replace ( / \. \s * $ / , "" ) ;
103
- item . attachments . push ( {
104
- document : doc ,
105
- title : "Figshare Snapshot" ,
106
- mimeType : "text/html"
107
- } ) ;
108
- item . DOI = DOI ;
109
- if ( downloadlink ) {
110
- item . attachments . push ( {
111
- url : downloadlink ,
112
- title : "Figshare Download"
113
- } )
114
- }
115
- item . complete ( ) ;
116
- } ) ;
117
- translator . translate ( ) ;
118
- } ) ;
81
+ var id = url . match ( / \/ ( \d + ) / ) ;
82
+ if ( id ) id = id [ 1 ] ;
83
+ var get = 'http://figshare.com/articles/exportref?id=' + id ;
84
+ var downloadlink = ZU . xpathText ( doc , '//div[@id="download_all"]/a/@href' ) ;
85
+ if ( downloadlink . indexOf ( "javascript:void" ) != - 1 ) downloadlink = "" ;
86
+ var DOI = ZU . xpathText ( doc , '//meta[@name="citation_doi"]/@content' )
87
+ ZU . HTTP . doGet ( get , function ( text ) {
88
+ //Z.debug(text)
89
+ text = text . trim ( )
90
+ var translator = Zotero . loadTranslator ( "import" ) ;
91
+ translator . setTranslator ( "32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7" ) ;
92
+ translator . setString ( text ) ;
93
+ translator . setHandler ( "itemDone" , function ( obj , item ) {
94
+ //Authors are firstName LastName - fix
95
+ for ( i in item . creators ) {
96
+ //sometimes there _is_ a comma delimiter
97
+ if ( ! item . creators [ i ] . firstName ) {
98
+ item . creators [ i ] = ZU . cleanAuthor ( item . creators [ i ] . lastName , "author" )
99
+ }
100
+ }
101
+ //Remove period at end of title
102
+ item . title = item . title . replace ( / \. \s * $ / , "" ) ;
103
+ item . attachments . push ( {
104
+ document : doc ,
105
+ title : "Figshare Snapshot" ,
106
+ mimeType : "text/html"
107
+ } ) ;
108
+ item . DOI = DOI ;
109
+ if ( downloadlink ) {
110
+ item . attachments . push ( {
111
+ url : downloadlink ,
112
+ title : "Figshare Download"
113
+ } )
114
+ }
115
+ item . complete ( ) ;
116
+ } ) ;
117
+ translator . translate ( ) ;
118
+ } ) ;
119
119
}
120
120
/** BEGIN TEST CASES **/
121
- var testCases = [ {
122
- "type" : "web" ,
123
- "url" : "http://figshare.com/articles/browse#thumb" ,
124
- "items" : "multiple"
125
- } , {
126
- "type" : "web" ,
127
- "url" : "http://figshare.com/articles/_Number_of_reported_pertussis_cases_per_week_in_Japan_from_2002_to_2012_/815480" ,
128
- "items" : [ {
129
- "itemType" : "document" ,
130
- "creators" : [ {
131
- "firstName" : "Yusuke" ,
132
- "lastName" : "Miyaji" ,
133
- "creatorType" : "author"
134
- } , {
135
- "firstName" : "Nao" ,
136
- "lastName" : "Otsuka" ,
137
- "creatorType" : "author"
138
- } , {
139
- "firstName" : "Hiromi" ,
140
- "lastName" : "Toyoizumi-Ajisaka" ,
141
- "creatorType" : "author"
142
- } , {
143
- "firstName" : "Keigo" ,
144
- "lastName" : "Shibayama" ,
145
- "creatorType" : "author"
146
- } , {
147
- "firstName" : "Kazunari" ,
148
- "lastName" : "Kamachi" ,
149
- "creatorType" : "author"
150
- } ] ,
151
- "notes" : [ ] ,
152
- "tags" : [
153
- "japan" ,
154
- "cases" ,
155
- "2002" ,
156
- "pertussis"
157
- ] ,
158
- "seeAlso" : [ ] ,
159
- "attachments" : [ {
160
- "title" : "Full Text (HTML)" ,
161
- "mimeType" : "text/html" ,
162
- "downloadable" : true
163
- } , {
164
- "title" : "Figure_1" ,
165
- "downloadable" : true
166
- } , {
167
- "title" : "Figshare Snapshot" ,
168
- "mimeType" : "text/html"
169
- } , {
170
- "title" : "Figshare Download"
171
- } ] ,
172
- "title" : "Number of reported pertussis cases per week in Japan from 2002 to 2012" ,
173
- "url" : "http://figshare.com/articles/_Number_of_reported_pertussis_cases_per_week_in_Japan_from_2002_to_2012_/815480" ,
174
- "abstractNote" : "Pertussis cases are shown by the black line, with each value representing a week of the year. The percentage of adolescent and adult cases (≥15 years old) per year is shown in red circles. The data were obtained from the Ministry of Health, Labor and Welfare of Japan Infectious Disease Surveillance data. Data regarding the number of adolescent and adult cases in 2012 were not available." ,
175
- "date" : "October 5, 2013" ,
176
- "DOI" : "doi:10.6084/m9.figshare.815480" ,
177
- "libraryCatalog" : "Figshare" ,
178
- "accessDate" : "CURRENT_TIMESTAMP"
179
- } ]
180
- } , {
181
- "type" : "web" ,
182
- "url" : "http://figshare.com/articles/search?q=labor&quick=1&x=0&y=0" ,
183
- "items" : "multiple"
184
- } ]
185
- /** END TEST CASES **/
121
+ var testCases = [
122
+ {
123
+ "type" : "web" ,
124
+ "url" : "http://figshare.com/articles/browse#thumb" ,
125
+ "items" : "multiple"
126
+ } ,
127
+ {
128
+ "type" : "web" ,
129
+ "url" : "http://figshare.com/articles/_Number_of_reported_pertussis_cases_per_week_in_Japan_from_2002_to_2012_/815480" ,
130
+ "items" : [
131
+ {
132
+ "itemType" : "document" ,
133
+ "creators" : [
134
+ {
135
+ "firstName" : "Yusuke" ,
136
+ "lastName" : "Miyaji" ,
137
+ "creatorType" : "author"
138
+ } ,
139
+ {
140
+ "firstName" : "Nao" ,
141
+ "lastName" : "Otsuka" ,
142
+ "creatorType" : "author"
143
+ } ,
144
+ {
145
+ "firstName" : "Hiromi" ,
146
+ "lastName" : "Toyoizumi-Ajisaka" ,
147
+ "creatorType" : "author"
148
+ } ,
149
+ {
150
+ "firstName" : "Keigo" ,
151
+ "lastName" : "Shibayama" ,
152
+ "creatorType" : "author"
153
+ } ,
154
+ {
155
+ "firstName" : "Kazunari" ,
156
+ "lastName" : "Kamachi" ,
157
+ "creatorType" : "author"
158
+ }
159
+ ] ,
160
+ "notes" : [ ] ,
161
+ "tags" : [
162
+ "japan" ,
163
+ "cases" ,
164
+ "2002" ,
165
+ "pertussis"
166
+ ] ,
167
+ "seeAlso" : [ ] ,
168
+ "attachments" : [
169
+ {
170
+ "title" : "Full Text (HTML)" ,
171
+ "mimeType" : "text/html" ,
172
+ "downloadable" : true
173
+ } ,
174
+ {
175
+ "title" : "Figure_1" ,
176
+ "downloadable" : true
177
+ } ,
178
+ {
179
+ "title" : "Figshare Snapshot" ,
180
+ "mimeType" : "text/html"
181
+ } ,
182
+ {
183
+ "title" : "Figshare Download"
184
+ }
185
+ ] ,
186
+ "title" : "Number of reported pertussis cases per week in Japan from 2002 to 2012" ,
187
+ "url" : "http://figshare.com/articles/_Number_of_reported_pertussis_cases_per_week_in_Japan_from_2002_to_2012_/815480" ,
188
+ "abstractNote" : "Pertussis cases are shown by the black line, with each value representing a week of the year. The percentage of adolescent and adult cases (≥15 years old) per year is shown in red circles. The data were obtained from the Ministry of Health, Labor and Welfare of Japan Infectious Disease Surveillance data. Data regarding the number of adolescent and adult cases in 2012 were not available." ,
189
+ "date" : "October 5, 2013" ,
190
+ "DOI" : "doi:10.6084/m9.figshare.815480" ,
191
+ "libraryCatalog" : "Figshare" ,
192
+ "accessDate" : "CURRENT_TIMESTAMP"
193
+ }
194
+ ]
195
+ } ,
196
+ {
197
+ "type" : "web" ,
198
+ "defer" : true ,
199
+ "url" : "http://figshare.com/articles/search?q=labor&quick=1&x=0&y=0" ,
200
+ "items" : "multiple"
201
+ }
202
+ ]
203
+ /** END TEST CASES **/
0 commit comments