Socket
Book a DemoInstallSign in
Socket

mobile-enhancements

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobile-enhancements

0.0.5
bundlerRubygems
Version published
Maintainers
1
Created
Source

This gem provides a few features to a Rails app which aid the production of a mobile-targeted UI.

Firstly, it provides the mobile_only and mobile_optional blocks to your routes, these let you define particular routes which can only be accessed via your mobile prefix (default: /mobile) or ones which will work for both desktop and mobile. For details on customising the prefix, and exact usage of the routes helpers, see the "Usage" section below.

Build Status Code Climate

Installation

Add this line to your application's Gemfile:

gem "mobile-enhancements"

And then execute:

$ bundle

Or install it yourself as:

$ gem install mobile-enhancements

Usage

In your config/routes.rb file:

YourApp::Application.routes.draw do
  # accessible via /items and /mobile/items
  mobile_optional do
    resource :items
  end
  
  # only accessible via /mobile/barcode_scanner
  mobile_only do
    get :barcode_scanner, to: "scans#new"
  end
  
  # only accessible via /guides (normal routing)
  resource :guides
end

By default the path prefix for mobile routes will be mobile/. The app will also use layouts/application.mobile.erb as the root mobile UI template unless specified otherwise.

You can customise these options by creating an initializer, here's an example config/initializers/mobile_enhancements.rb file (the defaults):

require "mobile_enhancements"

MobileEnhancements.configure do
  mobile do
    # defines the path prefix used
    prefix "mobile"
    # defines the global view file
    layout "mobile"
    # defines the 'format' in view.format.renderer view filenames,
    # to use the same HTML as standard actions, simply set to "html"
    format "mobile"
  end
  
  desktop do
    layout "application"
  end
end

Note, in your application controller, a determine_layout method will be defined which will choose which layout file it needs, if you want to override this in your own controllers, you can always use super to reference the original.

A few helper methods are also provided (accessible both by your views and controllers):

mobile_request?
mobile_path(path_to_convert)
mobile_url(url_to_convert)
desktop_request?
desktop_path(path_to_convert)
desktop_url(url_to_convert)

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 21 Dec 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.