Sha256: 8efdade57e8bba9928040e70b26d9e80c6408f15f6aeb047ec50d2491682d940

Contents?: true

Size: 733 Bytes

Versions: 14

Compression:

Stored size: 733 Bytes

Contents

module Rack
  # Rack::Facebook formats HTTP responses to remove certain status codes
  # and HTML entities that are invalid as FBML responses.
  class Facebook
    def initialize(app)
      @_app = app
    end

    def call(env)
      code, headers, body = @_app.call(env)
      
      if code >= 500 && code < 600
        code = 200
      end
      
      contents = ''
      body.each {|p| contents += p }
      
      contents.gsub!(/txmt:\/\//, 'http://textmate.local/')
      contents.gsub!('<body>', '<div class="body">')
      contents.gsub!('</body>', '</div>')
      contents.gsub!('<wbr/>', '')
      
      headers['Content-Length'] = contents.content_length.to_s
      
      [ code, headers, contents ]
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kiss-1.8.9 lib/kiss/rack/facebook.rb
kiss-1.8.8 lib/kiss/rack/facebook.rb
kiss-1.8.7 lib/kiss/rack/facebook.rb
kiss-1.8.6 lib/kiss/rack/facebook.rb
kiss-1.8.5 lib/kiss/rack/facebook.rb
kiss-1.8.4 lib/kiss/rack/facebook.rb
kiss-1.8.3 lib/kiss/rack/facebook.rb
kiss-1.8.2 lib/kiss/rack/facebook.rb
kiss-1.8.1 lib/kiss/rack/facebook.rb
kiss-1.8 lib/kiss/rack/facebook.rb
kiss-1.7.4 lib/kiss/rack/facebook.rb
kiss-1.7.2 lib/kiss/rack/facebook.rb
kiss-1.7.1 lib/kiss/rack/facebook.rb
kiss-1.7 lib/kiss/rack/facebook.rb