Sha256: 703b975ce65ce8aa318d4386be1ece3e8de74e671bdd8653fad8d6d84fbc4031

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

require "sinatra/content_for"

module Schnitzelpress
  class App < Sinatra::Base
    STATIC_PATHS = ["/favicon.ico", "/img", "/js"]

    set :views, ['./views/', File.expand_path('../../views/', __FILE__)]
    set :public_folder, File.expand_path('../../public/', __FILE__)

    use Rack::Cache if Schnitzelpress.env.production?
    use Rack::ShowExceptions
    use Rack::StaticCache,
      :urls => STATIC_PATHS,
      :root => File.expand_path('../../public/', __FILE__)
    use Rack::MethodOverride
    use Rack::Session::Cookie

    helpers Sinatra::ContentFor
    helpers Schnitzelpress::Helpers
    include Rack::Utils
    include Schnitzelpress::Actions::Auth
    include Schnitzelpress::Actions::Assets
    include Schnitzelpress::Actions::Admin
    include Schnitzelpress::Actions::Blog

    configure do
      disable :protection
      set :logging, true
    end

    before do
      # Reload configuration before every request. I know this isn't ideal,
      # but right now it's the easiest way to get the configuration in synch
      # across multiple instances of the app.
      #
      Config.instance.reload
    end

    def fresh_when(options)
      last_modified options[:last_modified]
      etag options[:etag]
    end

    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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
schnitzelpress-0.2.1 lib/schnitzelpress/app.rb
schnitzelpress-0.2.0 lib/schnitzelpress/app.rb