module Locomotive
module Steam
module Middlewares
class PageEditing
include Locomotive::Engine.routes.url_helpers
def initialize(app, opts = {})
@app = app
end
def call(env)
disable_live_editing_if_not_html(env)
status, headers, response = @app.call(env)
site, mounted_on, page, locale, live_editing = env['steam.site'], env['steam.mounted_on'], env['steam.page'], env['steam.locale'].to_s, env['steam.live_editing']
if editable?(page, response, live_editing)
html = %(
)
response.first.gsub!('', %(#{html}))
# new way of letting the parent window know about the status of the preview
response.first.gsub!('