closes #525, Amazon URLs should be saved as attached links instead of URL field
setting the snapshot property on an attachment explicitly to false now forces a link, rather than a snapshot, to be generated
This commit is contained in:
parent
87df94d382
commit
3a304081dd
|
@ -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
|
||||
|
|
13
scrapers.sql
13
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("</ItemLookupResponse>");
|
||||
text = "<Items>" + 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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user