diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml index 13669f845..0862e755f 100644 --- a/chrome/content/zotero/bindings/itembox.xml +++ b/chrome/content/zotero/bindings/itembox.xml @@ -260,6 +260,18 @@ } } + // If that fails, try the DOI field + if (!spec) { + var doi = this.item.getField('DOI'); + if (doi) { + // Pull out DOI, in case there's a prefix + doi = doi.match(/10\..*/); + if (doi) { + spec = "http://dx.doi.org/" + encodeURIComponent(doi); + } + } + } + if (!spec) { break testView; } diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 8856e8e55..dd4e83923 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -1907,6 +1907,20 @@ var ZoteroPane = new function() var item = ZoteroPane.getSelectedItems()[0]; if (item) { if (item.isRegularItem()) { + var uri = Components.classes["@mozilla.org/network/standard-url;1"]. + createInstance(Components.interfaces.nsIURI); + var snapID = item.getBestSnapshot(); + if (snapID) { + spec = Zotero.Items.get(snapID).getLocalFileURL(); + if (spec) { + uri.spec = spec; + if (uri.scheme && uri.scheme == 'file') { + ZoteroPane.viewAttachment(snapID, event); + return; + } + } + } + var uri = item.getField('url'); if (!uri) { var doi = item.getField('DOI'); diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index f97b93c93..93650a537 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -2565,10 +2565,12 @@ Zotero.Item.prototype.getLocalFileURL = function() { } var file = this.getFile(); + if (!file) { + return false; + } var nsIFPH = Components.classes["@mozilla.org/network/protocol;1?name=file"] .getService(Components.interfaces.nsIFileProtocolHandler); - return nsIFPH.getURLSpecFromFile(file); }