Coder Social home page Coder Social logo

igor-pavlenko / mobile-detect.lua Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yourpalmark/mobile-detect.lua

0.0 1.0 0.0 78 KB

Mobile device detection (phone, tablet, bot, mobile grade, os, versions, etc)

Home Page: http://yourpalmark.github.io/mobile-detect.lua

License: MIT License

PHP 1.64% Lua 76.89% Perl 21.46%

mobile-detect.lua's Introduction

Build Status

mobile-detect.lua

A loose port of Mobile-Detect to Lua for NGINX HTTP servers.

The script will detect the device by comparing patterns against a given User-Agent string.
The following device information is available:

  • mobile or not
  • if mobile, whether phone or tablet
  • operating system
  • Mobile Grade (A, B, C)
  • specific versions (e.g. WebKit)

Current master branch is using detection logic from [email protected]

Requirements

Usage

init_by_lua_block {
    mobile_detect = require "mobile-detect"
}

content_by_lua_block {
    local user_agent = ngx.var.http_user_agent
    ngx.say(mobile_detect.mobile(user_agent))
    ngx.say(mobile_detect.is('iPhone', user_agent))
    ngx.say(mobile_detect.is('bot', user_agent))
}

Contributing

Your contribution is welcome.
If you want new devices to be supported, please contribute to Mobile-Detect.
Changes there will cascade to this project.

If you have bug-fixes, new features, etc for this project, please follow the below steps:
Note: To generate source from template, it requires Mobile-Detect as a sibling directory to mobile-detect.lua

  • Clone Mobile-Detect
  • Fork mobile-detect.lua
  • Create branch
  • Make changes
  • Generate source: php generate/generate.php (requires PHP >= 5.4 in your PATH)
  • Run tests (see below)
  • Commit, push to your branch
  • Create pull request

Testing

  • Install Perl (add to PATH)
  • Install Test::Nginx: cpan Test::Nginx
  • Run: prove -r t

License

MIT-License (see LICENSE file)

mobile-detect.lua's People

Contributors

igor-pavlenko avatar yourpalmark avatar

Watchers

 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.