Sha256: 50aa8866c58c79bb5779a11582fefcce24c8e9bce862091d230b874d5f21a0da
Contents?: true
Size: 1.51 KB
Versions: 5
Compression:
Stored size: 1.51 KB
Contents
module Spontaneous::Rack::Middleware module Scope class Base def initialize(app, site, options = {}) raise "Missing site instance" if site.nil? @app, @site, @options = app, site, options end def call(env) env[Spontaneous::Rack::SITE] = @site call!(env) end end class Edit < Base def call!(env) response = nil @site.model.scope(nil, false) do response = @app.call(env) end response end end class Preview < Base include Spontaneous::Rack::Constants def initialize(app, site, options = {}) super @renderer = Spontaneous::Output.preview_renderer(@site) end def call!(env) env[RENDERER] = @renderer response = nil @site.model.scope(nil, true) do response = @app.call(env) end response end end POWERED_BY = { "X-Powered-By" => "Spontaneous CMS v#{Spontaneous::VERSION}" } class Front < Base include Spontaneous::Rack::Constants def initialize(app, site, options = {}) super @renderer = Spontaneous::Output.published_renderer(@site) end def call!(env) status = headers = body = nil env[RENDERER] = @renderer env[REVISION] = @site.published_revision @site.model.with_published(@site) do status, headers, body = @app.call(env) end [status, headers.merge(POWERED_BY), body] end end end end
Version data entries
5 entries across 5 versions & 1 rubygems