module Rtml::Controller::BeforeFilters protected def rtml_format def request.is_terminal? self.user_agent and (self.user_agent['OE MicroBrowser'] || self.user_agent['IO Browser']) end def request.terminal?; is_terminal?; end def request.rtml? format == :rtml || params[:format] == 'rtml' end def response.rtml? request.is_terminal? || request.format == :rtml || template.template_format == :rtml end params[:format] = 'rtml' if params[:format] == 'tml' return if params[:format] if request.format == :tml || request.is_terminal? request.format = :rtml end end def set_rtml_etag # TODO: The lines below were in RTML 1.x; see if they are necessary now that caching has been addressed. headers['Cache-Control'] = 'no-cache ' headers['ETag'] = "W/\"329-#{Time.now.to_i}#{rand(9999)}\" " end def set_rtml_headers if request.format == 'rtml' headers['content-type'] = (request.is_terminal? ? 'text/tml' : 'text/xml') headers['Expires'] = if expires_at then expires_at.call(self) else Time.at(0) # always expired end.strftime("%a, %d %b %Y %H:%M:%S GMT") end end public class << self def included(base) base.instance_eval do skip_before_filter :verify_authenticity_token before_filter :rtml_format before_filter :set_rtml_etag end end end end