Add Chrome/Safari-compatible PubMed
This commit is contained in:
parent
3b2cc93269
commit
3dcb45d6ac
|
@ -4,12 +4,13 @@
|
||||||
"label":"NCBI PubMed",
|
"label":"NCBI PubMed",
|
||||||
"creator":"Simon Kornblith, Michael Berkowitz, Avram Lyon, and Rintze Zelle",
|
"creator":"Simon Kornblith, Michael Berkowitz, Avram Lyon, and Rintze Zelle",
|
||||||
"target":"https?://[^/]*(www|preview)\\.ncbi\\.nlm\\.nih\\.gov[^/]*/(pubmed|sites/pubmed|sites/entrez|entrez/query\\.fcgi\\?.*db=PubMed)",
|
"target":"https?://[^/]*(www|preview)\\.ncbi\\.nlm\\.nih\\.gov[^/]*/(pubmed|sites/pubmed|sites/entrez|entrez/query\\.fcgi\\?.*db=PubMed)",
|
||||||
"minVersion":"2.1b1",
|
"minVersion":"2.1.9",
|
||||||
"maxVersion":"",
|
"maxVersion":"",
|
||||||
"priority":100,
|
"priority":100,
|
||||||
|
"browserSupport":"gcs",
|
||||||
"configOptions":{"dataMode":"block"},
|
"configOptions":{"dataMode":"block"},
|
||||||
"inRepository":true,
|
"inRepository":true,
|
||||||
"lastUpdated":"2011-04-25 18:05:00"
|
"lastUpdated":"2011-07-01 04:22:03"
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectWeb(doc, url) {
|
function detectWeb(doc, url) {
|
||||||
|
@ -91,9 +92,6 @@ function detectImport() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function doImportFromText(text) {
|
function doImportFromText(text) {
|
||||||
// Remove xml parse instruction and doctype
|
|
||||||
text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, "");
|
|
||||||
|
|
||||||
if (!text.substr(0,1000).match(/<PubmedArticleSet>/)) {
|
if (!text.substr(0,1000).match(/<PubmedArticleSet>/)) {
|
||||||
// Pubmed data in the wild, perhaps copied from the web site's search results,
|
// Pubmed data in the wild, perhaps copied from the web site's search results,
|
||||||
// can be missing the <PubmedArticleSet> root tag. Let's add a pair!
|
// can be missing the <PubmedArticleSet> root tag. Let's add a pair!
|
||||||
|
@ -101,28 +99,30 @@ function doImportFromText(text) {
|
||||||
text = "<PubmedArticleSet>" + text + "</PubmedArticleSet>";
|
text = "<PubmedArticleSet>" + text + "</PubmedArticleSet>";
|
||||||
}
|
}
|
||||||
|
|
||||||
var xml = new XML(text);
|
// parse XML with DOMParser
|
||||||
|
var parser = new DOMParser();
|
||||||
|
var doc = parser.parseFromString(text, "text/xml");
|
||||||
|
|
||||||
for(var i=0; i<xml.PubmedArticle.length(); i++) {
|
var articles = ZU.xpath(doc, '/PubmedArticleSet/PubmedArticle');
|
||||||
|
for(var i in articles) {
|
||||||
var newItem = new Zotero.Item("journalArticle");
|
var newItem = new Zotero.Item("journalArticle");
|
||||||
|
|
||||||
var citation = xml.PubmedArticle[i].MedlineCitation;
|
var citation = ZU.xpath(articles[i], 'MedlineCitation');
|
||||||
|
var PMID = ZU.xpathText(citation, 'PMID');
|
||||||
var PMID = citation.PMID.text().toString();
|
|
||||||
newItem.url = "http://www.ncbi.nlm.nih.gov/pubmed/" + PMID;
|
newItem.url = "http://www.ncbi.nlm.nih.gov/pubmed/" + PMID;
|
||||||
newItem.extra = "PMID: "+PMID;
|
newItem.extra = "PMID: "+PMID;
|
||||||
|
|
||||||
var article = citation.Article;
|
var article = ZU.xpath(citation, 'Article');
|
||||||
if(article.ArticleTitle.length()) {
|
var title = ZU.xpathText(article, 'ArticleTitle');
|
||||||
var title = article.ArticleTitle.text().toString();
|
if(title) {
|
||||||
if(title.substr(-1) == ".") {
|
if(title.substr(-1) == ".") {
|
||||||
title = title.substring(0, title.length-1);
|
title = title.substring(0, title.length-1);
|
||||||
}
|
}
|
||||||
newItem.title = title;
|
newItem.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (article.Pagination.MedlinePgn.length()){
|
var fullPageRange = ZU.xpathText(article, 'Pagination/MedlinePgn');
|
||||||
var fullPageRange = article.Pagination.MedlinePgn.text().toString();
|
if(fullPageRange) {
|
||||||
var pageRange = fullPageRange.match(/\d+-\d+/g);
|
var pageRange = fullPageRange.match(/\d+-\d+/g);
|
||||||
for (var j in pageRange) {
|
for (var j in pageRange) {
|
||||||
var pageRangeStart = pageRange[j].match(/^\d+/)[0];
|
var pageRangeStart = pageRange[j].match(/^\d+/)[0];
|
||||||
|
@ -135,75 +135,87 @@ function doImportFromText(text) {
|
||||||
newItem.pages = fullPageRange;
|
newItem.pages = fullPageRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(article.Journal.length()) {
|
var journal = ZU.xpath(article, 'Journal');
|
||||||
var issn = article.Journal.ISSN.text().toString();
|
if(journal.length) {
|
||||||
if(issn) {
|
newItem.ISSN = ZU.xpathText(journal, 'ISSN');
|
||||||
newItem.ISSN = issn;
|
|
||||||
|
var abbreviation;
|
||||||
|
if((abbreviation = ZU.xpathText(journal, 'ISOAbbreviation'))) {
|
||||||
|
newItem.journalAbbreviation = abbreviation;
|
||||||
|
} else if((abbreviation = ZU.xpathText(journal, 'MedlineTA'))) {
|
||||||
|
newItem.journalAbbreviation = abbreviation;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(citation.Article.Journal.ISOAbbreviation.length()) {
|
var title = ZU.xpathText(journal, 'Title');
|
||||||
newItem.journalAbbreviation = Zotero.Utilities.superCleanString(citation.Article.Journal.ISOAbbreviation.text().toString());
|
if(title) {
|
||||||
} else if(citation.MedlineJournalInfo.MedlineTA.length()) {
|
newItem.publicationTitle = title;
|
||||||
newItem.journalAbbreviation = Zotero.Utilities.superCleanString(citation.MedlineJournalInfo.MedlineTA.text().toString());
|
} else if(newItem.journalAbbreviation) {
|
||||||
}
|
|
||||||
|
|
||||||
if(article.Journal.Title.length()) {
|
|
||||||
newItem.publicationTitle = Zotero.Utilities.superCleanString(article.Journal.Title.text().toString());
|
|
||||||
} else if(newItem.journalAbbreviation.length()) {
|
|
||||||
newItem.publicationTitle = newItem.journalAbbreviation;
|
newItem.publicationTitle = newItem.journalAbbreviation;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(article.Journal.JournalIssue.length()) {
|
var journalIssue = ZU.xpath(journal, 'JournalIssue');
|
||||||
newItem.volume = article.Journal.JournalIssue.Volume.text().toString();
|
if(journalIssue.length) {
|
||||||
newItem.issue = article.Journal.JournalIssue.Issue.text().toString();
|
newItem.volume = ZU.xpathText(journalIssue, 'Volume');
|
||||||
if(article.Journal.JournalIssue.PubDate.length()) { // try to get the date
|
newItem.issue = ZU.xpathText(journalIssue, 'Issue');
|
||||||
if(article.Journal.JournalIssue.PubDate.Day.text().toString() != "") {
|
var pubDate = ZU.xpath(journalIssue, 'PubDate');
|
||||||
newItem.date = article.Journal.JournalIssue.PubDate.Month.text().toString()+" "+article.Journal.JournalIssue.PubDate.Day.text().toString()+", "+article.Journal.JournalIssue.PubDate.Year.text().toString();
|
if(pubDate.length) { // try to get the date
|
||||||
} else if(article.Journal.JournalIssue.PubDate.Month.text().toString() != "") {
|
var day = ZU.xpathText(pubDate, 'Day');
|
||||||
newItem.date = article.Journal.JournalIssue.PubDate.Month.text().toString()+" "+article.Journal.JournalIssue.PubDate.Year.text().toString();
|
var month = ZU.xpathText(pubDate, 'Month');
|
||||||
} else if(article.Journal.JournalIssue.PubDate.Year.text().toString() != "") {
|
var year = ZU.xpathText(pubDate, 'Year');
|
||||||
newItem.date = article.Journal.JournalIssue.PubDate.Year.text().toString();
|
|
||||||
} else if(article.Journal.JournalIssue.PubDate.MedlineDate.text().toString() != "") {
|
if(day) {
|
||||||
newItem.date = article.Journal.JournalIssue.PubDate.MedlineDate.text().toString();
|
newItem.date = month+" "+day+", "+year;
|
||||||
|
} else if(month) {
|
||||||
|
newItem.date = month+" "+year;
|
||||||
|
} else if(year) {
|
||||||
|
newItem.date = year;
|
||||||
|
} else {
|
||||||
|
newItem.date = ZU.xpathText(pubDate, 'MedlineDate');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(article.AuthorList.length() && article.AuthorList.Author.length()) {
|
var authors = ZU.xpath(article, 'AuthorList/Author');
|
||||||
var authors = article.AuthorList.Author;
|
for(var j in authors) {
|
||||||
for(var j=0; j<authors.length(); j++) {
|
var author = authors[j];
|
||||||
var lastName = authors[j].LastName.text().toString();
|
|
||||||
var firstName = authors[j].FirstName.text().toString();
|
var lastName = ZU.xpathText(author, 'LastName');
|
||||||
if(firstName == "") {
|
var firstName = ZU.xpathText(author, 'FirstName');
|
||||||
firstName = authors[j].ForeName.text().toString();
|
if(!firstName) {
|
||||||
}
|
firstName = ZU.xpathText(author, 'ForeName');
|
||||||
var suffix = authors[j].Suffix.text().toString();
|
}
|
||||||
if(suffix && firstName != "") {
|
var suffix = ZU.xpathText(author, 'Suffix');
|
||||||
firstName += ", " + authors[j].Suffix.text().toString();
|
if(suffix && firstName) {
|
||||||
}
|
firstName += ", " + suffix
|
||||||
if(firstName || lastName) {
|
}
|
||||||
newItem.creators.push({lastName:lastName, firstName:firstName});
|
if(firstName || lastName) {
|
||||||
}
|
newItem.creators.push({lastName:lastName, firstName:firstName});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (citation.MeshHeadingList && citation.MeshHeadingList.MeshHeading) {
|
var keywords = ZU.xpath(citation, 'MeshHeadingList/MeshHeading');
|
||||||
var keywords = citation.MeshHeadingList.MeshHeading;
|
for(var k in keywords) {
|
||||||
for (var k = 0 ; k < keywords.length() ; k++) {
|
newItem.tags.push(ZU.xpathText(keywords[k], 'DescriptorName'));
|
||||||
newItem.tags.push(keywords[k].DescriptorName.text().toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// We use a regex to remove the section labels
|
|
||||||
// also, we have entities to clear up
|
|
||||||
newItem.abstractNote = Zotero.Utilities.unescapeHTML(
|
|
||||||
article.Abstract.AbstractText.toString()
|
|
||||||
.replace(/<\/?AbstractText\s*(?:Label=")?([^">]+)?[^>]*>/g, "$1\n")
|
|
||||||
);
|
|
||||||
|
|
||||||
newItem.DOI = xml.PubmedArticle[i].PubmedData.ArticleIdList.ArticleId.(@IdType == "doi" ).text().toString();
|
var abstractSections = ZU.xpath(article, 'Abstract/AbstractText');
|
||||||
newItem.publicationTitle = Zotero.Utilities.capitalizeTitle(newItem.publicationTitle);
|
var abstractNote = [];
|
||||||
|
for(var j in abstractSections) {
|
||||||
|
var abstractSection = abstractSections[j];
|
||||||
|
if(abstractSection.hasAttribute("Label")) {
|
||||||
|
abstractNote.push(abstractSection.getAttribute("Label"));
|
||||||
|
}
|
||||||
|
abstractNote.push(abstractSection.textContent+"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
newItem.abstractNote = abstractNote.join("\n\n");
|
||||||
|
newItem.DOI = ZU.xpathText(articles[i], 'PubmedData/ArticleIdList/ArticleId[@IdType="doi"]');
|
||||||
|
// (do we want this?)
|
||||||
|
if(newItem.publicationTitle) {
|
||||||
|
newItem.publicationTitle = Zotero.Utilities.capitalizeTitle(newItem.publicationTitle);
|
||||||
|
}
|
||||||
newItem.complete();
|
newItem.complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,17 +250,17 @@ function doWeb(doc, url) {
|
||||||
items[uid.value] = article.textContent;
|
items[uid.value] = article.textContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
items = Zotero.selectItems(items);
|
Zotero.selectItems(items, function(items) {
|
||||||
|
if(!items) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if(!items) {
|
for(var i in items) {
|
||||||
return true;
|
ids.push(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var i in items) {
|
lookupPMIDs(ids);
|
||||||
ids.push(i);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
lookupPMIDs(ids);
|
|
||||||
} else {
|
} else {
|
||||||
ids.push(uid.value);
|
ids.push(uid.value);
|
||||||
lookupPMIDs(ids, doc);
|
lookupPMIDs(ids, doc);
|
||||||
|
@ -293,3 +305,55 @@ function doSearch(item) {
|
||||||
// pmid was defined earlier in detectSearch
|
// pmid was defined earlier in detectSearch
|
||||||
lookupPMIDs([getPMID(item.contextObject)]);
|
lookupPMIDs([getPMID(item.contextObject)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** BEGIN TEST CASES **/
|
||||||
|
var testCases = [
|
||||||
|
{
|
||||||
|
"type": "web",
|
||||||
|
"url": "http://www.ncbi.nlm.nih.gov/pubmed/20729678",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"itemType": "journalArticle",
|
||||||
|
"creators": [
|
||||||
|
{
|
||||||
|
"lastName": "Coar",
|
||||||
|
"firstName": "Jaekea T"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"lastName": "Sewell",
|
||||||
|
"firstName": "Jeanne P"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"notes": [],
|
||||||
|
"tags": [
|
||||||
|
"Bibliography as Topic",
|
||||||
|
"Database Management Systems",
|
||||||
|
"Humans"
|
||||||
|
],
|
||||||
|
"seeAlso": [],
|
||||||
|
"attachments": [],
|
||||||
|
"url": "http://www.ncbi.nlm.nih.gov/pubmed/20729678",
|
||||||
|
"extra": "PMID: 20729678",
|
||||||
|
"title": "Zotero: harnessing the power of a personal bibliographic manager",
|
||||||
|
"pages": "205-207",
|
||||||
|
"ISSN": "1538-9855",
|
||||||
|
"journalAbbreviation": "Nurse Educ",
|
||||||
|
"publicationTitle": "Nurse Educator",
|
||||||
|
"volume": "35",
|
||||||
|
"issue": "5",
|
||||||
|
"date": "2010 Sep-Oct",
|
||||||
|
"abstractNote": "Zotero is a powerful free personal bibliographic manager (PBM) for writers. Use of a PBM allows the writer to focus on content, rather than the tedious details of formatting citations and references. Zotero 2.0 (http://www.zotero.org) has new features including the ability to synchronize citations with the off-site Zotero server and the ability to collaborate and share with others. An overview on how to use the software and discussion about the strengths and limitations are included.\u000a",
|
||||||
|
"DOI": "10.1097/NNE.0b013e3181ed81e4",
|
||||||
|
"libraryCatalog": "NCBI PubMed",
|
||||||
|
"shortTitle": "Zotero"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "web",
|
||||||
|
"url": "http://www.ncbi.nlm.nih.gov/pubmed?term=zotero",
|
||||||
|
"items": "multiple"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
/** END TEST CASES **/
|
Loading…
Reference in New Issue
Block a user