commit a6478d7dd5aebdc36273b400eaa9bd9ecb8580bd
parent 211d5f3b628ab700a923472330005a491656398b
Author: Dan Stillman <dstillman@zotero.org>
Date: Sat, 30 May 2009 08:53:44 +0000
- Display snapshot first when double-clicking on an item, to make it consistent with the View button
- Check DOI field for View button
- Return false in Zotero.Item.getLocalFileURL() if file is missing rather than throwing error
Diffstat:
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git 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
@@ -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
@@ -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);
}