Drop ruby-mime-types support in favour of Rack::MIME.

This commit is contained in:
Paul van Tilburg 2011-11-15 17:22:57 +01:00
parent 08a7ef3c01
commit 52c5b858f5
2 changed files with 9 additions and 12 deletions

1
README
View File

@ -28,7 +28,6 @@ The following Ruby libraries are required:
* ActionPack (>= 2.3) for ActionView * ActionPack (>= 2.3) for ActionView
* ActiveSupport (>= 2.3) * ActiveSupport (>= 2.3)
* MIME-Types
* Rack (for deployment using Apache/Rackup) * Rack (for deployment using Apache/Rackup)
* SASS * SASS

View File

@ -14,7 +14,6 @@ require "action_view"
require "active_support" require "active_support"
require "camping" require "camping"
require "markaby" require "markaby"
require "mime/types"
require "pathname" require "pathname"
require "sass/plugin/rack" require "sass/plugin/rack"
@ -986,10 +985,10 @@ module StopTime::Controllers
# Sets the headers such that the web server will fetch and offer # Sets the headers such that the web server will fetch and offer
# the file identified by the _path_ relative to the +public/+ subdirectory. # the file identified by the _path_ relative to the +public/+ subdirectory.
def get(path) def get(path)
mime_type = MIME::Types.type_for(path).first
@headers['Content-Type'] = mime_type.nil? ? "text/plain" : mime_type.to_s
unless path.include? ".." unless path.include? ".."
@headers['X-Sendfile'] = (PUBLIC_DIR + path).to_s full_path = PUBLIC_DIR + path
@headers['Content-Type'] = Rack::Mime.mime_type(full_path.extname)
@headers['X-Sendfile'] = full_path.to_s
else else
@status = "403" @status = "403"
"Error 403: Invalid path: #{path}" "Error 403: Invalid path: #{path}"
@ -1051,9 +1050,8 @@ module StopTime::Views
if @tasks.empty? if @tasks.empty?
p do p do
text "No customers, projects or tasks found! Set them up " "No customers, projects or tasks found! Set them up " +
a "here", :href => R(CustomersNew) "#{a "here", :href => R(CustomersNew)}."
text "."
end end
else else
@tasks.keys.sort_by { |c| c.name }.each do |customer| @tasks.keys.sort_by { |c| c.name }.each do |customer|