Merge pull request #736 from bhollis/master
Serve extensionless files or dotfiles with text/plain MIME type, and remove Sitemap::Resource#mime_type.
This commit is contained in:
commit
2d28272396
|
@ -251,7 +251,7 @@ module Middleman
|
||||||
current_path = resource.destination_path
|
current_path = resource.destination_path
|
||||||
|
|
||||||
# Set a HTTP content type based on the request's extensions
|
# Set a HTTP content type based on the request's extensions
|
||||||
content_type(res, resource.mime_type)
|
content_type(res, mime_type(resource.ext))
|
||||||
|
|
||||||
begin
|
begin
|
||||||
# Write out the contents of the page
|
# Write out the contents of the page
|
||||||
|
@ -280,6 +280,7 @@ module Middleman
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def mime_type(type, value=nil)
|
def mime_type(type, value=nil)
|
||||||
return type if type.nil? || type.to_s.include?('/')
|
return type if type.nil? || type.to_s.include?('/')
|
||||||
|
return ::Rack::Mime.mime_type('.txt') if type.empty?
|
||||||
type = ".#{type}" unless type.to_s[0] == ?.
|
type = ".#{type}" unless type.to_s[0] == ?.
|
||||||
return ::Rack::Mime.mime_type(type, nil) unless value
|
return ::Rack::Mime.mime_type(type, nil) unless value
|
||||||
::Rack::Mime::MIME_TYPES[type] = value
|
::Rack::Mime::MIME_TYPES[type] = value
|
||||||
|
@ -314,7 +315,7 @@ module Middleman
|
||||||
# @param [Hash] params
|
# @param [Hash] params
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def content_type(res, type, params={})
|
def content_type(res, type, params={})
|
||||||
return res['Content-Type'] unless type
|
return unless type
|
||||||
default = params.delete :default
|
default = params.delete :default
|
||||||
mime_type = mime_type(type) || default
|
mime_type = mime_type(type) || default
|
||||||
throw "Unknown media type: %p" % type if mime_type.nil?
|
throw "Unknown media type: %p" % type if mime_type.nil?
|
||||||
|
|
|
@ -102,12 +102,6 @@ module Middleman
|
||||||
File.extname(path)
|
File.extname(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Mime type of the path
|
|
||||||
# @return [String]
|
|
||||||
def mime_type
|
|
||||||
app.mime_type ext
|
|
||||||
end
|
|
||||||
|
|
||||||
# Render this resource
|
# Render this resource
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def render(opts={}, locs={}, &block)
|
def render(opts={}, locs={}, &block)
|
||||||
|
|
Loading…
Reference in a new issue