IE Filter on Rack

What?

  • Rack middleware that denies specified versions of IE.

  • Use the default template, a custom template or redirect users to another location.

Why?

  • Because progressive enhancement only goes so far.

How?

Install:

[sudo] gem install rack-denyie

Use:

require 'rack-denyie'

With default options: (Allows IE 7 or higher and displays the default template)

use Rack::DenyIE

With custom template and modified minimum version:

use Rack::DenyIE, {
 :min_version => 8,  # Allow IE 8 and higher
 :template => "/full/path/to/your/template.html"  # Custom HTML template
}

With redirection set (not well tested):

use Rack::DenyIE, {
 :redirect_url => "http://browsehappy.com/"
}

With all options:

use Rack::DenyIE, {
 :min_version => 6,  # Minimum Version :: Allows IE 6 and higher
 :template => '/full/path/to/your/template.erb',  # Custom template :: ERB or HTML
 :headline => 'Sorry, old browser alert!',  # Replaces "Your version of Internet Explorer is not supported."
 :site_name => "My Website"  # Site Name :: Replaces the default "this site" with your site name.
}

Any key/value you pass in will be available to your ERB template.

use Rack::DenyIE, {
 :my_key => "my value"
}

<%= @my_key %> #=> "my value"

Todo

  • Allow HAML templates

  • Write tests for url redirection

  • Tests need improvement

Copyright © 2009 Brad Whitcomb, Digitalstar Studios. See LICENSE for details.