Giter Site home page Giter Site logo

play-wurfl's Introduction

Play-Wurfl

This is a Play! framework module for detecting mobile devices using Wurfl. It currently has the following features:

  • Route to .mobi template if UA Header indicates a mobile device
  • Device details available in renderArgs
  • Dynamic byte generation to allow simple access to Wurfl properties e.g. device.model_name
  • Typing of capabilities to allow straightforward logic in templates (e.g. #{if device.ajax_supports_javascript} or #{if device.physical_screen_height > 200}

Installing a wurfl.xml

Wurfl data is provided in an xml file, available from http://wurfl.sourceforge.net. The Wurfl plugin makes it easy to get the latest version of this file by using "play wurfl:install", which will download the latest file and install it into your conf directory. Any existing wurfl.xml file will be overwritten.

Templates for mobile devices

By annotating your controller @With(WurflAware.class), requests will be intercepted and routed to a corresponding template ending in .mobi if the request is from a mobile device (specifically, a UA header for which is_wireless_device in WURFL returns true). For instance, if your render() method would have resulted in index.html being rendered, then for mobile devices index.mobi will be rendered instead.

Querying wurfl capabilities

When rendering for mobile devices, an implicit object "device" is available. This allows you to query for Wurfl capabilities simply as fields on that object e.g. ${device.model_name}. Capabilities are dynamically discovered from the wurfl.xml file at application startup. Properties are typed as either String, int or boolean, so that you can use them in a simple way. For instance, for numeric properties, you can use mathematical operators e.g.

Screen area : ${device.physical_screen_height * device.physical_screen_width}

For boolean properties you can do simple switches e.g.

#{if device.ajax_supports_javascript}

play-wurfl's People

Contributors

revbingo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.