promptus / detect_mobile_browser Goto Github PK
View Code? Open in Web Editor NEWThis project forked from georgi/detect_mobile_browser
Plugin to find out if the client is a mobile device, based on the user agent string.
License: MIT License
This project forked from georgi/detect_mobile_browser
Plugin to find out if the client is a mobile device, based on the user agent string.
License: MIT License
Detect Mobile Browser =================== This plugin provides helper methods for a Ruby on Rails application to detect which requests to the application are made from mobile clients. In addition, there are some methods that let you find out specific agents (like an iOS or Android) device, and some URL manipulation methods to make it easier to forward mobile clients to special mobile subdomains and vice versa. The device detection is based on a big Regular Expression, the source of which is http://detectmobilebrowser.com/ . There is also a simple session-based test system - it allows you to use a normal browser and force the plugin to pretend it's detecting a mobile browser. Example ======= Install the plugin with <tt> script/plugin install git://github.com/traveliq/detect_mobile_browser.git </tt> and you're done. The plugin is tested with Rails 2.3.11 - it probably won't work with Rails 3.x. Contributions are welcome ! After restarting your server, you should see debugging output from the plugin in your development log on every request. You can then ask in any Controller #mobile_device?, which is true for the configured mobile devices. In addition, #mobile_device gives you a short name (like "android"), if the user agent matches a known, specific device class. #oldschool_browser? is true for any mobile device which is not an iOS or Android device - usually you want different, simpler views for those, and more sophisticated or specialised ones for the "newschools". There are shortcut methods for the newschools: #android? #iphone? #ipod? There are also methods to switch the subdomain of the current request's URL. Say that an Android phone has requested "www.example.com/query=waffles" Use mobilize_url(url) to turn it into "m.example.com/query=waffles" And demobilize_url(url) to turn it back. You can test the plugin even if you don't have a mobile device at hand by using the session switch. Add to any request URL to your app the parameters mobile=true and/or oldschool=true to force recognition as a mobile device in general or an oldschool device specifically. Use mobile/oldschool=false to force the recognition off (even if it would normally be recognized as mobile/oldschool), and mobile/oldschool=disable to switch the whole debug hack off. Author ====== Martin Tepper (monogreen.de) Contact ======= For any questions, mail to [email protected], or the Author(s). Copyright ========= Copyright (c) 2010 Travel IQ, released under the MIT license
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.