class BallonizerProxy
A PrettyProxy (that is a Rack::Proxy, that is a rack app) subclass that use an Ballonizer instance to allow the addition of speech bubbles (text ballons) over any (X)HTML page that is requested through it.
The first three parameters are equal to the PrettyProxy ones, and the last two equal the Ballonizer ones. This class only deal in a special way with the *_asset_path_for_link and form_handler_url that are joined with the proxy site (scheme+host+port) to make a absolute url if the original values are relative.
@author Henrique Becker
Attributes
ballonizer[R]
Public Class Methods
new(proxy_path, original_domain, original_paths, database, settings)
click to toggle source
Calls superclass method
# File lib/ballonizer_proxy.rb, line 21 def initialize(proxy_path, original_domain, original_paths, database, settings) super(proxy_path, original_domain, original_paths, true) @ballonizer = Ballonizer.new(database, settings) end
Public Instance Methods
sugared_rewrite_response(triplet, requested_to_proxy_env, rewritten_env)
click to toggle source
# File lib/ballonizer_proxy.rb, line 26 def sugared_rewrite_response(triplet, requested_to_proxy_env, rewritten_env) status, headers, page = triplet original_url = Rack::Request.new(rewritten_env).url requested_to_proxy_url = Rack::Request.new(requested_to_proxy_env).url proxy_site = Addressable::URI.parse(requested_to_proxy_url).site absolute_settings = {} [ :css_asset_path_for_link, :js_asset_path_for_link, :form_handler_url].each do | conf_name | relative_uri = @ballonizer.settings[conf_name] next unless relative_uri absolute_settings[conf_name] = Addressable::URI.parse(proxy_site) .join(relative_uri).to_s end page = @ballonizer.ballonize_page( page, original_url, headers['content-type'], absolute_settings ) # This makes the browser always request a new copy of the document (status # 200) and avoid 304 status without body to us ballonize (and the ballons # can be updated without the original page being updated so isn't # interesting to preserve the original cache control) Workarounds.make_uncacheable(headers) triplet = [status, headers, page] end