# Copyright (c) 2010-2011, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. module Rack class InternetExplorerVersion def initialize(app, options={}) @app = app @options = options end def call(env) if env["HTTP_USER_AGENT"] =~ /MSIE/ && ie_version(env["HTTP_USER_AGENT"]) < @options[:minimum] html = <<-HTML Diaspora doesn't support your version of Internet Explorer. Try Firefox, Chrome or Opera!

Diaspora doesn't support your version of Internet Explorer.

You can use one of these browsers (and many more): HTML return [200, {"Content-Type" => "text/html", "Content-Length" => html.size.to_s}, Rack::Response.new([html])] end @app.call(env) end def ie_version(ua_string) ua_string.match(/MSIE ?(\S+)/)[1].to_f end end end