= quartermaster
* http://contentfree.rubyforge.org/quartermaster
== DESCRIPTION:
A collection of shortcuts and helpers for leveraging a request's env in Rails, such as including a browser-specific stylesheet if one exists or putting a short version of the user agent in the CSS classes of the body tag.
This eliminates the need for most hacks or conditional comments since you can now get browser-specific with your CSS rules (ex. body.ie6 div { ... })
== FEATURES/PROBLEMS:
* Short user agents for major browsers
* Detect and include browser-specific stylesheets
* Add short user agent to CSS classes which includes OS and browser info
== SYNOPSIS:
# Including classes in the body tag of an HTML layout when making a request with IE6/Win:
<body class="<%= user_agent_for_css %>"> #=> Results in: <body class="win ie ie6">
# Including browser-specific stylesheets, using Firefox 2 and a stylesheet at public/stylesheets/browsers/firefox2.css. It
# only includes stylesheets if they exist. Will look for stylesheets for the base browser - "firefox" - as well as
# version-specific - "firefox2"
<head>
<%= stylesheet_link_tag_for_browser %> #=> results in a link tag for the stylesheet(s) for the requesting browser
</head>
== CAVEATS:
If you use user_agent_for_css, you'll lose the ability to (usefully) page cache since the first requester's browser information would get cached.
Another trade-off if you're using stylesheet_link_tag_for_browser is that you have multiple stylesheet requests. If you want to consolidate your requests per page, don't use stylesheet_link_tag_for_browser and instead use a combination of user_agent_for_css and body.<short user agent> in your rules
== INSTALL:
* sudo gem install quartermaster
* In config/environment.rb (or something in config/initializers/), just require 'quartermaster'. It automatically adds its helpers to ActionView::Base
== LICENSE:
(The MIT License)
Copyright (c) 2008 FIX
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* http://contentfree.rubyforge.org/quartermaster
== DESCRIPTION:
A collection of shortcuts and helpers for leveraging a request's env in Rails, such as including a browser-specific stylesheet if one exists or putting a short version of the user agent in the CSS classes of the body tag.
This eliminates the need for most hacks or conditional comments since you can now get browser-specific with your CSS rules (ex. body.ie6 div { ... })
== FEATURES/PROBLEMS:
* Short user agents for major browsers
* Detect and include browser-specific stylesheets
* Add short user agent to CSS classes which includes OS and browser info
== SYNOPSIS:
# Including classes in the body tag of an HTML layout when making a request with IE6/Win:
<body class="<%= user_agent_for_css %>"> #=> Results in: <body class="win ie ie6">
# Including browser-specific stylesheets, using Firefox 2 and a stylesheet at public/stylesheets/browsers/firefox2.css. It
# only includes stylesheets if they exist. Will look for stylesheets for the base browser - "firefox" - as well as
# version-specific - "firefox2"
<head>
<%= stylesheet_link_tag_for_browser %> #=> results in a link tag for the stylesheet(s) for the requesting browser
</head>
== CAVEATS:
If you use user_agent_for_css, you'll lose the ability to (usefully) page cache since the first requester's browser information would get cached.
Another trade-off if you're using stylesheet_link_tag_for_browser is that you have multiple stylesheet requests. If you want to consolidate your requests per page, don't use stylesheet_link_tag_for_browser and instead use a combination of user_agent_for_css and body.<short user agent> in your rules
== INSTALL:
* sudo gem install quartermaster
* In config/environment.rb (or something in config/initializers/), just require 'quartermaster'. It automatically adds its helpers to ActionView::Base
== LICENSE:
(The MIT License)
Copyright (c) 2008 FIX
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.