2012-03-22 01:13:24 +00:00
|
|
|
module Locomotive
|
|
|
|
module Middlewares
|
|
|
|
class InlineEditor
|
|
|
|
|
|
|
|
def initialize(app, opts = {})
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
|
|
|
response = @app.call(env)
|
|
|
|
|
|
|
|
unless response[1]['Editable'].blank?
|
|
|
|
html = response.last.body.to_s.gsub '</body>', %(
|
|
|
|
<a href="_admin"
|
|
|
|
onmouseout="this.style.backgroundPosition='0px 0px'"
|
|
|
|
onmouseover="this.style.backgroundPosition='0px -45px'"
|
|
|
|
onmousedown="this.style.backgroundPosition='0px -90px'"
|
|
|
|
onmouseup="this.style.backgroundPosition='0px 0px'"
|
2012-03-27 22:26:32 +00:00
|
|
|
style="display: block;z-index: 1031;position: fixed;top: 10px; right: 10px;width: 48px; height: 45px;text-indent:-9999px;text-decoration:none;background: transparent url\('/assets/locomotive/icons/start.png'\) no-repeat 0 0;">
|
2012-03-22 01:13:24 +00:00
|
|
|
Admin</a>
|
|
|
|
</body>
|
|
|
|
)
|
|
|
|
[response[0], response[1], [html]]
|
|
|
|
else
|
|
|
|
response
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|