Sha256: 60f08fdf569ece01c2a7ce71c39adef47a064cb1b3ffb3aa6bd8e768905f799a

Contents?: true

Size: 1.9 KB

Versions: 1

Compression:

Stored size: 1.9 KB

Contents

= schmobile

A mobile user agent detection Rack middleware.

== Redirecting

It can be configured to return the user to an explicit destination:

  use Rack::Schmobile, :redirect_to => "/mobile"

It supports string interpolation for dynamic destinations:

  use Rack::Schmobile, :redirect_to => "/mobile/#!/{{path}}"

Finally the middleware provides a request level method to determine if the client is a mobile device

  Rack::Request#is_mobile?

== Forcing mobile mode

You can force toggle mobile mode by sending +is_mobile=true+ and +is_mobile=false+ as
parameters in the request URL - note that these require session access. This entirely
overrides the user agent detection.

== Rolling out

  use Rack::Schmobile, :redirect_to => "/mobile", :if => Proc.new { |request| request.host =~ /staging/ }

== User agent detection

You can add/remove user agents like so:

  Rack::Schmobile::UserAgents.add_user_agent_pattern("wibble")
  Rack::Schmobile::UserAgents.remove_user_agent_pattern("ipad")

== Thanks

Not quite what we were looking for, but good inspiration and may work for you:

  https://github.com/talison/rack-mobile-detect
  https://github.com/brendanlim/mobile-fu


== Contributing to schmobile

* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright

Copyright (c) 2011 Morten Primdahl. See LICENSE.txt for
further details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
schmobile-0.1.0 README.rdoc