Skip to content

Instantly share code, notes, and snippets.

@brynary
Created July 20, 2009 18:18
Show Gist options
  • Save brynary/150489 to your computer and use it in GitHub Desktop.
Save brynary/150489 to your computer and use it in GitHub Desktop.
class AdFrame < Rails::Rack::Metal
def self.call(env)
refresher = AdFrameApp.new
refresher.call(env)
end
end
class AdFrameApp
def call(env)
if env["REQUEST_URI"] =~ %r|^/ads/iframe/(.+)$|
prepare(env, $1)
html = render_ad_frame
[200, {"Content-Type" => "text/html"}, html]
else
[404, { "Content-Type" => "text/html" }, "Not Found"]
end
end
# to setup the environment
def prepare(env, url_fragment)
request = Rack::Request.new(env)
@doubleclick = RackDoubleclickPresenter.new(request, url_fragment)
end
def render_ad_frame
%Q|
<html><head>
<style type="text/css" media="screen">
a img{ border:1px solid #999; }
body{ background:transparent; margin:0; padding:0 }
.clickapic a img{ border:none; behavior: url( /htc/iepngfix_v2.htc ); }
</style>
</head><body>
#{@doubleclick.to_html}
</body></html>
|
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment