From 986fea0b03e567091291e4ffcc5b0e1a5be1a030 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 13 Dec 2006 03:18:57 +0000 Subject: [PATCH] -closes #365, update import/export/bibliography to handle new item types. any fields I couldn't find in an existing RDF ontology use the Zotero namespace. we still have to decide if primary creators should be mapped to "author" in the RDF, and translated back out later (currently they aren't). -adds Zotero.Utilities.getCreatorsForType to Zotero utilities -makes CiteBase search translator error more gracefully --- chrome/content/zotero/xpcom/utilities.js | 12 + scrapers.sql | 547 ++++++++++++----------- 2 files changed, 292 insertions(+), 267 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index b2ed05ddae..980e8dcea3 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -217,6 +217,18 @@ Zotero.Utilities.prototype.itemTypeExists = function(type) { } } +/* + * returns an array of all (string) creatorTypes valid for a (string) itemType + */ +Zotero.Utilities.prototype.getCreatorsForType = function(type) { + var types = Zotero.CreatorTypes.getTypesForItemType(Zotero.ItemTypes.getID(type)); + var cleanTypes = new Array(); + for each(var type in types) { + cleanTypes.push(type.name); + } + return cleanTypes; +} + /* * Cleans a title, capitalizing the proper words and replacing " :" with ":" */ diff --git a/scrapers.sql b/scrapers.sql index 9f3d014527..9d8b71ba2f 100644 --- a/scrapers.sql +++ b/scrapers.sql @@ -1,4 +1,4 @@ --- 121 +-- 122 -- ***** BEGIN LICENSE BLOCK ***** -- @@ -22,7 +22,7 @@ -- Set the following timestamp to the most recent scraper update date -REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-12-11 18:37:00')); +REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-12-12 22:10:00')); REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b3.r1', '', '2006-12-11 11:24:00', 1, 100, 4, 'Amazon', 'Sean Takats', '^http://(?:www\.)amazon', 'function detectWeb(doc, url) { @@ -4395,7 +4395,7 @@ function doSearch(item) { Zotero.wait(); }'); -REPLACE INTO translators VALUES ('af4cf622-eaca-450b-bd45-0f4ba345d081', '1.0.0b2.r2', '', '2006-11-27 22:45:00', 1, 100, 8, 'CiteBase', 'Simon Kornblith', 'http://www.citebase.org/', +REPLACE INTO translators VALUES ('af4cf622-eaca-450b-bd45-0f4ba345d081', '1.0.0b2.r2', '', '2006-12-12 22:10:00', 1, 100, 8, 'CiteBase', 'Simon Kornblith', 'http://www.citebase.org/', 'function detectSearch(item) { if(item.itemType == "journalArticle") { return true; @@ -4413,13 +4413,14 @@ REPLACE INTO translators VALUES ('af4cf622-eaca-450b-bd45-0f4ba345d081', '1.0.0b var co = Zotero.Utilities.createContextObject(item); } - Zotero.Utilities.debug("http://www.citebase.org/openurl?"+co+"&svc_id=bibtex"); - Zotero.Utilities.HTTP.doGet("http://www.citebase.org/openurl?"+co+"&svc_id=bibtex", function(responseText) { - // read BibTeX - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - translator.setString(responseText); - translator.translate(); + Zotero.Utilities.HTTP.doGet("http://www.citebase.org/openurl?"+co+"&svc_id=bibtex", function(responseText, request) { + if(responseText.substr(0, 6) != "