git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2672 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/0.9.0
@@ -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)}")%> | |||
</td> | |||
<td class="size"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td> | |||
<% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %> |
@@ -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 |
@@ -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); } |
@@ -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 |
@@ -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 |