Feature #43805 » 0002-Show-text-plain-icon-for-Markdown-and-Textile-files.patch
| app/helpers/icons_helper.rb | ||
|---|---|---|
|
end
|
||
|
def icon_for_mime_type(mime)
|
||
|
if %w(text/plain text/x-c text/x-csharp text/x-java text/x-php
|
||
|
if %w(text/x-c text/x-csharp text/x-java text/x-php
|
||
|
text/x-ruby text/xml text/css text/html text/css text/html
|
||
|
application/pdf application/zip application/gzip application/javascript).include?(mime)
|
||
|
icon_name = mime.tr('/', '-')
|
||
|
else
|
||
|
top_level_type, subtype = mime.to_s.split('/')
|
||
|
icon_name =
|
||
|
case top_level_type # rubocop:disable Style/HashLikeCase
|
||
|
case top_level_type
|
||
|
when 'audio' then 'file-music'
|
||
|
when 'image' then 'photo'
|
||
|
when 'text'
|
||
|
%w(markdown plain x-textile).include?(subtype) ? 'text-plain' : nil
|
||
|
when 'video' then 'movie'
|
||
|
end
|
||
|
end
|
||
| test/helpers/icons_helper_test.rb | ||
|---|---|---|
|
end
|
||
|
def test_icon_for_mime_type_should_return_specific_icon_for_known_mime_types
|
||
|
assert_equal 'text-plain', icon_for_mime_type('text/plain')
|
||
|
assert_equal 'application-pdf', icon_for_mime_type('application/pdf')
|
||
|
assert_equal 'text-plain', icon_for_mime_type('text/markdown')
|
||
|
assert_equal 'text-plain', icon_for_mime_type('text/plain')
|
||
|
end
|
||
|
def test_icon_for_mime_type_should_return_icon_for_top_level_types
|
||
- « Previous
- 1
- 2
- 3
- 4
- Next »