Project

General

Profile

Patch #29359 » replace-mime-types-with-mini_mime.diff

Go MAEDA, 2018-08-11 08:01

View differences:

Gemfile (working copy)
gem "rails", "5.2.1"
gem "coderay", "~> 1.1.1"
gem "request_store", "1.0.5"
gem "mime-types", "~> 3.0"
gem "mini_mime"
gem "actionpack-xml_parser"
gem "roadie-rails", "~> 1.3.0"
gem "roadie", "~> 3.2.1"
lib/redmine/mime_type.rb (working copy)
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'mime/types'
module Redmine
module MimeType
......
# returns mime type for name or nil if unknown
def self.of(name)
return nil unless name.present?
if m = name.to_s.match(/(^|\.)([^\.]+)$/)
extension = m[2].downcase
@known_types ||= Hash.new do |h, ext|
type = EXTENSIONS[ext]
type ||= MIME::Types.type_for(ext).first.to_s.presence
h[ext] = type
end
@known_types[extension]
end
ext = File.extname(name)[1..-1].to_s.downcase
EXTENSIONS[ext] || MiniMime.lookup_by_filename(name).try(:content_type)
end
# Returns the css class associated to
(3-3/7)