Patch #29359 » replace-mime-types-with-mini_mime.diff
Gemfile (working copy) | ||
---|---|---|
7 | 7 |
gem "rails", "5.2.1" |
8 | 8 |
gem "coderay", "~> 1.1.1" |
9 | 9 |
gem "request_store", "1.0.5" |
10 |
gem "mime-types", "~> 3.0"
|
|
10 |
gem "mini_mime"
|
|
11 | 11 |
gem "actionpack-xml_parser" |
12 | 12 |
gem "roadie-rails", "~> 1.3.0" |
13 | 13 |
gem "roadie", "~> 3.2.1" |
lib/redmine/mime_type.rb (working copy) | ||
---|---|---|
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 |
require 'mime/types' |
|
19 | ||
20 | 18 |
module Redmine |
21 | 19 |
module MimeType |
22 | 20 | |
... | ... | |
62 | 60 |
# returns mime type for name or nil if unknown |
63 | 61 |
def self.of(name) |
64 | 62 |
return nil unless name.present? |
65 |
if m = name.to_s.match(/(^|\.)([^\.]+)$/) |
|
66 |
extension = m[2].downcase |
|
67 |
@known_types ||= Hash.new do |h, ext| |
|
68 |
type = EXTENSIONS[ext] |
|
69 |
type ||= MIME::Types.type_for(ext).first.to_s.presence |
|
70 |
h[ext] = type |
|
71 |
end |
|
72 |
@known_types[extension] |
|
73 |
end |
|
63 |
ext = File.extname(name)[1..-1].to_s.downcase |
|
64 |
EXTENSIONS[ext] || MiniMime.lookup_by_filename(name).try(:content_type) |
|
74 | 65 |
end |
75 | 66 | |
76 | 67 |
# Returns the css class associated to |