Feature #43805 » 0002-Show-text-plain-icon-for-Markdown-and-Textile-files.patch
| app/helpers/icons_helper.rb | ||
|---|---|---|
| 114 | 114 |
end |
| 115 | 115 | |
| 116 | 116 |
def icon_for_mime_type(mime) |
| 117 |
if %w(text/plain text/x-c text/x-csharp text/x-java text/x-php
|
|
| 117 |
if %w(text/x-c text/x-csharp text/x-java text/x-php |
|
| 118 | 118 |
text/x-ruby text/xml text/css text/html text/css text/html |
| 119 | 119 |
application/pdf application/zip application/gzip application/javascript).include?(mime) |
| 120 | 120 |
icon_name = mime.tr('/', '-')
|
| 121 | 121 |
else |
| 122 | 122 |
top_level_type, subtype = mime.to_s.split('/')
|
| 123 | 123 |
icon_name = |
| 124 |
case top_level_type # rubocop:disable Style/HashLikeCase
|
|
| 124 |
case top_level_type |
|
| 125 | 125 |
when 'audio' then 'file-music' |
| 126 | 126 |
when 'image' then 'photo' |
| 127 |
when 'text' |
|
| 128 |
%w(markdown plain x-textile).include?(subtype) ? 'text-plain' : nil |
|
| 127 | 129 |
when 'video' then 'movie' |
| 128 | 130 |
end |
| 129 | 131 |
end |
| test/helpers/icons_helper_test.rb | ||
|---|---|---|
| 135 | 135 |
end |
| 136 | 136 | |
| 137 | 137 |
def test_icon_for_mime_type_should_return_specific_icon_for_known_mime_types |
| 138 |
assert_equal 'text-plain', icon_for_mime_type('text/plain')
|
|
| 139 | 138 |
assert_equal 'application-pdf', icon_for_mime_type('application/pdf')
|
| 139 |
assert_equal 'text-plain', icon_for_mime_type('text/markdown')
|
|
| 140 |
assert_equal 'text-plain', icon_for_mime_type('text/plain')
|
|
| 140 | 141 |
end |
| 141 | 142 | |
| 142 | 143 |
def test_icon_for_mime_type_should_return_icon_for_top_level_types |
- « Previous
- 1
- 2
- 3
- 4
- Next »