-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4f187c0
Showing
6 changed files
with
463 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2013 Scott Francis | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
##mobile_detect## | ||
|
||
A simple little Lua library to perform mobile browser detection. | ||
|
||
Detection rules were stolen from https://github.com/serbanghita/Mobile-Detect. | ||
|
||
### Installation ### | ||
|
||
``` | ||
luarocks install mobile_detect | ||
``` | ||
|
||
### Dependencies ### | ||
|
||
- Lua >= 5.1 | Luajit >= 2.0.0 | ||
- lua-cjson | ||
- Lrexlib-PCRE | ||
|
||
### Usage ### | ||
|
||
All APIs take a table of HTTP headers as an input parameter. | ||
|
||
```lua | ||
md = require("mobile_detect") | ||
|
||
http_headers = {} | ||
http_headers['HTTP_USER_AGENT'] = "Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5" | ||
assert(md.is_mobile(http_headers)) | ||
``` | ||
|
||
The following APIs are provided: | ||
- `is_mobile` | ||
- `is_mobile_browser` | ||
- `is_mobile_os` | ||
- `is_phone` | ||
- `is_tablet` | ||
|
||
### Development ### | ||
|
||
Tests can be run using [busted](http://olivinelabs.com/busted): | ||
|
||
``` | ||
sudo luarocks install busted | ||
busted test/mobile_detect_test.lua | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package = "mobile_detect" | ||
version = "1.0-1" | ||
source = { | ||
url = "https://github.com/csfrancis/mobile_detect/archive/1.0.tar.gz" | ||
} | ||
description = { | ||
summary = "Mobile HTTP browser detection library", | ||
homepage = "https://github.com/csfrancis/mobile_detect", | ||
license = "MIT/X11", | ||
maintainer = "Scott Francis <[email protected]>" | ||
} | ||
dependencies = { | ||
"lua >= 5.1", | ||
"lua-cjson", | ||
"lrexlib-pcre" | ||
} | ||
build = { | ||
type = "builtin", | ||
install = { | ||
conf = { | ||
["mobile_detect.json"] = "src/mobile_detect.json" | ||
} | ||
}, | ||
modules = { | ||
mobile_detect = "src/mobile_detect.lua" | ||
} | ||
} |
Oops, something went wrong.