Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added usage and todo section.

  • Loading branch information...
commit 43f1209caba8a28cae6312800ed511c17ad9ae1c 1 parent fceeec7
@marshally marshally authored
Showing with 43 additions and 10 deletions.
  1. +43 −10 README.md
View
53 README.md
@@ -4,29 +4,62 @@
rack-modernizr is a Rack Middleware that includes the Modernizr javascript and stuffs Modernizr's output into a cookie on the first page request.
-Include it in your config.ru like so:
+# Installation
+
+Include it in your application.rb like so:
+
+ module ModernizrTestApp
+ class Application < Rails::Application
+ config.middleware.use Rack::Modernizr
+ end
+ end
+
+or in your config.ru:
+
+ # Initialize the rails application
+ MyApp::Application.initialize!
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require 'modernizr'
+
+ # WARNING: session storage is not working properly with config.ru initialization :/
use Rack::Modernizr
run MyApp::Application
-or environment.rb
+# Usage
- # Load the rails application
- require File.expand_path('../application', __FILE__)
-
- config.middleware.use Rack::Modernizr
-
- # Initialize the rails application
- MyApp::Application.initialize!
+In your rails code, Modernizr's client side detected browser functionality is now available from the Rack environment. (w00t!)
+
+ <%= request.env['X-rack-modernizr'].inspect %>
+
+or
+
+ if 1==request.env['X-rack-modernizr']['video']['h264']
+ # do stuff
+ end
+
+# Features
+
+Rack-modernizr chews up 1k of cookie data (yikes!). If you are storing session data in the database or memcache, you can avoid the cookie tax by pushing modernizr data into the session:
+
+ module ModernizrTestApp
+ class Application < Rails::Application
+ config.middleware.use Rack::Modernizr, :storage => "session"
+ end
+ end
# TODO
-Add usage section for retrieving cookie data in your application. Test against multiple permutations of Rack/Ruby.
+(in no particular order)
+- Cool kid .accessorize method, like [rack-flash](http://nakajima.github.com/rack-flash/).
+- Better unit testing for sessions and cookies.
+- Rails helper to clean up retrieval syntax
+- compression to cut down on 1k cookie storage size
+
+# Thanks
rack-modernizr was inspired by [jamesgpearce](https://github.com/jamesgpearce)'s super awesome [modernizr-server](https://github.com/jamesgpearce/modernizr-server). Some javascript was used from that project.
Please sign in to comment.
Something went wrong with that request. Please try again.