More snapshot-related tweaks:

- Only use saveDocument() for text/html snapshots

- Add 'application/xhtml+xml' and 'application/xml' as native MIME types

- When loading attachment, check recorded MIME type first before detecting
This commit is contained in:
Dan Stillman 2006-12-07 14:12:00 +00:00
parent 0d145cd47b
commit b383fb6aa7
3 changed files with 10 additions and 16 deletions

View file

@ -1069,7 +1069,13 @@ var ZoteroPane = new function()
{
var file = attachment.getFile();
if (file){
if (Zotero.MIME.fileHasInternalHandler(file))
var mimeType = attachment.getAttachmentMimeType();
if (mimeType) {
var ext = Zotero.File.getExtension(file);
var internal = Zotero.MIME.hasInternalHandler(mimeType, ext);
}
if (internal || Zotero.MIME.fileHasInternalHandler(file))
{
window.loadURI(attachment.getLocalFileURL());
}

View file

@ -442,7 +442,7 @@ Zotero.Attachments = new function(){
// leaving the transaction open if the callback never triggers
Zotero.DB.commitTransaction();
if (Zotero.MIME.isDocumentType(mimeType)) {
if (mimeType == 'text/html') {
Zotero.debug('Saving with saveDocument()');
wbp.saveDocument(document, file, destDir, mimeType, encodingFlags, false);
}

View file

@ -26,7 +26,6 @@ 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;
@ -42,14 +41,6 @@ Zotero.MIME = new function(){
["<?xml", 'text/xml']
];
// MIME types to be saved as documents
var _documentMIMETypes = {
'text/html': true,
'application/xhtml+xml': true,
'text/xml': true,
'application/xml': true
};
// MIME types handled natively by Gecko
// DEBUG: There's definitely a better way of getting these
var _nativeMIMETypes = {
@ -58,6 +49,8 @@ Zotero.MIME = new function(){
'image/jpeg': true,
'image/gif': true,
'text/xml': true,
'application/xhtml+xml': true,
'application/xml': true,
'text/plain': true,
'application/x-javascript': true
};
@ -146,11 +139,6 @@ Zotero.MIME = new function(){
}
function isDocumentType(mimeType) {
return _documentMIMETypes[mimeType] ? true : false;
}
/*
* Determine if a MIME type can be handled natively
* or if it needs to be passed off to a plugin or external helper app