-
Notifications
You must be signed in to change notification settings - Fork 785
/
Copy pathIngentaConnect.js
312 lines (298 loc) · 9.98 KB
/
IngentaConnect.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
{
"translatorID": "9e306d5d-193f-44ae-9dd6-ace63bf47689",
"label": "IngentaConnect",
"creator": "Michael Berkowitz",
"target": "^https?://(www\\.)?ingentaconnect\\.com",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2022-07-12 05:41:32"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2020 Michael Berkowitz
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 *****
*/
// attr()/text() v2
// eslint-disable-next-line
function attr(docOrElem,selector,attr,index){var elem=index?docOrElem.querySelectorAll(selector).item(index):docOrElem.querySelector(selector);return elem?elem.getAttribute(attr):null;}function text(docOrElem,selector,index){var elem=index?docOrElem.querySelectorAll(selector).item(index):docOrElem.querySelector(selector);return elem?elem.textContent:null;}
function detectWeb(doc, url) {
if (url.includes("article?") || url.includes("article;") || url.includes("/art")) {
return "journalArticle";
}
// permalinks
else if (url.includes("/content/") && getRisUrl(doc)) {
return "journalArticle";
}
else if ((url.includes("search")) && getSearchResults(doc)) {
return "multiple";
}
return false;
}
function getSearchResults(doc) {
var items = {}, found = false;
var rows = doc.getElementsByClassName('searchResultTitle');
for (var i = 0; i < rows.length; i++) {
var id = ZU.xpathText(rows[i], './a/@href');
var title = ZU.xpathText(rows[i], './a/@title');
if (!id || !title) {
continue;
}
else {
found = true;
items[id] = title;
}
}
return found ? items : false;
}
function doWeb(doc, url) {
if (detectWeb(doc, url) == "multiple") {
Zotero.selectItems(getSearchResults(doc, false), function (items) {
if (!items) {
return;
}
var articles = [];
for (var i in items) {
articles.push(i);
}
ZU.processDocuments(articles, scrape);
});
}
else {
scrape(doc, url);
}
}
function getRisUrl(doc) {
return ZU.xpathText(doc, '//div[contains(@class,"export-formats")]/ul/li/a[contains(text(), "EndNote")]/@href');
}
function scrape(newDoc, url) {
var abs;
var risurl = getRisUrl(newDoc);
if (ZU.xpathText(newDoc, '//div[@id="abstract"]')) {
abs = Zotero.Utilities.trimInternal(ZU.xpathText(newDoc, '//div[@id="abstract"]')).substr(10);
}
var pdf = attr(newDoc, 'a.fulltext.pdf', 'data-popup');
if (!pdf) {
Z.debug("PDF URL not found - constructing from main URL");
pdf = url
.replace(/[?&#;].*/, '')
.replace('/content/', '/search/download?pub=infobike://')
+ '&mimetype=application/pdf&host=https://www.ingentaconnect.com';
}
if (ZU.xpathText(newDoc, '//div[@id="info"]/p[1]/a')) {
var keywords = ZU.xpathText(newDoc, '//div[@id="info"]/p[1]/a');
var key;
var keys = [];
while (key == keywords.iterateNext()) {
keys.push(Zotero.Utilities.capitalizeTitle(key.textContent, true));
}
}
Zotero.Utilities.HTTP.doGet(risurl, function (text) {
// fix spacing per spec
text = text.replace(/([A-Z0-9]{2}) ?-/g, "$1 -");
// Zotero.debug(text);
text = text.replace(/(PY\s+-\s+)\/+/, "$1");
text = text.replace(/ER\s\s-/, "") + "\nER - ";
var translator = Zotero.loadTranslator("import");
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
translator.setString(text);
translator.setHandler("itemDone", function (obj, item) {
if (abs) item.abstractNote = abs;
if (pdf) item.attachments.push({ url: pdf, title: "IngentaConnect Full Text PDF", mimeType: "application/pdf" });
// Note that the RIS translator gives us a link to the record already
item.url = null;
if (keys) item.tags = keys;
if (item.date) item.date = item.date.replace(/T00:00:00\/*/, "");
if (item.DOI) {
if (item.DOI.match(/^doi:/)) {
item.DOI = item.DOI.substr(4);
}
}
item.complete();
});
translator.translate();
});
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "https://www.ingentaconnect.com/search%3bjsessionid=296g394n0j012.alice?form_name=quicksearch&ie=%25E0%25A5%25B0&value1=argentina&option1=tka&x=0&y=0",
"items": "multiple"
},
{
"type": "web",
"url": "https://www.ingentaconnect.com/content/tpp/ep/2014/00000010/00000001/art00001",
"items": [
{
"itemType": "journalArticle",
"title": "Strategies for enabling the use of research evidence",
"creators": [
{
"lastName": "Gough",
"firstName": "David",
"creatorType": "author"
},
{
"lastName": "Boaz",
"firstName": "Annette",
"creatorType": "author"
}
],
"date": "2014-01-01",
"DOI": "10.1332/174426413X13836441441630",
"issue": "1",
"journalAbbreviation": "Evidence & Policy: A Journal of Research, Debate and Practice",
"libraryCatalog": "IngentaConnect",
"pages": "3-4",
"publicationTitle": "Evidence & Policy: A Journal of Research, Debate and Practice",
"volume": "10",
"attachments": [
{
"title": "IngentaConnect Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.ingentaconnect.com/search/article?option1=title&value1=credibility+associated+with+how+often+they+present+research+evidence+to+public+or+partly+government-owned+organisations&sortDescending=true&sortField=default&pageSize=10&index=1",
"items": [
{
"itemType": "journalArticle",
"title": "Are indicators of faculty members' credibility associated with how often they present research evidence to public or partly government-owned organisations? A cross-sectional survey",
"creators": [
{
"lastName": "Ouimet",
"firstName": "Mathieu",
"creatorType": "author"
},
{
"lastName": "Bédard",
"firstName": "Pierre-Olivier",
"creatorType": "author"
},
{
"lastName": "Léon",
"firstName": "Grégory",
"creatorType": "author"
},
{
"lastName": "Dagenais",
"firstName": "Christian",
"creatorType": "author"
}
],
"date": "2014-01-01",
"DOI": "10.1332/174426413X662699",
"abstractNote": "This study provides an empirical test of the assumption that the credibility of the messenger is one of the factors that influence knowledge mobilisation among policy makers. This general hypothesis was tested using a database of 321 social scientists from the province of Quebec that\ncombines survey and bibliometric data. A regression model was used to study the association between indicators of faculty members' credibility and the number of times they have presented research evidence to public or partly government-owned organisations over an 18-month period. Overall,\nempirical results provide new evidence supporting the credibility hypothesis.",
"issue": "1",
"journalAbbreviation": "Evidence & Policy: A Journal of Research, Debate and Practice",
"libraryCatalog": "IngentaConnect",
"pages": "5-27",
"publicationTitle": "Evidence & Policy: A Journal of Research, Debate and Practice",
"shortTitle": "Are indicators of faculty members' credibility associated with how often they present research evidence to public or partly government-owned organisations?",
"volume": "10",
"attachments": [
{
"title": "IngentaConnect Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [
{
"tag": "CREDIBILITY"
},
{
"tag": "CROSS-SECTIONAL SURVEY"
},
{
"tag": "FACULTY MEMBERS"
},
{
"tag": "KNOWLEDGE TRANSFER"
}
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.ingentaconnect.com/search/article?option1=tka&value1=search&pageSize=10&index=1",
"items": [
{
"itemType": "journalArticle",
"title": "Search engine optimisation in 2017: A new world where old rules still matter",
"creators": [
{
"lastName": "Alpert",
"firstName": "Brian",
"creatorType": "author"
}
],
"date": "2017-03-01",
"abstractNote": "The ability for website content to be found on search engines has always been a concern for anyone managing a website. Search has evolved, however, and improving ‘findability’ means more today than ever, in no small part due to the sophisticated technologies underpinning\ntoday’s search engines. This paper discusses the current state of search, provides an overview of still-important variables and techniques for search engine optimisation, and discusses newer, important considerations. Also discussed are priorities for relaunching an existing site (or\nlaunching a new one), and a look at current trends that illuminate where things are heading.",
"issue": "1",
"journalAbbreviation": "Journal of Digital & Social Media Marketing",
"libraryCatalog": "IngentaConnect",
"pages": "39-60",
"publicationTitle": "Journal of Digital & Social Media Marketing",
"shortTitle": "Search engine optimisation in 2017",
"volume": "5",
"attachments": [
{
"title": "IngentaConnect Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [
{
"tag": "SEO"
},
{
"tag": "engine"
},
{
"tag": "findability"
},
{
"tag": "marketing"
},
{
"tag": "optimisation"
},
{
"tag": "rank"
},
{
"tag": "search"
}
],
"notes": [],
"seeAlso": []
}
]
}
]
/** END TEST CASES **/