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)
|
2009-10-22 20:25:15 -04:00
|
|
|
end
|
2010-01-20 18:22:40 -05:00
|
|
|
|
|
|
|
@app.call(env)
|
2009-10-22 20:25:15 -04:00
|
|
|
end
|
|
|
|
end
|