diff --git a/app/views/repositories/_dir_list_content.rhtml b/app/views/repositories/_dir_list_content.rhtml
index 799318134..bcffed4a5 100644
--- a/app/views/repositories/_dir_list_content.rhtml
+++ b/app/views/repositories/_dir_list_content.rhtml
@@ -13,7 +13,7 @@
<% end %>
<%= link_to h(entry.name),
{:action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => to_path_param(entry.path), :rev => @rev},
- :class => (entry.is_dir? ? 'icon icon-folder' : 'icon icon-file')%>
+ :class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(entry.name)}")%>
<%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %> |
<% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %>
diff --git a/lib/redmine/mime_type.rb b/lib/redmine/mime_type.rb
index dfdfff407..f0e55cc92 100644
--- a/lib/redmine/mime_type.rb
+++ b/lib/redmine/mime_type.rb
@@ -24,6 +24,7 @@ module Redmine
'text/html' => 'html,htm,xhtml',
'text/jsp' => 'jsp',
'text/x-c' => 'c,cpp,cc,h,hh',
+ 'text/x-csharp' => 'cs',
'text/x-java' => 'java',
'text/x-javascript' => 'js',
'text/x-html-template' => 'rhtml',
@@ -41,6 +42,9 @@ module Redmine
'image/tiff' => 'tiff,tif',
'image/x-ms-bmp' => 'bmp',
'image/x-xpixmap' => 'xpm',
+ 'application/pdf' => 'pdf',
+ 'application/zip' => 'zip',
+ 'application/x-gzip' => 'gz',
}.freeze
EXTENSIONS = MIME_TYPES.inject({}) do |map, (type, exts)|
@@ -55,6 +59,13 @@ module Redmine
EXTENSIONS[m[2].downcase] if m
end
+ # Returns the css class associated to
+ # the mime type of name
+ def self.css_class_of(name)
+ mime = of(name)
+ mime && mime.gsub('/', '-')
+ end
+
def self.main_mimetype_of(name)
mimetype = of(name)
mimetype.split('/').first if mimetype
diff --git a/public/images/file.png b/public/images/file.png
deleted file mode 100644
index f387dd305..000000000
Binary files a/public/images/file.png and /dev/null differ
diff --git a/public/images/files/c.png b/public/images/files/c.png
new file mode 100644
index 000000000..34a05cccf
Binary files /dev/null and b/public/images/files/c.png differ
diff --git a/public/images/files/csharp.png b/public/images/files/csharp.png
new file mode 100644
index 000000000..ffb8fc932
Binary files /dev/null and b/public/images/files/csharp.png differ
diff --git a/public/images/files/default.png b/public/images/files/default.png
new file mode 100644
index 000000000..8b8b1ca00
Binary files /dev/null and b/public/images/files/default.png differ
diff --git a/public/images/files/image.png b/public/images/files/image.png
new file mode 100644
index 000000000..134b66936
Binary files /dev/null and b/public/images/files/image.png differ
diff --git a/public/images/files/pdf.png b/public/images/files/pdf.png
new file mode 100644
index 000000000..8f8095e46
Binary files /dev/null and b/public/images/files/pdf.png differ
diff --git a/public/images/files/php.png b/public/images/files/php.png
new file mode 100644
index 000000000..7868a2594
Binary files /dev/null and b/public/images/files/php.png differ
diff --git a/public/images/files/ruby.png b/public/images/files/ruby.png
new file mode 100644
index 000000000..f59b7c436
Binary files /dev/null and b/public/images/files/ruby.png differ
diff --git a/public/images/files/text.png b/public/images/files/text.png
new file mode 100644
index 000000000..813f712f7
Binary files /dev/null and b/public/images/files/text.png differ
diff --git a/public/images/files/xml.png b/public/images/files/xml.png
new file mode 100644
index 000000000..0c76bd129
Binary files /dev/null and b/public/images/files/xml.png differ
diff --git a/public/images/files/zip.png b/public/images/files/zip.png
new file mode 100644
index 000000000..8606ff0fd
Binary files /dev/null and b/public/images/files/zip.png differ
diff --git a/public/images/pdf.png b/public/images/pdf.png
deleted file mode 100644
index 68c9bada8..000000000
Binary files a/public/images/pdf.png and /dev/null differ
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index a8d8736fd..f4bd10218 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -665,7 +665,6 @@ vertical-align: middle;
.icon-move { background-image: url(../images/move.png); }
.icon-save { background-image: url(../images/save.png); }
.icon-cancel { background-image: url(../images/cancel.png); }
-.icon-file { background-image: url(../images/file.png); }
.icon-folder { background-image: url(../images/folder.png); }
.open .icon-folder { background-image: url(../images/folder_open.png); }
.icon-package { background-image: url(../images/package.png); }
@@ -692,6 +691,21 @@ vertical-align: middle;
.icon-report { background-image: url(../images/report.png); }
.icon-comment { background-image: url(../images/comment.png); }
+.icon-file { background-image: url(../images/files/default.png); }
+.icon-file.text-plain { background-image: url(../images/files/text.png); }
+.icon-file.text-x-c { background-image: url(../images/files/c.png); }
+.icon-file.text-x-csharp { background-image: url(../images/files/csharp.png); }
+.icon-file.text-x-php { background-image: url(../images/files/php.png); }
+.icon-file.text-x-ruby { background-image: url(../images/files/ruby.png); }
+.icon-file.text-xml { background-image: url(../images/files/xml.png); }
+.icon-file.image-gif { background-image: url(../images/files/image.png); }
+.icon-file.image-jpeg { background-image: url(../images/files/image.png); }
+.icon-file.image-png { background-image: url(../images/files/image.png); }
+.icon-file.image-tiff { background-image: url(../images/files/image.png); }
+.icon-file.application-pdf { background-image: url(../images/files/pdf.png); }
+.icon-file.application-zip { background-image: url(../images/files/zip.png); }
+.icon-file.application-x-gzip { background-image: url(../images/files/zip.png); }
+
.icon22-projects { background-image: url(../images/22x22/projects.png); }
.icon22-users { background-image: url(../images/22x22/users.png); }
.icon22-tracker { background-image: url(../images/22x22/tracker.png); }
diff --git a/test/functional/repositories_subversion_controller_test.rb b/test/functional/repositories_subversion_controller_test.rb
index c2bb40367..aef8c2ef2 100644
--- a/test/functional/repositories_subversion_controller_test.rb
+++ b/test/functional/repositories_subversion_controller_test.rb
@@ -64,6 +64,7 @@ class RepositoriesSubversionControllerTest < Test::Unit::TestCase
entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
assert_equal 'file', entry.kind
assert_equal 'subversion_test/helloworld.c', entry.path
+ assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ }
end
def test_browse_at_given_revision
diff --git a/test/unit/lib/redmine/mime_type_test.rb b/test/unit/lib/redmine/mime_type_test.rb
new file mode 100644
index 000000000..79d086944
--- /dev/null
+++ b/test/unit/lib/redmine/mime_type_test.rb
@@ -0,0 +1,61 @@
+# Redmine - project management software
+# Copyright (C) 2006-2009 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../../../test_helper'
+
+class Redmine::MimeTypeTest < Test::Unit::TestCase
+
+ def test_of
+ to_test = {'test.unk' => nil,
+ 'test.txt' => 'text/plain',
+ 'test.c' => 'text/x-c',
+ }
+ to_test.each do |name, expected|
+ assert_equal expected, Redmine::MimeType.of(name)
+ end
+ end
+
+ def test_css_class_of
+ to_test = {'test.unk' => nil,
+ 'test.txt' => 'text-plain',
+ 'test.c' => 'text-x-c',
+ }
+ to_test.each do |name, expected|
+ assert_equal expected, Redmine::MimeType.css_class_of(name)
+ end
+ end
+
+ def test_main_mimetype_of
+ to_test = {'test.unk' => nil,
+ 'test.txt' => 'text',
+ 'test.c' => 'text',
+ }
+ to_test.each do |name, expected|
+ assert_equal expected, Redmine::MimeType.main_mimetype_of(name)
+ end
+ end
+
+ def test_is_type
+ to_test = {['text', 'test.unk'] => false,
+ ['text', 'test.txt'] => true,
+ ['text', 'test.c'] => true,
+ }
+ to_test.each do |args, expected|
+ assert_equal expected, Redmine::MimeType.is_type?(*args)
+ end
+ end
+end