-
Notifications
You must be signed in to change notification settings - Fork 785
/
Copy pathREDALYC.js
196 lines (182 loc) · 6.16 KB
/
REDALYC.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
{
"translatorID": "d1ac3b4f-1aa7-4a76-a97e-cf3580a41c37",
"label": "REDALYC",
"creator": "Sebastian Karcher",
"target": "^https?://(www\\.)?redalyc\\.(uaemex\\.mx|org)",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2022-12-23 04:12:43"
}
/*
Translator
Copyright (C) 2013 Sebastian Karcher
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
function detectWeb(doc, url) {
if (url.includes('articulo.oa?id=') || /\/journal\/\d+\/\d+/.test(url)) {
return "journalArticle";
}
else if (getSearchResults(doc, true)) {
return "multiple";
}
return false;
}
function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.getElementsByClassName('contentcard');
for (let row of rows) {
// Single language
let href = attr(row, 'a[ng-if*="article.pdfOtroIdioma=="]', 'href');
// mutliple languages we go to the HTML instead
if (!href) {
href = ZU.xpathText(row, './/a[img[@src="img/formatos-05-html.png"]]/@href');
}
// if all else fails, we go to the linked title
if (!href) {
href = ZU.xpathText(row, './/a[span[@class="title"]]/@href');
}
// Z.debug(href)
let title = text(row, '.title');
if (!href || !title) continue;
if (checkOnly) return true;
found = true;
items[href] = title;
}
return found ? items : false;
}
async function doWeb(doc, url) {
if (detectWeb(doc, url) == 'multiple') {
let items = await Zotero.selectItems(getSearchResults(doc, false));
if (items) {
await Promise.all(
Object.keys(items)
.map(url => requestDocument(url).then(scrape))
);
}
}
else {
await scrape(doc, url);
}
}
async function scrape(doc, url = doc.location.href) {
if (doc.getElementById('visor-cabecera')) {
// we're on a viewer page
var pdfURL = attr(doc, "#impresion-pdf-n", "onclick");
if (pdfURL) {
pdfURL = pdfURL.replace("window.open('", "").replace("')", "");
}
Z.debug(pdfURL);
}
let translator = Zotero.loadTranslator('web');
// Embedded Metadata
translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48');
translator.setDocument(doc);
translator.setHandler('itemDone', (_obj, item) => {
if (item.title == item.title.toUpperCase()) {
item.title = ZU.capitalizeTitle(item.title.toLowerCase(), true);
}
if (pdfURL) {
item.attachments = [{ url: pdfURL, title: "Full Text PDF", mimeType: "application/pdf" }];
}
item.complete();
});
let em = await translator.getTranslatorObject();
em.itemType = 'journalArticle';
await em.doWeb(doc, url);
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "https://www.redalyc.org/articulo.oa?id=32921102001",
"items": [
{
"itemType": "journalArticle",
"title": "Os partidos políticos brasileiros realmente não importam?",
"creators": [
{
"firstName": "Maria do Socorro Sousa",
"lastName": "Braga",
"creatorType": "author"
},
{
"firstName": "Jairo Pimentel",
"lastName": "Jr",
"creatorType": "author"
}
],
"date": "2011",
"ISSN": "0104-6276, 1807-0191",
"abstractNote": "Há décadas a constatação corrente no Brasil é de que os partidos pouco importam para explicar o comportamento dos eleitores brasileiros. Entretanto, esse cenário de baixa identificação partidária contrasta com a observação de que, ao menos para as eleições presidenciais a competição eleitoral tem se estruturado em torno de duas organizações partidárias: PT e PSDB. O objetivo deste artigo é demonstrar que mesmo que os partidos de fato não estejam internalizados em termos de identidade partidária, estamos vivenciando importante movimento no sentido de uma divisão do eleitorado entre as duas principais organizações políticas em termos de simpatia partidária, redundando na estruturação de um sistema bipartidário ao nível da disputa nacional. Com base nas respostas dos entrevistados do ESEB 2002, 2006 e 2010 sobre as eleições presidências verificamos que nesses pleitos as simpatias eleitorais pelo PT e PSDB se mostraram um dos principais componentes de explicação do voto nos candidatos. Este artigo também destacou que apesar das simpatias partidárias serem uma heurística utilizada para decisão do voto entre os eleitores com maior escolaridade, foi possível observar que mesmo entre os menos escolarizados essa variável foi fundamental para explicar o voto, evidenciando que mesmo entre eleitores com menor conhecimento político, os partidos têm auxiliado na decisão do voto.",
"issue": "2",
"language": "Portugués",
"libraryCatalog": "www.redalyc.org",
"pages": "271-303",
"publicationTitle": "Opinião Pública",
"url": "https://www.redalyc.org/articulo.oa?id=32921102001",
"volume": "17",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [
{
"tag": "CSES-ESEB2010"
},
{
"tag": "ESEB2010"
},
{
"tag": "Partidos políticos"
},
{
"tag": "Political parties"
},
{
"tag": "comportamento eleitoral"
},
{
"tag": "electoral behavior"
},
{
"tag": "eleições presidenciais"
},
{
"tag": "party sympathy"
},
{
"tag": "presidential elections"
},
{
"tag": "simpatia partidária"
}
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"defer": true,
"url": "https://www.redalyc.org/busquedaArticuloFiltros.oa?q=piqueteros",
"items": "multiple"
}
]
/** END TEST CASES **/