diff --git a/chrome/content/zotero/xpcom/translate.js b/chrome/content/zotero/xpcom/translate.js index b56bcd7d5..1c365f2b5 100644 --- a/chrome/content/zotero/xpcom/translate.js +++ b/chrome/content/zotero/xpcom/translate.js @@ -1215,9 +1215,25 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) { if(!attachment.url && !attachment.document) { Zotero.debug("not adding attachment: no URL specified"); } else { - if(attachment.document + if(attachment.snapshot === false) { + // if snapshot is explicitly set to false, attach as link + if(attachment.document) { + attachmentID = Zotero.Attachments.linkFromURL(attachment.document.location.href, myID, + (attachment.mimeType ? attachment.mimeType : attachment.document.contentType), + (attachment.title ? attachment.title : attachment.document.title)); + } else { + if(!attachment.mimeType || !attachment.title) { + Zotero.debug("NOTICE: either mimeType or title is missing; attaching file will be slower"); + } + + attachmentID = Zotero.Attachments.linkFromURL(attachment.url, myID, + (attachment.mimeType ? attachment.mimeType : undefined), + (attachment.title ? attachment.title : undefined)); + } + } else if(attachment.document || (attachment.mimeType && attachment.mimeType == "text/html") || Zotero.Prefs.get("downloadAssociatedFiles")) { + // if snapshot is not explicitly set to false, retrieve snapshot if(attachment.document) { Zotero.Attachments.importFromDocument(attachment.document, myID, attachment.title); } else { @@ -1249,20 +1265,6 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) { Zotero.Attachments.importFromURL(attachment.url, myID, title, fileBaseName); } } - // links no longer exist, so just don't save them - /*if(attachment.document) { - attachmentID = Zotero.Attachments.linkFromURL(attachment.document.location.href, myID, - (attachment.mimeType ? attachment.mimeType : attachment.document.contentType), - (attachment.title ? attachment.title : attachment.document.title)); - } else { - if(!attachment.mimeType || attachment.title) { - Zotero.debug("notice: either mimeType or title is missing; attaching file will be slower"); - } - - attachmentID = Zotero.Attachments.linkFromURL(attachment.url, myID, - (attachment.mimeType ? attachment.mimeType : undefined), - (attachment.title ? attachment.title : undefined)); - }*/ } } else if(this.type == "import") { // create new attachments attached here diff --git a/scrapers.sql b/scrapers.sql index 70631cb78..edd5385a1 100644 --- a/scrapers.sql +++ b/scrapers.sql @@ -1,4 +1,4 @@ --- 186 +-- 187 -- ***** BEGIN LICENSE BLOCK ***** -- @@ -22,9 +22,9 @@ -- Set the following timestamp to the most recent scraper update date -REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2007-03-20 18:40:00')); +REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2007-03-21 15:26:54')); -REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b3.r1', '', '2006-12-15 03:40:00', 1, 100, 4, 'Amazon.com', 'Sean Takats', '^https?://(?:www\.)?amazon', +REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b4.r1', '', '2007-03-21 15:26:54', '1', '100', '4', 'Amazon.com', 'Sean Takats', '^https?://(?:www\.)?amazon', 'function detectWeb(doc, url) { var suffixRe = new RegExp("https?://(?:www\.)?amazon\.([^/]+)/"); @@ -64,7 +64,7 @@ REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b } } } -', +', 'function doWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { @@ -125,6 +125,7 @@ REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b texts = texts[1].split(""); text = "" + texts[0]; var xml = new XML(text); + Zotero.debug(text); var publisher = ""; if (xml..Publisher.length()){ @@ -202,14 +203,14 @@ REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b title = title.substring(0, title.lastIndexOf("(")-1); } if (xml..ASIN.length()){ - newItem.url = "http://www.amazon." + suffix + "/dp/" + Zotero.Utilities.cleanString(xml..ASIN[0].text().toString()); + var url = "http://www.amazon." + suffix + "/dp/" + Zotero.Utilities.cleanString(xml..ASIN[0].text().toString()); + newItem.attachments.push({title:"Amazon.com Link", snapshot:false, mimeType:"text/html", url:url}); } if (xml..OriginalReleaseDate.length()){ newItem.extra = newItem.pages = Zotero.Utilities.cleanString(xml..OriginalReleaseDate[0].text().toString()); } - Zotero.debug("item title: " + title); newItem.title = title; newItem.complete(); }, function() {Zotero.done();}, null);