-
Notifications
You must be signed in to change notification settings - Fork 0
/
Archive Ouverte en Sciences de l'Information et de la Communication (AOSIC).js
75 lines (72 loc) · 2.12 KB
/
Archive Ouverte en Sciences de l'Information et de la Communication (AOSIC).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
{
"translatorID":"dedcae51-073c-48fb-85ce-2425e97f128d",
"translatorType":4,
"label":"Archive Ouverte en Sciences de l'Information et de la Communication (AOSIC)",
"creator":"Michael Berkowitz",
"target":"http://archivesic.ccsd.cnrs.fr/",
"minVersion":"1.0.0b4.r5",
"maxVersion":"",
"priority":100,
"inRepository":true,
"lastUpdated":"2009-01-08 08:19:07"
}
function detectWeb(doc, url) {
if (doc.title.toLowerCase().match("fulltext search")) {
return "multiple";
} else if (url.match(/sic_\d+/)) {
return "journalArticle";
}
}
var metaTags = {
"DC.relation":"url",
"DC.date":"date",
"DC.description":"abstractNote",
"DC.creator":"creators",
"DC.title":"title"
}
function doWeb(doc, url) {
var articles = new Array();
if (detectWeb(doc, url) == "multiple") {
var items = Zotero.Utilities.getItemArray(doc, doc, /sic_\d+\/fr\//);
items = Zotero.selectItems(items)
for (var i in items) {
articles.push(i);
}
} else {
articles = [url];
}
Zotero.Utilities.processDocuments(articles, function(doc) {
var xpath = '//meta[@name]';
var data = new Object();
var metas = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null);
var meta;
while (meta = metas.iterateNext()) {
if (data[meta.name]) {
data[meta.name] = data[meta.name] + ";" + meta.content;
} else {
data[meta.name] = meta.content;
}
}
Zotero.debug(data);
var item = new Zotero.Item("journalArticle");
for (var tag in metaTags) {
if (tag == "DC.creator") {
var authors = data['DC.creator'].split(";");
for each (var aut in authors) {
aut = aut.replace(/^([^,]+),\s+(.*)$/, "$2 $1");
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author"));
}
} else {
item[metaTags[tag]] = data[tag];
}
}
var pdfurl = doc.evaluate('//a[contains(@href, ".pdf")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href.match(/url=([^&]+)&/)[1];
Zotero.debug(pdfurl);
item.attachments = [
{url:item.url, title:"AOSIC Snapshot", mimeType:"text/html"},
{url:pdfurl, title:"AOSIC Full Text PDF", mimeType:"application/pdf"}
];
item.complete();
}, function() {Zotero.done();});
Zotero.wait();
}