diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js
index 183ca8523..f6d7d678b 100644
--- a/chrome/content/zotero/overlay.js
+++ b/chrome/content/zotero/overlay.js
@@ -874,10 +874,35 @@ var ZoteroPane = new function()
}
}
+ var menuitem = document.getElementById("zotero-context-save-link-as-snapshot");
+ if (menuitem) {
+ if (window.gContextMenu.onLink) {
+ menuitem.hidden = false;
+ showing = true;
+ }
+ else {
+ menuitem.hidden = true;
+ }
+ }
+
+ var menuitem = document.getElementById("zotero-context-save-image-as-snapshot");
+ if (menuitem) {
+ // Not using window.gContextMenu.hasBGImage -- if the user wants it,
+ // they can use the Firefox option to view and then import from there
+ if (window.gContextMenu.onImage) {
+ menuitem.hidden = false;
+ showing = true;
+ }
+ else {
+ menuitem.hidden = true;
+ }
+ }
+
var separator = document.getElementById("zotero-context-separator");
separator.hidden = !showing;
}
+
function newNote(popup, parent, text)
{
if (!popup)
diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul
index 38060be2c..1dd3c3fd8 100644
--- a/chrome/content/zotero/overlay.xul
+++ b/chrome/content/zotero/overlay.xul
@@ -52,6 +52,12 @@
+
+
diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js
index f908c1cd5..e49b34323 100644
--- a/chrome/content/zotero/xpcom/attachments.js
+++ b/chrome/content/zotero/xpcom/attachments.js
@@ -178,9 +178,9 @@ Zotero.Attachments = new function(){
nsIURL.spec = url;
var ext = nsIURL.fileExtension;
- // If we can load this internally, use a hidden browser (so we can
- // get the charset and title)
- if (Zotero.MIME.hasInternalHandler(mimeType, ext)){
+ // If we can load this natively, use a hidden browser (so we can
+ // get the charset and title and index the document)
+ if (Zotero.MIME.hasNativeHandler(mimeType, ext)){
var browser = Zotero.Browser.createHiddenBrowser();
browser.addEventListener("pageshow", function(){
Zotero.Attachments.importFromDocument(browser.contentDocument, sourceItemID);
@@ -254,7 +254,7 @@ Zotero.Attachments = new function(){
// leaving the transaction open if the callback never triggers
Zotero.DB.commitTransaction();
- wbp.saveURI(nsIURL, null, null, null, null, file);
+ wbp.saveURI(nsIURL, null, null, null, null, file);
}
catch (e){
Zotero.DB.rollbackTransaction();
@@ -340,15 +340,17 @@ Zotero.Attachments = new function(){
var title = forceTitle ? forceTitle : document.title;
var mimeType = document.contentType;
var charsetID = Zotero.CharacterSets.getID(document.characterSet);
- var hasNativeHandler = Zotero.MIME.hasNativeHandler(mimeType, _getExtensionFromURL(url))
- // TODO: make this work -- with local plugin files, onStateChange in the
- // nsIWebBrowserPersist's nsIWebProgressListener never completes and
- // onProgressChange returns -1 for maxTotal, which prevents it from
- // triggering the callback.
- if (!hasNativeHandler && url.substr(0, 4) == 'file') {
- Zotero.debug('Import of loaded files from plugins is not supported');
- return false;
+ if (!forceTitle) {
+ // Remove e.g. " - Scaled (-17%)" from end of images saved from links,
+ // though I'm not sure why it's getting added to begin with
+ if (mimeType.indexOf('image/') === 0) {
+ title = title.replace(/(.+ \([^,]+, [0-9]+x[0-9]+[^\)]+\)) - .+/, "$1" );
+ }
+ // If not native type, strip mime type data in parens
+ else if (!Zotero.MIME.hasNativeHandler(mimeType, _getExtensionFromURL(url))) {
+ title = title.replace(/(.+) \([a-z]+\/[^\)]+\)/, "$1" );
+ }
}
const nsIWBP = Components.interfaces.nsIWebBrowserPersist;
@@ -434,13 +436,23 @@ Zotero.Attachments = new function(){
}
Zotero.Fulltext.indexDocument(document, itemID);
- }, !hasNativeHandler);
+ });
// The attachment is still incomplete here, but we can't risk
// leaving the transaction open if the callback never triggers
Zotero.DB.commitTransaction();
- wbp.saveDocument(document, file, destDir, mimeType, encodingFlags, false);
+ if (Zotero.MIME.isDocumentType(mimeType)) {
+ Zotero.debug('Saving with saveDocument()');
+ wbp.saveDocument(document, file, destDir, mimeType, encodingFlags, false);
+ }
+ else {
+ Zotero.debug('Saving with saveURI()');
+ var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+ .getService(Components.interfaces.nsIIOService);
+ var nsIURL = ioService.newURI(url, null, null);
+ wbp.saveURI(nsIURL, null, null, null, null, file);
+ }
}
catch (e) {
Zotero.DB.rollbackTransaction();
diff --git a/chrome/content/zotero/xpcom/fulltext.js b/chrome/content/zotero/xpcom/fulltext.js
index c54fd8020..06ba574cc 100644
--- a/chrome/content/zotero/xpcom/fulltext.js
+++ b/chrome/content/zotero/xpcom/fulltext.js
@@ -159,6 +159,16 @@ Zotero.Fulltext = new function(){
Zotero.debug("Indexing document '" + document.title + "'");
+ if (document.contentType.indexOf('text/') !== 0) {
+ Zotero.debug('File is not text in indexDocument()', 2);
+ return false;
+ }
+
+ if (!document.characterSet){
+ Zotero.debug("Text file didn't have charset in indexFile()", 1);
+ return false;
+ }
+
var text = document.body.innerHTML.replace(/(>)/g, '$1 ');
text = HTMLToText(text);
indexString(text, document.characterSet, itemID);
diff --git a/chrome/content/zotero/xpcom/mime.js b/chrome/content/zotero/xpcom/mime.js
index 4e31c68d0..a36c6b634 100644
--- a/chrome/content/zotero/xpcom/mime.js
+++ b/chrome/content/zotero/xpcom/mime.js
@@ -26,6 +26,7 @@ Zotero.MIME = new function(){
this.sniffForBinary = sniffForBinary;
this.getMIMETypeFromData = getMIMETypeFromData;
this.getMIMETypeFromFile = getMIMETypeFromFile;
+ this.isDocumentType = isDocumentType;
this.hasNativeHandler = hasNativeHandler;
this.hasInternalHandler = hasInternalHandler;
this.fileHasInternalHandler = fileHasInternalHandler;
@@ -41,6 +42,14 @@ Zotero.MIME = new function(){
["
+
+