| 88 |
88 |
api.created_on attachment.created_on
|
| 89 |
89 |
end
|
| 90 |
90 |
|
|
91 |
# Names that are displayed instead of MIME types. A name should be added
|
|
92 |
# only for a type that is frequently used but whose MIME type is very long
|
|
93 |
# and hard to read. The names are not translated, so they should consist
|
|
94 |
# of the name of the application or the format followed by nouns.
|
|
95 |
#
|
|
96 |
# * A template is named by appending "Template" to the corresponding type
|
|
97 |
# * For Microsoft Office, a macro-enabled type is named by appending "(+macro)"
|
|
98 |
#
|
|
99 |
# The keys must be in lowercase because the lookup is case-insensitive.
|
|
100 |
CONTENT_TYPE_NAMES = {
|
|
101 |
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'Microsoft Word Document',
|
|
102 |
'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'Microsoft Word Document Template',
|
|
103 |
'application/vnd.ms-word.document.macroenabled.12' => 'Microsoft Word Document (+macro)',
|
|
104 |
'application/vnd.ms-word.template.macroenabled.12' => 'Microsoft Word Document Template (+macro)',
|
|
105 |
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'Microsoft Excel Workbook',
|
|
106 |
'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'Microsoft Excel Workbook Template',
|
|
107 |
'application/vnd.ms-excel.sheet.macroenabled.12' => 'Microsoft Excel Workbook (+macro)',
|
|
108 |
'application/vnd.ms-excel.template.macroenabled.12' => 'Microsoft Excel Workbook Template (+macro)',
|
|
109 |
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'Microsoft PowerPoint Presentation',
|
|
110 |
'application/vnd.openxmlformats-officedocument.presentationml.template' => 'Microsoft PowerPoint Presentation Template',
|
|
111 |
'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'Microsoft PowerPoint Slide Show',
|
|
112 |
'application/vnd.ms-powerpoint.presentation.macroenabled.12' => 'Microsoft PowerPoint Presentation (+macro)',
|
|
113 |
'application/vnd.ms-powerpoint.template.macroenabled.12' => 'Microsoft PowerPoint Presentation Template (+macro)',
|
|
114 |
'application/vnd.ms-powerpoint.slideshow.macroenabled.12' => 'Microsoft PowerPoint Slide Show (+macro)',
|
|
115 |
'application/vnd.oasis.opendocument.text' => 'OpenDocument Text',
|
|
116 |
'application/vnd.oasis.opendocument.text-template' => 'OpenDocument Text Template',
|
|
117 |
'application/vnd.oasis.opendocument.spreadsheet' => 'OpenDocument Spreadsheet',
|
|
118 |
'application/vnd.oasis.opendocument.spreadsheet-template' => 'OpenDocument Spreadsheet Template',
|
|
119 |
'application/vnd.oasis.opendocument.presentation' => 'OpenDocument Presentation',
|
|
120 |
'application/vnd.oasis.opendocument.presentation-template' => 'OpenDocument Presentation Template',
|
|
121 |
'application/vnd.oasis.opendocument.graphics' => 'OpenDocument Graphics',
|
|
122 |
'application/vnd.oasis.opendocument.graphics-template' => 'OpenDocument Graphics Template'
|
|
123 |
}.freeze
|
|
124 |
|
|
125 |
# Returns a span tag that contains the content type of the attachment, or
|
|
126 |
# nil if the content type is blank.
|
|
127 |
#
|
|
128 |
# For the types listed in CONTENT_TYPE_NAMES, the name of the type is
|
|
129 |
# displayed and the MIME type is available in the title attribute.
|
|
130 |
def attachment_content_type_tag(attachment)
|
|
131 |
content_type = attachment.content_type
|
|
132 |
return if content_type.blank?
|
|
133 |
|
|
134 |
name = CONTENT_TYPE_NAMES[content_type.downcase]
|
|
135 |
content_tag(:span, name || content_type, :class => 'content-type', :title => (content_type if name))
|
|
136 |
end
|
|
137 |
|
| 91 |
138 |
def render_file_content(attachment, content)
|
| 92 |
139 |
if attachment.is_markdown?
|
| 93 |
140 |
render :partial => 'common/markup', :locals => {:markup_text_formatting => 'common_mark', :markup_text => content}
|