##// END OF EJS Templates
Added a few extensions/mimetypes....
Jean-Philippe Lang -
r1114:6d109258c909
parent child
Show More
@@ -19,7 +19,7 module Redmine
19 19 module MimeType
20 20
21 21 MIME_TYPES = {
22 'text/plain' => 'txt,tpl,properties',
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/x-c' => 'c,cpp,h',
@@ -30,25 +30,28 module Redmine
30 30 'text/x-php' => 'php,php3,php4,php5',
31 31 'text/x-python' => 'py',
32 32 'text/x-ruby' => 'rb,rbw,ruby,rake',
33 'text/x-csh' => 'csh',
33 34 'text/x-sh' => 'sh',
34 'text/xml' => 'xml',
35 'text/xml' => 'xml,xsd,mxml',
35 36 'text/yaml' => 'yml,yaml',
36 37 'image/gif' => 'gif',
37 38 'image/jpeg' => 'jpg,jpeg,jpe',
38 39 'image/png' => 'png',
39 'image/tiff' => 'tiff,tif'
40 'image/tiff' => 'tiff,tif',
41 'image/x-ms-bmp' => 'bmp',
42 'image/x-xpixmap' => 'xpm',
40 43 }.freeze
41 44
42 45 EXTENSIONS = MIME_TYPES.inject({}) do |map, (type, exts)|
43 exts.split(',').each {|ext| map[ext] = type}
46 exts.split(',').each {|ext| map[ext.strip] = type}
44 47 map
45 48 end
46 49
47 50 # returns mime type for name or nil if unknown
48 51 def self.of(name)
49 52 return nil unless name
50 m = name.to_s.match(/\.([^\.]+)$/)
51 EXTENSIONS[m[1]] if m
53 m = name.to_s.match(/(^|\.)([^\.]+)$/)
54 EXTENSIONS[m[2].downcase] if m
52 55 end
53 56
54 57 def self.main_mimetype_of(name)
General Comments 0
You need to be logged in to leave comments. Login now