From bf2e86da808e61dc4078b4d2d04dc4939eae57f0 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sat, 14 Feb 2026 08:50:04 +0000 Subject: [PATCH] Show 'text-plain' icon for Markdown and Textile files (#43805). Patch by Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@24412 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/icons_helper.rb | 6 ++++-- test/helpers/icons_helper_test.rb | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 8071e7126..0dc341941 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -114,16 +114,18 @@ module IconsHelper 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 diff --git a/test/helpers/icons_helper_test.rb b/test/helpers/icons_helper_test.rb index 942ee96ef..527e8fc03 100644 --- a/test/helpers/icons_helper_test.rb +++ b/test/helpers/icons_helper_test.rb @@ -135,8 +135,9 @@ class IconsHelperTest < Redmine::HelperTest 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