useragent-node

useragent-node ============ app.js ```` var express = require('express'), app = express(); app.set('view engine', 'm') app.engine('m', require('hogan-express')) app.set('views', '.') app.listen(3000); console.log('running on 3000')

npm install useragent-node
8 downloads in the last month

useragent-node

app.js

var express = require('express'), app = express();
app.set('view engine', 'm')
app.engine('m', require('hogan-express'))
app.set('views', '.')
app.listen(3000);
console.log('running on 3000')

require('dns').lookup(require('os').hostname(), function (err, add, fam) {
  console.log('from a mobile device, go to http://'+add+':3000');
})

app.use(require('./useragent.js')({check:['iPhone', 'Chrome', 'Android', 'Windows']}));

app.all('/', function(r, s){
        s.render('test.m', {ua: r.ua});
})

index.m (mustache)

{{#ua.iPhone}}
  I am iPhone
{{/ua.iPhone}}

<br>

{{#ua.Android}}
  I am Android
{{/ua.Android}}

<br>

{{^ua.Android}}
I am not Android
{{/ua.Android}}

<br>

{{#ua.Chrome}}
I am Chrome
{{/ua.Chrome}}

<br>

{{#ua.Windows}}
I am Windows
{{/ua.Windows}}

Common user agents http://whatsmyuseragent.com/CommonUserAgents.asp

npm loves you