Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fresheyeball/ismobile-node
Stupid simple mobile detection script for node.js and express
https://github.com/fresheyeball/ismobile-node
Last synced: 7 days ago
JSON representation
Stupid simple mobile detection script for node.js and express
- Host: GitHub
- URL: https://github.com/fresheyeball/ismobile-node
- Owner: Fresheyeball
- Created: 2013-04-06T14:46:19.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-04-14T18:08:48.000Z (over 11 years ago)
- Last Synced: 2024-10-11T21:10:36.923Z (27 days ago)
- Language: JavaScript
- Size: 208 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
isMobile-node
=============Stupid simple mobile detection script for node.js and express
Installation
=============This package is registered with npm. Simply use
npm install ismobile
or include it in your package.json
"dependencies": {
"express": "3.0.x",
"jade": "*",
"ismobile": "*",
},Usage
=============This small script allows you to control what gets sent to mobile and desktop in the templating layer. Its middleware and needs to be included in your app.configuration like so
app.configure(function(){
// your setuprequire('isMobile')(app); // this must be BEFORE
app.use(app.router); // app.router!// continuing your setup
});Now you can use if blocks in your templates (jade shown here) using the two key variable `isMobile` and `isDesktop` :
html
head
title detection basicif isDesktop
//- include desktop css here
else
//- include mobile css herebody
if isMobile
h1 Its Mobile!
else
h1 Its Desktop!Thats it! Like it says, stupid simple. Here is the one thing to be aware of, this script treats tablet computers as desktops. If you want to serve the mobile version of your site to an iPad, this script is not for you (atleast not this version); also you should be ashamed for annoying me as an iPad user.