closes #239, fix embedded RDF translator

This commit is contained in:
Simon Kornblith 2006-09-04 21:43:23 +00:00
parent 370fe48388
commit 7d93903e2d
3 changed files with 19 additions and 9 deletions

View File

@ -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;
}

View File

@ -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];

View File

@ -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();
}');