1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/lib/middleman/rack/static.rb

18 lines
597 B
Ruby
Raw Normal View History

2010-01-20 18:22:40 -05:00
class Middleman::Rack::Static
def initialize(app, options={})
@app = app
end
2009-11-24 17:24:20 -05:00
2010-01-20 18:22:40 -05:00
def call(env)
public_file_path = File.join(Middleman::Base.public, env["PATH_INFO"])
view_file_path = File.join(Middleman::Base.views, env["PATH_INFO"])
2009-11-30 14:32:02 -05:00
2010-01-20 18:22:40 -05:00
if File.exists?(public_file_path) && !File.directory?(public_file_path)
env["DOWNSTREAM"] = ::Rack::File.new(Middleman::Base.public).call(env)
elsif File.exists?(view_file_path) && !File.directory?(view_file_path)
env["DOWNSTREAM"] = ::Rack::File.new(Middleman::Base.views).call(env)
end
2010-01-20 18:22:40 -05:00
@app.call(env)
end
end