diff --git a/chrome/chromeFiles/content/scholar/xpcom/translate.js b/chrome/chromeFiles/content/scholar/xpcom/translate.js index fa7666c31..f1ce1a754 100644 --- 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 index b8a46cfa7..e6e1551ce 100644 --- 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 index 909b360c3..f06ae9e3d 100644 --- 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(); }');