Skip to content

Commit

Permalink
Syntax highlight readme content
Browse files Browse the repository at this point in the history
  • Loading branch information
benlangfeld committed Jul 3, 2012
1 parent aefdf7c commit 7517f9a
Showing 1 changed file with 44 additions and 30 deletions.
74 changes: 44 additions & 30 deletions README.md
Expand Up @@ -16,50 +16,58 @@ Usage

Add this this one line to the controller.

class ApplicationController < ActionController::Base
has_mobile_fu
end
```ruby
class ApplicationController < ActionController::Base
has_mobile_fu
end
```

Once this is in place, any request that comes from a mobile device will be be
set as :mobile format. It is up to you to determine how you want to handle
these requests. It is also up to you to create the .mobile.erb versions of
your views that are to be requested.

If you do not want to set the format to :mobile or :tablet and only use the
If you do not want to set the format to :mobile or :tablet and only use the
helper functions, pass false as an argument.

class ApplicationController < ActionController::Base
has_mobile_fu(false)
end
```ruby
class ApplicationController < ActionController::Base
has_mobile_fu(false)
end
```



Mobile Fu automatically adds a new `:mobile` and `:tablet` to `text/html` mime type
alias for Rails apps. If you already have a custom `:mobile` alias registered in
Mobile Fu automatically adds a new `:mobile` and `:tablet` to `text/html` mime type
alias for Rails apps. If you already have a custom `:mobile` alias registered in
`config/initializers/mime_types.rb`, you can remove that.

I recommend that you setup a before_filter that will redirect to a specific page
depending on whether or not it is a mobile request. How can you check this?

is_mobile_device? # => Returns true or false depending on the device or
```ruby
is_mobile_device? # => Returns true or false depending on the device or

is_tablet_device? # => Returns true if the device is a tablet
is_tablet_device? # => Returns true if the device is a tablet
```

You can also determine which format is currently set in by calling the following:

in_mobile_view? # => Returns true or false depending on current req. format or
```ruby
in_mobile_view? # => Returns true or false depending on current req. format or

in_tablet_view? # => Returns true if the current req. format is for tablet view
in_tablet_view? # => Returns true if the current req. format is for tablet view
```

Also, if you want the ability to allow a user to switch between 'mobile' and
'standard' format (:html), you can just adjust the mobile_view session variable
in a custom controller action.

session[:mobile_view] # => Set to true if request format is :mobile and false
if set to :html
```ruby
session[:mobile_view] # => Set to true if request format is :mobile and false
if set to :html

session[:tablet_view] # => Set to true if request format is :tablet and false
if set to :html
session[:tablet_view] # => Set to true if request format is :tablet and false
if set to :html
```

So, different devices need different styling. Don't worry, we've got this
baked in to Mobile Fu.
Expand All @@ -69,11 +77,13 @@ to do is add _device to the name of one of your files to override your styling
for a certain device. The stylesheet that is loaded is dependant on which device
is making the request.

e.g., Accessing a page from a Blackberry.
e.g., Accessing a page from a Blackberry.

... stylesheet_link_tag 'mobile.css' ...
```ruby
stylesheet_link_tag 'mobile.css' ...
```

This loads mobile.css, and mobile_blackberry.css if the file exists.
This loads mobile.css, and mobile_blackberry.css if the file exists.

Supported stylesheet override device extensions at the moment are:

Expand All @@ -97,16 +107,20 @@ Testing Mobile Interface
If you want to force the mobile interface for testing, you can either use a
mobile device emulator, or you can call `force_mobile_format` in a before filter.

class ApplicationController < ActionController::Base
has_mobile_fu
before_filter :force_mobile_format
end
```ruby
class ApplicationController < ActionController::Base
has_mobile_fu
before_filter :force_mobile_format
end
```

You can also force the tablet view by calling `force_tablet_format` instead

class ApplicationController < ActionController::Base
has_mobile_fu
before_filter :force_tablet_format
end
```ruby
class ApplicationController < ActionController::Base
has_mobile_fu
before_filter :force_tablet_format
end
```

Copyright (c) 2008 Brendan G. Lim, Intridea, Inc., released under the MIT license

0 comments on commit 7517f9a

Please sign in to comment.