From 9c3a6e074dc5c0376e30c40a61727e75c360a580 Mon Sep 17 00:00:00 2001 From: Hendrik Mans Date: Fri, 24 Feb 2012 14:33:24 +0100 Subject: [PATCH] Provide App.with_local_files --- lib/schnitzelpress/app.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/schnitzelpress/app.rb b/lib/schnitzelpress/app.rb index e41b3fc..4886010 100644 --- a/lib/schnitzelpress/app.rb +++ b/lib/schnitzelpress/app.rb @@ -1,13 +1,13 @@ module SchnitzelPress class App < Sinatra::Base + STATIC_PATHS = ["/favicon.ico", "/img", "/js", '/moo.txt'] + set :views, ['./views/', File.expand_path('../../views/', __FILE__)] set :public_folder, File.expand_path('../../public/', __FILE__) - # use SchnitzelPress::Static use Rack::ShowExceptions - use Rack::Cache use Rack::StaticCache, - :urls => ["/favicon.ico", "/img", "/js"], + :urls => STATIC_PATHS, :root => File.expand_path('../../public/', __FILE__) use Rack::MethodOverride use Rack::Session::Cookie @@ -42,5 +42,12 @@ def cache_for(time) not_found do haml :"404" end + + def self.with_local_files + Rack::Cascade.new([ + Rack::StaticCache.new(self, :urls => STATIC_PATHS, :root => './public'), + self + ]) + end end end