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:
Thomas Reynolds 2013-01-22 23:14:15 -08:00
commit 2d28272396
2 changed files with 3 additions and 8 deletions

View file

@ -251,7 +251,7 @@ module Middleman
current_path = resource.destination_path
# 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
# Write out the contents of the page
@ -280,6 +280,7 @@ module Middleman
# @return [void]
def mime_type(type, value=nil)
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] == ?.
return ::Rack::Mime.mime_type(type, nil) unless value
::Rack::Mime::MIME_TYPES[type] = value
@ -314,7 +315,7 @@ module Middleman
# @param [Hash] params
# @return [void]
def content_type(res, type, params={})
return res['Content-Type'] unless type
return unless type
default = params.delete :default
mime_type = mime_type(type) || default
throw "Unknown media type: %p" % type if mime_type.nil?

View file

@ -102,12 +102,6 @@ module Middleman
File.extname(path)
end
# Mime type of the path
# @return [String]
def mime_type
app.mime_type ext
end
# Render this resource
# @return [String]
def render(opts={}, locs={}, &block)