##// END OF EJS Templates
Adds .erb mime type....
Jean-Philippe Lang -
r2603:24875be705fd
parent child
Show More
@@ -1,81 +1,81
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 module Redmine
19 19 module MimeType
20 20
21 21 MIME_TYPES = {
22 22 'text/plain' => 'txt,tpl,properties,patch,diff,ini,readme,install,upgrade',
23 23 'text/css' => 'css',
24 24 'text/html' => 'html,htm,xhtml',
25 25 'text/jsp' => 'jsp',
26 26 'text/x-c' => 'c,cpp,cc,h,hh',
27 27 'text/x-csharp' => 'cs',
28 28 'text/x-java' => 'java',
29 29 'text/x-javascript' => 'js',
30 30 'text/x-html-template' => 'rhtml',
31 31 'text/x-perl' => 'pl,pm',
32 32 'text/x-php' => 'php,php3,php4,php5',
33 33 'text/x-python' => 'py',
34 'text/x-ruby' => 'rb,rbw,ruby,rake',
34 'text/x-ruby' => 'rb,rbw,ruby,rake,erb',
35 35 'text/x-csh' => 'csh',
36 36 'text/x-sh' => 'sh',
37 37 'text/xml' => 'xml,xsd,mxml',
38 38 'text/yaml' => 'yml,yaml',
39 39 'image/gif' => 'gif',
40 40 'image/jpeg' => 'jpg,jpeg,jpe',
41 41 'image/png' => 'png',
42 42 'image/tiff' => 'tiff,tif',
43 43 'image/x-ms-bmp' => 'bmp',
44 44 'image/x-xpixmap' => 'xpm',
45 45 'application/pdf' => 'pdf',
46 46 'application/zip' => 'zip',
47 47 'application/x-gzip' => 'gz',
48 48 }.freeze
49 49
50 50 EXTENSIONS = MIME_TYPES.inject({}) do |map, (type, exts)|
51 51 exts.split(',').each {|ext| map[ext.strip] = type}
52 52 map
53 53 end
54 54
55 55 # returns mime type for name or nil if unknown
56 56 def self.of(name)
57 57 return nil unless name
58 58 m = name.to_s.match(/(^|\.)([^\.]+)$/)
59 59 EXTENSIONS[m[2].downcase] if m
60 60 end
61 61
62 62 # Returns the css class associated to
63 63 # the mime type of name
64 64 def self.css_class_of(name)
65 65 mime = of(name)
66 66 mime && mime.gsub('/', '-')
67 67 end
68 68
69 69 def self.main_mimetype_of(name)
70 70 mimetype = of(name)
71 71 mimetype.split('/').first if mimetype
72 72 end
73 73
74 74 # return true if mime-type for name is type/*
75 75 # otherwise false
76 76 def self.is_type?(type, name)
77 77 main_mimetype = main_mimetype_of(name)
78 78 type.to_s == main_mimetype
79 79 end
80 80 end
81 81 end
General Comments 0
You need to be logged in to leave comments. Login now