##// END OF EJS Templates
Added jsp mime type....
Jean-Philippe Lang -
r1177:d09f7d73b33f
parent child
Show More
@@ -1,69 +1,70
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 'text/jsp' => 'jsp',
25 26 'text/x-c' => 'c,cpp,h',
26 27 'text/x-java' => 'java',
27 28 'text/x-javascript' => 'js',
28 29 'text/x-html-template' => 'rhtml',
29 30 'text/x-perl' => 'pl,pm',
30 31 'text/x-php' => 'php,php3,php4,php5',
31 32 'text/x-python' => 'py',
32 33 'text/x-ruby' => 'rb,rbw,ruby,rake',
33 34 'text/x-csh' => 'csh',
34 35 'text/x-sh' => 'sh',
35 36 'text/xml' => 'xml,xsd,mxml',
36 37 'text/yaml' => 'yml,yaml',
37 38 'image/gif' => 'gif',
38 39 'image/jpeg' => 'jpg,jpeg,jpe',
39 40 'image/png' => 'png',
40 41 'image/tiff' => 'tiff,tif',
41 42 'image/x-ms-bmp' => 'bmp',
42 43 'image/x-xpixmap' => 'xpm',
43 44 }.freeze
44 45
45 46 EXTENSIONS = MIME_TYPES.inject({}) do |map, (type, exts)|
46 47 exts.split(',').each {|ext| map[ext.strip] = type}
47 48 map
48 49 end
49 50
50 51 # returns mime type for name or nil if unknown
51 52 def self.of(name)
52 53 return nil unless name
53 54 m = name.to_s.match(/(^|\.)([^\.]+)$/)
54 55 EXTENSIONS[m[2].downcase] if m
55 56 end
56 57
57 58 def self.main_mimetype_of(name)
58 59 mimetype = of(name)
59 60 mimetype.split('/').first if mimetype
60 61 end
61 62
62 63 # return true if mime-type for name is type/*
63 64 # otherwise false
64 65 def self.is_type?(type, name)
65 66 main_mimetype = main_mimetype_of(name)
66 67 type.to_s == main_mimetype
67 68 end
68 69 end
69 70 end
General Comments 0
You need to be logged in to leave comments. Login now