lib/spontaneous/rack/middleware/scope.rb in spontaneous-0.2.0.beta9 vs lib/spontaneous/rack/middleware/scope.rb in spontaneous-0.2.0.beta10

- old
+ new

@@ -39,28 +39,40 @@ response end end POWERED_BY = { - "X-Powered-By" => "Spontaneous CMS v#{Spontaneous::VERSION}" + "X-Powered-By" => "Spontaneous v#{Spontaneous::VERSION} <http://spontaneous.io>" } 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 + env[RENDERER] = renderer + env[REVISION] = revision = @site.published_revision @site.model.with_published(@site) do status, headers, body = @app.call(env) end [status, headers.merge(POWERED_BY), body] + end + + def renderer + return renderer_for_revision if development? + @renderer ||= renderer_for_revision + end + + def renderer_for_revision + Spontaneous::Output.published_renderer(@site) + end + + def development? + Spontaneous.development? end end end end