Rack::Html5

Added by masone at July 15, 2010 15:08 Star_smallStar_smallStar_smallStar_smallStar_small html5, request, header, features, support, rack, browser, user-agent, version
GitHub stats:
Magnifier watcher(s)
Arrow_branch fork(s)
Wrench

About

Rack::Html5 detects the browser and its version by parsing the user agent and adds a HTTP header to the current request for each feature the browser supports.

Details

Rack::Html5 then sets the following HTTP headers:

  • HTTP_X_DETECTED_BROWSER: Browser that has been DETECTED, eg.: Firefox
  • HTTP_X_DETECTED_VERSION: Version of the browser that has been DETECTED, eg.: 3.6.6
  • HTTP_X_SUPPORTS_HTML5_WYSIWYG: WYSIWYG editable elements
  • HTTP_X_SUPPORTS_HTML5_CLASSNAME: getElementsByClassName
  • HTTP_X_SUPPORTS_HTML5_ELEMENTS: Stylable HTML5 elements
  • HTTP_X_SUPPORTS_HTML5_CANVAS: Canvas (basic support)
  • HTTP_X_SUPPORTS_HTML5_MESSAGING: Cross-document messaging
  • HTTP_X_SUPPORTS_HTML5_AUDIO: Audio element
  • HTTP_X_SUPPORTS_HTML5_VIDEO: Video element
  • HTTP_X_SUPPORTS_HTML5_TEXTAPI: Text API for canvas
  • HTTP_X_SUPPORTS_HTML5_DRAGANDDROP: Drag and drop
  • HTTP_X_SUPPORTS_HTML5_OFFLINE: Offline web applications
  • HTTP_X_SUPPORTS_HTML5_SVG: Inline SVG
  • HTTP_X_SUPPORTS_HTML5_FORMS: Form features (Web Forms 2.0)

For more information, check the README
There are also convenient rails helper methods available

Usage

gem install rack-html5
require 'rack-html5'
use Rack::Html5
app = lambda { |env| [200, { 'Content-Type' => 'text/html' }, '<html><body><p></p></body></html>'] }
run app

blog comments powered by Disqus