2012-01-16 22:59:59 +00:00
|
|
|
module Locomotive
|
|
|
|
class InlineEditorMiddleware
|
|
|
|
|
|
|
|
def initialize(app, opts = {})
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
|
|
|
response = @app.call(env)
|
|
|
|
|
|
|
|
unless response[1]['Editable'].blank?
|
|
|
|
Rails.logger.debug "==> #{ENV['PATH_INFO'].inspect}, warden ? #{env['warden'].inspect} /#{env['warden'].user} / #{env['warden'].authenticated?(:locomotive_account)}"
|
|
|
|
|
|
|
|
html = response.last.body.to_s.gsub '</body>', %(
|
2012-01-17 01:53:49 +00:00
|
|
|
<a href="_admin">Admin</a>
|
2012-01-16 22:59:59 +00:00
|
|
|
</body>
|
|
|
|
)
|
|
|
|
|
|
|
|
[response[0], response[1], [html]]
|
|
|
|
else
|
|
|
|
response
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|