Giter Club home page Giter Club logo

common_device_detector's Introduction

CommonDeviceDetector

Build Status Ebert Hex version Inline docs Lisence

Detect devices that desktop, mobile, smartphone and tabled form User Agent.

Installation

If available in Hex, the package can be installed as:

  1. Add common_device_detector to your list of dependencies in mix.exs:
def deps do
  [{:common_device_detector, "~> x.x"}]
end
  1. Ensure common_device_detector is started before your application:
def application do
  [applications: [:common_device_detector]]
end
  1. Configure databases. here https://github.com/elixytics/ua_inspector#parser-databases

Usage

Basic
iex(1)> alias CommonDeviceDetector.Detector
iex(2)> ua = "Mozilla /5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B5110e Safari/601.1"
iex(3)> Detector.smartphone? ua
true
iex(4)> Detector.desktop? ua
false
iex(5)> Detector.mobile? ua
true
iex(6)> Detector.tablet? ua
false
iex(7)> Detector.game? ua
false
iex(8)> Detector.tv? ua
false
iex(9)> Detector.bot? ua
false
Plug
iex(1)> alias CommonDeviceDetector.Detector
iex(2)> %Plug.Conn{} = conn
iex(3)> Detector.smartphone? conn
true
iex(4)> Detector.desktop? conn
false
iex(5)> Detector.mobile? conn
true
iex(6)> Detector.tablet? conn
false
iex(7)> Detector.game? ua
false
iex(8)> Detector.tv? ua
false
iex(9)> Detector.bot? ua
false
Migration database on production such as a phoenix with distillery

CommonDeviceDetector can download database on Production environment

$ bin/myapp command Elixir.CommonDeviceDetector.DownloadTasks run
Loading ua_inspector..
Starting dependencies..
UAInspector Database Download
Download path: /path/to/ua_inspector
This command will overwrite any existing files!
.. downloading: bot.bots.yml
.. downloading: browser_engine.browser_engine.yml
.. downloading: client.feed_readers.yml
.. downloading: client.mobile_apps.yml
.. downloading: client.mediaplayers.yml
.. downloading: client.pim.yml
.. downloading: client.browsers.yml
.. downloading: client.libraries.yml
.. downloading: device.televisions.yml
.. downloading: device.consoles.yml
.. downloading: device.car_browsers.yml
.. downloading: device.cameras.yml
.. downloading: device.portable_media_player.yml
.. downloading: device.mobiles.yml
.. downloading: os.oss.yml
.. downloading: vendor_fragment.vendorfragments.yml
Download complete!
UAInspector Short Code Map Download
Download path: /path/to/ua_inspector
This command will overwrite any existing files!
.. downloading: short_codes.client_browsers.yml
.. downloading: short_codes.device_brands.yml
.. downloading: short_codes.mobile_browsers.yml
.. downloading: short_codes.oss.yml
Download complete!
Success!

common_device_detector's People

Contributors

ikeikeikeike avatar

Stargazers

 avatar  avatar  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.