From f2639e9038c1d5f9ad2975cc3e246381e9c3ec72 Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Mon, 2 Sep 2024 20:48:40 +0000 Subject: Replace icons for files in repository view with SVG icons (#23980). git-svn-id: https://svn.redmine.org/redmine/trunk@23011 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/assets/images/icons.svg | 6 +++--- app/assets/stylesheets/application.css | 36 +++++++++++++++++----------------- app/helpers/icons_helper.rb | 20 +++++++++++++++++-- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/app/assets/images/icons.svg b/app/assets/images/icons.svg index b6a5ed020..c22c19f06 100644 --- a/app/assets/images/icons.svg +++ b/app/assets/images/icons.svg @@ -133,10 +133,10 @@ - + - + @@ -288,7 +288,7 @@ - + diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f704df274..c733662dc 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1761,24 +1761,24 @@ span.icon-label { .icon-clear-query:not(:has(svg)) { background-image: url(/close_hl.png); } .icon-import:not(:has(svg)) { background-image: url(/database_go.png); } -.icon-file { background-image: url(/files/default.png); } -.icon-file.text-plain { background-image: url(/files/text.png); } -.icon-file.text-x-c { background-image: url(/files/c.png); } -.icon-file.text-x-csharp { background-image: url(/files/csharp.png); } -.icon-file.text-x-java { background-image: url(/files/java.png); } -.icon-file.application-javascript { background-image: url(/files/js.png); } -.icon-file.text-x-php { background-image: url(/files/php.png); } -.icon-file.text-x-ruby { background-image: url(/files/ruby.png); } -.icon-file.text-xml { background-image: url(/files/xml.png); } -.icon-file.text-css { background-image: url(/files/css.png); } -.icon-file.text-html { background-image: url(/files/html.png); } -.icon-file.image-gif { background-image: url(/files/image.png); } -.icon-file.image-jpeg { background-image: url(/files/image.png); } -.icon-file.image-png { background-image: url(/files/image.png); } -.icon-file.image-tiff { background-image: url(/files/image.png); } -.icon-file.application-pdf { background-image: url(/files/pdf.png); } -.icon-file.application-zip { background-image: url(/files/zip.png); } -.icon-file.application-gzip { background-image: url(/files/zip.png); } +.icon-file:not(:has(svg)) { background-image: url(/files/default.png); } +.icon-file.text-plain:not(:has(svg)) { background-image: url(/files/text.png); } +.icon-file.text-x-c:not(:has(svg)) { background-image: url(/files/c.png); } +.icon-file.text-x-csharp:not(:has(svg)) { background-image: url(/files/csharp.png); } +.icon-file.text-x-java:not(:has(svg)) { background-image: url(/files/java.png); } +.icon-file.application-javascript:not(:has(svg)) { background-image: url(/files/js.png); } +.icon-file.text-x-php:not(:has(svg)) { background-image: url(/files/php.png); } +.icon-file.text-x-ruby:not(:has(svg)) { background-image: url(/files/ruby.png); } +.icon-file.text-xml:not(:has(svg)) { background-image: url(/files/xml.png); } +.icon-file.text-css:not(:has(svg)) { background-image: url(/files/css.png); } +.icon-file.text-html:not(:has(svg)) { background-image: url(/files/html.png); } +.icon-file.image-gif:not(:has(svg)) { background-image: url(/files/image.png); } +.icon-file.image-jpeg:not(:has(svg)) { background-image: url(/files/image.png); } +.icon-file.image-png:not(:has(svg)) { background-image: url(/files/image.png); } +.icon-file.image-tiff:not(:has(svg)) { background-image: url(/files/image.png); } +.icon-file.application-pdf:not(:has(svg)) { background-image: url(/files/pdf.png); } +.icon-file.application-zip:not(:has(svg)) { background-image: url(/files/zip.png); } +.icon-file.application-gzip:not(:has(svg)) { background-image: url(/files/zip.png); } .icon-copy-link:not(:has(svg)) { background-image: url(/copy_link.png); } .sort-handle.ajax-loading { background-image: url(/loading.gif); } diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index b9b25c0ba..26a605fad 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -25,9 +25,12 @@ module IconsHelper sprite_icon(icon_name) + content_tag(:span, label_text, class: "icon-label") end - def icon_for_file(entry, label_text) + def icon_for_file(entry, name) if entry.is_dir? - icon_with_label("folder", label_text) + icon_with_label("folder", name) + else + icon = icon_for_mime_type(Redmine::MimeType.css_class_of(name)) + icon_with_label(icon, name) end end @@ -43,4 +46,17 @@ module IconsHelper } ) end + + private + + def icon_for_mime_type(mime) + if %w(text-plain 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 + image-gif image-jpeg image-png image-tiff + application-pdf application-zip application-gzip application-javascript).include?(mime) + mime + else + "file" + end + end end -- cgit v1.2.3