{ "translatorID":"e8fc7ebc-b63d-4eb3-a16c-91da232f7220", "translatorType":4, "label":"Aluka", "creator":"Sean Takats", "target":"https?://(?:www\\.)aluka.org/action/(?:showMetadata\\?doi=[^&]+|doSearch\\?|doBrowseResults\\?)", "minVersion":"1.0.0b4.r5", "maxVersion":"", "priority":100, "inRepository":true, "lastUpdated":"2008-02-12 10:00:00" } function detectWeb(doc, url){ var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == 'x') return namespace; else return null; } : null; var xpath = '//a[@class="title"]'; if (url.match(/showMetadata\?doi=[^&]+/)){ return "document"; } else if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { return "multiple"; } } // Aluka types we can import // TODO: Improve support for other Aluka item types? // Correspondence, Circulars, Newsletters, Interviews, Pamphlets, Policy Documents, Posters, Press Releases, Reports, Testimonies, Transcripts var typeMap = { "Books":"book", "Aluka Essays":"report", "photograph":"artwork", "Photographs":"artwork", "Panoramas":"artwork", "Journals (Periodicals)":"journalArticle", "Articles":"journalArticle", "Correspondence":"letter", "Interviews":"interview", "Reports":"report" } function doWeb(doc, url){ var urlString = "http://www.aluka.org/action/showPrimeXML?doi=" ; var uris = new Array(); var m = url.match(/showMetadata\?doi=([^&]+)/); if (m) { //single page uris.push(urlString+ m[1]); } else { //search results page var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == 'x') return namespace; else return null; } : null; var xpath = '//a[@class="title"]'; var items = new Object(); var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); var elmt; while (elmt = elmts.iterateNext()) { var title = elmt.textContent; var link = elmt.href; var m = link.match(/showMetadata\?doi=([^&]+)/); if (title && m){ items[m[1]] = title; } } var items = Zotero.selectItems(items); if(!items) { return true; } for(var i in items) { uris.push(urlString + i); } } // http://www.aluka.org/action/showPrimeXML?doi=10.5555/AL.SFF.DOCUMENT.cbp1008 Zotero.Utilities.HTTP.doGet(uris, function(text) { text = text.replace(/<\?xml[^>]*\?>/, ""); // strip xml header text = text.replace(/(<[^>\.]*)\.([^>]*>)/g, "$1_$2"); // replace dots in tags with underscores var xml = new XML(text); var metadata = xml..MetadataDC; var itemType = "Unknown"; if (metadata.length()){ itemType = "document"; if (metadata[0].Type.length()){ var value = metadata[0].Type[0].text().toString(); if(typeMap[value]) { itemType = typeMap[value]; } else { Zotero.debug("Unmapped Aluka Type: " + value); } } var newItem = new Zotero.Item(itemType); var title = ""; if (metadata[0].Title.length()){ var title = Zotero.Utilities.trimInternal(metadata[0].Title[0].text().toString()); if (title == ""){ title = " "; } newItem.title = title; } if (metadata[0].Title_Alternative.length()){ newItem.extra = Zotero.Utilities.trimInternal(metadata[0].Title_Alternative[0].text().toString()); } for(var i=0; i