Created
January 16, 2010 13:36
-
-
Save lachlanhardy/278823 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| helpers do | |
| def mobile_request? | |
| mobile_user_agent_patterns.any? {|r| request.env['HTTP_USER_AGENT'] =~ r} | |
| end | |
| def mobile_user_agent_patterns | |
| [ | |
| /AppleWebKit.*Mobile/, | |
| /Android.*AppleWebKit/ | |
| ] | |
| end | |
| end | |
| before do | |
| !mobile_request? ? @mobile = ".mobile" : @mobile = "" | |
| end | |
| # homepage | |
| get '/' do | |
| haml :"index#{@mobile}", :layout => :"layout#{@mobile}" | |
| end | |
| # And then I just have an index.haml & a index.mobile.haml as well as a layout.haml and a layout.mobile.haml | |
| # Still needs some tidying up - but it works! And that's good enough for this hour. Bed time! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment