Skip to content

Instantly share code, notes, and snippets.

@doctorpangloss
Created August 15, 2014 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doctorpangloss/a612dc5441825f93c01e to your computer and use it in GitHub Desktop.
Save doctorpangloss/a612dc5441825f93c01e to your computer and use it in GitHub Desktop.
DocumentViewer.SUPPORTED_MIMETYPE_MAP = {
office: [
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.ms-word.document.macroenabled.12',
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'application/vnd.ms-word.template.macroenabled.12',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.ms-excel.sheet.macroenabled.12',
'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
'application/vnd.ms-excel.template.macroenabled.12',
'application/vnd.ms-excel.sheet.binary.macroenabled.12',
'application/vnd.ms-excel.addin.macroenabled.12',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.ms-powerpoint.presentation.macroenabled.12',
'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
'application/vnd.openxmlformats-officedocument.presentationml.template',
'application/vnd.ms-powerpoint.template.macroenabled.12',
'application/vnd.ms-powerpoint.addin.macroenabled.12',
'application/vnd.openxmlformats-officedocument.presentationml.slide',
'application/vnd.ms-powerpoint.slide.macroenabled.12',
'application/msonenote',
'application/vnd.ms-officetheme'
],
pdf: [
'application/acrobat',
'application/x-pdf',
'applications/vnd.pdf',
'text/pdf',
'text/x-pdf',
'application/pdf'
]
};
// Traverse our supported mime types and return the mimegroup type as stirng 'office' or 'pdf'
// If not supported mimetype, return undefined
return _.object(_.flatten(_.map(DocumentViewer.SUPPORTED_MIMETYPE_MAP, function (mimetypes, filetype) {
return _.map(mimetypes, function(mimetype) {
return [mimetype, filetype];
});
}), true))[instance.metadata.mimetype];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment