Created
August 21, 2009 14:06
-
-
Save okkez/172023 to your computer and use it in GitHub Desktop.
あなろぐ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'rack' | |
module Rack | |
class Analog | |
ANALOG =<<-HTML | |
<div style="position:absolute;top:0;right:0;border:solid;width:5%;"> | |
アナログ | |
</div> | |
HTML | |
def initialize(app, options = {}) | |
@app = app | |
end | |
def call(env) | |
status, headers, response = @app.call(env) | |
return [status, headers, response] if Object.const_defined?(:Encoding) | |
unless response.body[0].gsub!(/<body>/, "<body>\n#{ANALOG}") | |
response.body << ANALOG | |
end | |
[status, headers, response] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment