##// END OF EJS Templates
Adds mime type specific css classes to the SCM browser....
Jean-Philippe Lang -
r2580:43200e21220d
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,61
1 # Redmine - project management software
2 # Copyright (C) 2006-2009 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require File.dirname(__FILE__) + '/../../../test_helper'
19
20 class Redmine::MimeTypeTest < Test::Unit::TestCase
21
22 def test_of
23 to_test = {'test.unk' => nil,
24 'test.txt' => 'text/plain',
25 'test.c' => 'text/x-c',
26 }
27 to_test.each do |name, expected|
28 assert_equal expected, Redmine::MimeType.of(name)
29 end
30 end
31
32 def test_css_class_of
33 to_test = {'test.unk' => nil,
34 'test.txt' => 'text-plain',
35 'test.c' => 'text-x-c',
36 }
37 to_test.each do |name, expected|
38 assert_equal expected, Redmine::MimeType.css_class_of(name)
39 end
40 end
41
42 def test_main_mimetype_of
43 to_test = {'test.unk' => nil,
44 'test.txt' => 'text',
45 'test.c' => 'text',
46 }
47 to_test.each do |name, expected|
48 assert_equal expected, Redmine::MimeType.main_mimetype_of(name)
49 end
50 end
51
52 def test_is_type
53 to_test = {['text', 'test.unk'] => false,
54 ['text', 'test.txt'] => true,
55 ['text', 'test.c'] => true,
56 }
57 to_test.each do |args, expected|
58 assert_equal expected, Redmine::MimeType.is_type?(*args)
59 end
60 end
61 end
@@ -13,7 +13,7
13 <% end %>
13 <% end %>
14 <%= link_to h(entry.name),
14 <%= link_to h(entry.name),
15 {:action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => to_path_param(entry.path), :rev => @rev},
15 {:action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => to_path_param(entry.path), :rev => @rev},
16 :class => (entry.is_dir? ? 'icon icon-folder' : 'icon icon-file')%>
16 :class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(entry.name)}")%>
17 </td>
17 </td>
18 <td class="size"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>
18 <td class="size"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>
19 <% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %>
19 <% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %>
@@ -24,6 +24,7 module Redmine
24 'text/html' => 'html,htm,xhtml',
24 'text/html' => 'html,htm,xhtml',
25 'text/jsp' => 'jsp',
25 'text/jsp' => 'jsp',
26 'text/x-c' => 'c,cpp,cc,h,hh',
26 'text/x-c' => 'c,cpp,cc,h,hh',
27 'text/x-csharp' => 'cs',
27 'text/x-java' => 'java',
28 'text/x-java' => 'java',
28 'text/x-javascript' => 'js',
29 'text/x-javascript' => 'js',
29 'text/x-html-template' => 'rhtml',
30 'text/x-html-template' => 'rhtml',
@@ -41,6 +42,9 module Redmine
41 'image/tiff' => 'tiff,tif',
42 'image/tiff' => 'tiff,tif',
42 'image/x-ms-bmp' => 'bmp',
43 'image/x-ms-bmp' => 'bmp',
43 'image/x-xpixmap' => 'xpm',
44 'image/x-xpixmap' => 'xpm',
45 'application/pdf' => 'pdf',
46 'application/zip' => 'zip',
47 'application/x-gzip' => 'gz',
44 }.freeze
48 }.freeze
45
49
46 EXTENSIONS = MIME_TYPES.inject({}) do |map, (type, exts)|
50 EXTENSIONS = MIME_TYPES.inject({}) do |map, (type, exts)|
@@ -55,6 +59,13 module Redmine
55 EXTENSIONS[m[2].downcase] if m
59 EXTENSIONS[m[2].downcase] if m
56 end
60 end
57
61
62 # Returns the css class associated to
63 # the mime type of name
64 def self.css_class_of(name)
65 mime = of(name)
66 mime && mime.gsub('/', '-')
67 end
68
58 def self.main_mimetype_of(name)
69 def self.main_mimetype_of(name)
59 mimetype = of(name)
70 mimetype = of(name)
60 mimetype.split('/').first if mimetype
71 mimetype.split('/').first if mimetype
@@ -665,7 +665,6 vertical-align: middle;
665 .icon-move { background-image: url(../images/move.png); }
665 .icon-move { background-image: url(../images/move.png); }
666 .icon-save { background-image: url(../images/save.png); }
666 .icon-save { background-image: url(../images/save.png); }
667 .icon-cancel { background-image: url(../images/cancel.png); }
667 .icon-cancel { background-image: url(../images/cancel.png); }
668 .icon-file { background-image: url(../images/file.png); }
669 .icon-folder { background-image: url(../images/folder.png); }
668 .icon-folder { background-image: url(../images/folder.png); }
670 .open .icon-folder { background-image: url(../images/folder_open.png); }
669 .open .icon-folder { background-image: url(../images/folder_open.png); }
671 .icon-package { background-image: url(../images/package.png); }
670 .icon-package { background-image: url(../images/package.png); }
@@ -692,6 +691,21 vertical-align: middle;
692 .icon-report { background-image: url(../images/report.png); }
691 .icon-report { background-image: url(../images/report.png); }
693 .icon-comment { background-image: url(../images/comment.png); }
692 .icon-comment { background-image: url(../images/comment.png); }
694
693
694 .icon-file { background-image: url(../images/files/default.png); }
695 .icon-file.text-plain { background-image: url(../images/files/text.png); }
696 .icon-file.text-x-c { background-image: url(../images/files/c.png); }
697 .icon-file.text-x-csharp { background-image: url(../images/files/csharp.png); }
698 .icon-file.text-x-php { background-image: url(../images/files/php.png); }
699 .icon-file.text-x-ruby { background-image: url(../images/files/ruby.png); }
700 .icon-file.text-xml { background-image: url(../images/files/xml.png); }
701 .icon-file.image-gif { background-image: url(../images/files/image.png); }
702 .icon-file.image-jpeg { background-image: url(../images/files/image.png); }
703 .icon-file.image-png { background-image: url(../images/files/image.png); }
704 .icon-file.image-tiff { background-image: url(../images/files/image.png); }
705 .icon-file.application-pdf { background-image: url(../images/files/pdf.png); }
706 .icon-file.application-zip { background-image: url(../images/files/zip.png); }
707 .icon-file.application-x-gzip { background-image: url(../images/files/zip.png); }
708
695 .icon22-projects { background-image: url(../images/22x22/projects.png); }
709 .icon22-projects { background-image: url(../images/22x22/projects.png); }
696 .icon22-users { background-image: url(../images/22x22/users.png); }
710 .icon22-users { background-image: url(../images/22x22/users.png); }
697 .icon22-tracker { background-image: url(../images/22x22/tracker.png); }
711 .icon22-tracker { background-image: url(../images/22x22/tracker.png); }
@@ -64,6 +64,7 class RepositoriesSubversionControllerTest < Test::Unit::TestCase
64 entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
64 entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
65 assert_equal 'file', entry.kind
65 assert_equal 'file', entry.kind
66 assert_equal 'subversion_test/helloworld.c', entry.path
66 assert_equal 'subversion_test/helloworld.c', entry.path
67 assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ }
67 end
68 end
68
69
69 def test_browse_at_given_revision
70 def test_browse_at_given_revision
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now