forked from zotero/translators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AMS Journals.js
154 lines (151 loc) · 5.64 KB
/
AMS Journals.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
{
"translatorID": "bdaac15c-b0ee-453f-9f1d-f35d00c7a994",
"label": "AMS Journals",
"creator": "Michael Berkowitz",
"target": "^https?://www\\.ams\\.org/",
"minVersion": "1.0.0b4.r5",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsib",
"lastUpdated": "2012-03-03 11:27:05"
}
function detectWeb(doc, url) {
if (url.match(/home\.html/)) {
return "journalArticle";
}
else if (url.match(/jour(nals|search)/)) {
return "multiple";
}
}
function doWeb(doc, url) {
var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
if (prefix == 'x') return namespace; else return null;
} : null;
var articles = new Array();
if (detectWeb(doc, url) == "multiple") {
var items = new Object();
if (url.match(/joursearch/)) {
var titlex = '//table/tbody/tr/td/span[@class="searchResultsArticleTitle"]';
var linkx = '//a[@class="searchResultsAbstractLink"]';
} else {
var titlex = '//div[@class="contentList"]/dl/dt[@class="articleTitleInAbstract"]';
var linkx = '//div[@class="contentList"]/dl/dd/a[contains(text(), "Abstract")]'
}
var titles = doc.evaluate(titlex, doc, nsResolver, XPathResult.ANY_TYPE, null);
var links = doc.evaluate(linkx, doc, nsResolver, XPathResult.ANY_TYPE, null);
var title, link;
while ((title = titles.iterateNext()) && (link = links.iterateNext())) {
items[link.href] = Zotero.Utilities.trimInternal(title.textContent);
}
Zotero.selectItems(items, function (items) {
if (!items) {
return true;
}
for (var i in items) {
articles.push(i);
}
ZU.processDocuments(articles, scrape, function () {Zotero.done();});
Zotero.wait();
});
} else {
scrape(doc, url)
}
}
function scrape(doc, url){
var item = new Zotero.Item("journalArticle");
item.publicationTitle = doc.title;
item.ISSN = ZU.xpathText(doc, '//span[@class="journalISSN"]').match(/\(e\)\s+ISSN:?\s+(.*)\(p\)/)[1];
item.title = Zotero.Utilities.trimInternal(ZU.xpathText(doc, '//p[@class="articleTitle"]'));
item.url = doc.location.href.replace(/\.html.+/, ".html");
var data = Zotero.Utilities.trimInternal(ZU.xpathText(doc, '//p[span[@class="bibDataTag"]][1]'));
data = data.replace(/(Journal|MSC|Posted|Retrieve)/g, "\n$1");
Zotero.debug(data);
var authors = data.match(/(Author\(s\):\s+(.*)\n|Author(s)?:\s+(.*))/)[1].replace(/Author\(s\):|Authors?:/, "").split(/;\s+| and |, /);
for each (var aut in authors) {
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author"));
}
var journalinfo = data.match(/Journal:\s+(.*)\n/)[1].match(/^([^\d]+)(\d+)\s+\((\d+)\),\s+(.*)$|\n/);
//the string isn't complete for recent articles w/o volume and issue infor
if (journalinfo){
item.journalAbbreviation = Zotero.Utilities.trimInternal(journalinfo[1]);
item.volume = journalinfo[2];
item.pages = journalinfo[4];
item.issue = item.url.match(/(\d+)\/S/)[1];
}
else {
var journalabr = data.match(/Journal:\s+(.*)/);
item.journalAbbreviation = Zotero.Utilities.trimInternal(journalinfo[1]); }
item.date = Zotero.Utilities.trimInternal(data.match(/Posted:\s+(.*)(\n|Full)/)[1]);
var pdfurl = item.url.replace(/([^/]+)\/home.html$/, "$1/$1.pdf");
item.attachments = [
{url:item.url, title:item.journalAbbreviation + " Snapshot", mimeType:"text/html"},
{url:pdfurl, title:item.journalAbbreviation + " PDF", mimeType:"application/pdf"}
];
item.abstractNote = ZU.trimInternal(ZU.xpathText(doc, '//td[@class="bottomCell"]/p[4]').substr(10)).replace(/^A?bstract:\s/, "");
item.complete();
}/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"defer": true,
"url": "http://www.ams.org/journals/jams/2012-25-01/",
"items": "multiple"
},
{
"type": "web",
"url": "http://www.ams.org/journals/jams/2012-25-01/S0894-0347-2011-00713-3/home.html",
"items": [
{
"itemType": "journalArticle",
"creators": [
{
"firstName": "Carles",
"lastName": "Broto",
"creatorType": "author"
},
{
"firstName": "Jesper M.",
"lastName": "Møller",
"creatorType": "author"
},
{
"firstName": "Bob",
"lastName": "Oliver",
"creatorType": "author"
}
],
"notes": [],
"tags": [],
"seeAlso": [],
"attachments": [
{
"url": "http://www.ams.org/journals/jams/2012-25-01/S0894-0347-2011-00713-3/home.html",
"title": "J. Amer. Math. Soc. Snapshot",
"mimeType": "text/html"
},
{
"url": "http://www.ams.org/journals/jams/2012-25-01/S0894-0347-2011-00713-3/S0894-0347-2011-00713-3.pdf",
"title": "J. Amer. Math. Soc. PDF",
"mimeType": "application/pdf"
}
],
"publicationTitle": "Journal of the American Mathematical Society",
"ISSN": "0894-0347",
"title": "Equivalences between fusion systems of finite groups of Lie type",
"url": "http://www.ams.org/journals/jams/2012-25-01/S0894-0347-2011-00713-3/home.html",
"journalAbbreviation": "J. Amer. Math. Soc.",
"volume": "25",
"pages": "1-20",
"issue": "01",
"date": "July 8, 2011",
"abstractNote": "We prove, for certain pairs of finite groups of Lie type, that the -fusion systems and are equivalent. In other words, there is an isomorphism between a Sylow -subgroup of and one of which preserves -fusion. This occurs, for example, when and for a simple Lie ``type'' , and and are prime powers, both prime to , which generate the same closed subgroup of -adic units. Our proof uses homotopy-theoretic properties of the -completed classifying spaces of and , and we know of no purely algebraic proof of this result.",
"libraryCatalog": "AMS Journals",
"accessDate": "CURRENT_TIMESTAMP"
}
]
}
]
/** END TEST CASES **/