www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 7d93903e2db0466f9477d9c153900f0eaaace3a1
parent 370fe483882d4d30560a72e8227ab23daf5a0f34
Author: Simon Kornblith <simon@simonster.com>
Date:   Mon,  4 Sep 2006 21:43:23 +0000

closes #239, fix embedded RDF translator


Diffstat:
Mchrome/chromeFiles/content/scholar/xpcom/translate.js | 4++++
Mchrome/chromeFiles/content/scholar/xpcom/utilities.js | 4++--
Mscrapers.sql | 20+++++++++++++-------
3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/xpcom/translate.js b/chrome/chromeFiles/content/scholar/xpcom/translate.js @@ -1860,6 +1860,10 @@ Scholar.Translate.RDF.prototype.addNamespace = function(prefix, uri) { // gets a resource's URI Scholar.Translate.RDF.prototype.getResourceURI = function(resource) { + if(typeof(resource) == "string") { + return resource; + } + resource.QueryInterface(Components.interfaces.nsIRDFResource); return resource.ValueUTF8; } diff --git a/chrome/chromeFiles/content/scholar/xpcom/utilities.js b/chrome/chromeFiles/content/scholar/xpcom/utilities.js @@ -28,10 +28,10 @@ Scholar.Utilities.prototype.cleanAuthor = function(author, type, useComma) { author = author.replace(/ +/, ' '); if(useComma) { // Add period for initials - if(author.substr(author.length-2, 1) == " ") { + if(author.substr(author.length-2, 1) == " " || author.substr(author.length-2, 1) == ".") { author += "."; } - var splitNames = author.split(', '); + var splitNames = author.split(/, ?/); if(splitNames.length > 1) { var lastName = splitNames[0]; var firstName = splitNames[1]; diff --git a/scrapers.sql b/scrapers.sql @@ -1,4 +1,4 @@ --- 76 +-- 77 -- Set the following timestamp to the most recent scraper update date REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-08-31 22:44:00')); @@ -2723,6 +2723,17 @@ REPLACE INTO "translators" VALUES ('951c027d-74ac-47d4-a107-9c3069ab7b48', '2006 // load RDF translator var translator = Scholar.loadTranslator("import"); translator.setTranslator("5e3ad958-ac79-463d-812b-a86a9235c28f"); + translator.setHandler("itemDone", function(obj, newItem) { + // use document title if none given in dublin core + if(!newItem.title) { + newItem.title = doc.title; + } + // add attachment + newItem.attachments.push({document:doc}); + // add url + newItem.url = doc.location.href; + newItem.complete(); + }); var rdf = translator.getTranslatorObject(); var metaTags = doc.getElementsByTagName("meta"); @@ -2734,8 +2745,7 @@ REPLACE INTO "translators" VALUES ('951c027d-74ac-47d4-a107-9c3069ab7b48', '2006 if(tag == "dc.title") { foundTitle = true; } - rdf.Scholar.RDF.addStatement(url, dc + tag.substr(3), value, true); - Scholar.Utilities.debug(tag.substr(3) + " = " + value); + rdf.Scholar.RDF.addStatement(url, dc + tag.substr(3).toLowerCase(), value, true); } else if(tag && value && (tag == "author" || tag == "author-personal")) { rdf.Scholar.RDF.addStatement(url, dc + "creator", value, true); } else if(tag && value && tag == "author-corporate") { @@ -2743,10 +2753,6 @@ REPLACE INTO "translators" VALUES ('951c027d-74ac-47d4-a107-9c3069ab7b48', '2006 } } - if(!foundTitle) { - rdf.Scholar.RDF.addStatement(url, dc + "title", doc.title, true); - } - rdf.doImport(); }');