반응형
블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리

Kurogo Tutorial 07 - Device Detection -

2012. 5. 9. 05:12 | Posted by 솔웅


반응형

Device Detection

Kurogo 프레임워크의 파워풀한 기능 중 하나가 다양한 디바이스를 감별해 내고 다양한 디바이스의 capabilities를 근거로 format content를 분류하는 기능입니다. 디바이스별 분류를 지우너하기 위해 프레임워크는 Device Detection Server를 사용합니다. 이 서버는 디바이스들과 nomalized 된 프로퍼티 세트 output들에 대한 데이터베이스가 있습니다.

 

Types of Device Detection Servers

 

Kurogo는 유저 디바이스의 user agent를 parse 하고 상응한 값 목록들을 return 하는  internal device detection server 가 포함돼 있습니다. 여기에는 lib/deviceData.json에 위치한 json dataset을 포함됍니다. 이것은 각 패턴들의 series를 포함하고 있고 해당 패턴에 맞는 값을 return 하게 됩니다. 또한 여러분은 여러분 나름대로의 custom dataset file을 정의하실 수 있습니다. 이 custom file은 canonical dataset보다 먼저 검색돼 여러분 필요에 따라 control 할 수 있도록 도와 줍니다.

external device detection service 도 가능합니다. 이 service의 장점은 좀 더 최신이 디바이스 정보까지 포함하고 있다는 겁니다. 이를 위해서는 2개의 url들이 제공됩니다. 하나는 개발용이고 다른 하나는 production 용입니다.

좀 더 자세한 사항은 Device Detection Configuration  를 보세요.

 

Data Format

 

Kurogo 프레임워크는 유저 브라우저의 user agent를 사용해서 device detection service를 진행합니다. 이 service는 그 디바이스를 근거로한 프로퍼티들을 return 할 겁니다.

  • pagetype - String. device buckets 중의 하나, 그 디바이스가 어떤 major HTML 소스 를 receive 할 것인지를 정하게 됨. 리턴값으로는 basic, touch, compliant and tablet 등이 있음
  • platform - 디바이스의 특정 타입. 값으로는  ANDROID, BBPLUS, BLACKBERRY, COMPUTER, FEATUREPHONE, IPHONE, IPAD, PALMOS, SPIDER, SYMBIAN, WEBOS, WINMO, WINPHONE7 등이 있음
  • description - 디바이스에 대한 설명 
  • supports_certificates - Boolean. 이 프로퍼티는 더 이상 사용하지 않음

The pagetype 와 platform properties 들은 module object 의 프로퍼티로서 assign 됩니다.

 

Configuration

 

device detection service에 영향을 미치는 몇가지 configuration 값들이 있습니다. 이 값을은 SITE_DIR/config/site.ini에서 설정 하실 수 있습니다.  

  • MOBI_SERVICE_VERSION - 디바이스 버전을 포함. compatibility를 위해 제공 됨
  • MOBI_SERVICE_USE_EXTERNAL - Boolean. 0 이면, Kurogo 는 internal device detection server를 사용함. 1이면 external server를 사용함
  • MOBI_SERVICE_SITE_FILE - internal detection을 사용할 경우 site-specific device detection data 의 위치.  (DATA_DIR/deviceData.json 에 있음)
  • MOBI_SERVICE_URL - external detection을 사용할 경우 device detection server 의 URL 
  • MOBI_SERVICE_CACHE_LIFETIME - Time (in seconds), external device detection service 로부터 받아 cache 된 값을 keep 하고 있는 시간

Debugging Options

 

  • DEVICE_DETECTION_DEBUG - on으로 할 경우 홈 스크린의 밑에서 device detection 정보를 보실 수 있습니다. 특정 디바이스를 다룰 경우 유용하게 사용하실 수 있습니다. 디바이스가 정확하게 분류되 있지 않다고 느끼시면 device/browser 의 user agent 정보와 함께 kurogo-dev@googlegroups.com 로 알려 주세요.
  • DEVICE_DEBUG - on으로 할 경우, 주어진 요청을 행하기 위해 device pagetype과 platform 을 변경하실 수 있는 권한을 갖게 됩니다. 이 기능은 특정 디바이스를 가지고 있지 않거나 데스크탑에서 테스트를 할 때 유용하게 사용하실 수 있습니다.  심플하게 /device/pagetype-platform/에 사전 정의 해 주세요. 

 

Customizing your Device Detection

 

Kurogo 1.3 에서는 device detection files에 어떻게 access를 하는지에 대해 변경이 있습니다. 수정하거나 특정 device detections를 override 하는 것을 훨씬 쉽게 진행할 수 있도록 면서도 speed 손실이 없도록 했습니다.

쿠로고는 device detection 프로세스를 컨트롤 하기 위해 JSON 포맷을 사용합니다. 그럼으로서 빠르게 감지하고 쉽게 수정하거나 특정 디바이스를 추가할 수 있도록 했습니다. 이 파일에 대한 스키마 정의가 LIB_DIR/deviceDataSchema.json에 있습니다. JSON 스키마에 대한 좀 더 자세한 정보는 http://json-schema.org/를 참조하세요. 샘플 custom file은 DATA_DIR/sampleDeviceData.json 에서 보실 수 있습니다.

The sample deviceData.json file is reproduced below with comments added to help describe the format. Note that comments are not allowed in the actual file, in order to conform to json specifications:

deviceData.json 파일을 주석을 달아서 이해하기 쉽도록 한 샘플 파일이 아래에 있습니다. 실제로는 이 주석이 허용되지 않으니까 주의하세요.

 

{
    // All deviceData files consist of an object containing a single property, "devices".  devices is an array of device blocks.
    "devices" : [
        {
            // A device block contains several properties:

            // "groupName" : a machine readable identification of the device or device group.
            "groupName" : "exampleDevice",

            // "description" : a human readable identification of the device or device group.
            "description" : "Both revisions of the Example Device produced by Example Company, Inc.",

            // "classification" : a versioned set of identifications to be passed to kurogo once a device is matched
            "classification" : {
                // By convention, the highest version number is placed first in the file.
                "2" : {
                    // The full list of supported pagetypes and platforms are defined
                    // in the associated schema.
                    // Note: The schema defines a specified set of pagetypes and
                    //     platforms, in an attempt to catch misspelling and other user
                    //     input errors.  Kurogo, however, has no such restrictive list, and
                    //     you can actually specify any pagetype/platform assuming you also
                    //     have all the necessary template/configuration files defined.
                    "pagetype"     : "compliant",
                    "platform"     : "android",
                    "supports_certificate" : true
                },

                // In the event that a classification cannot be found for a given version
                // number, it attempts to search for the next lowest version.
                // So if you are requesting version 3, it first attempts to find version 3.
                // If it cannot find it, it attempts to find version 2.  If it cannot find
                // that either, it attempts to find version 1, etc.

                // Because of this, version numbers are a way to specify when this
                // definition last changed.  This also means that upgrading to a new
                // version of the detection engine does not require you to edit every single
                // entry just to continue to use your custom detection file.
                "1" : {
                    "pagetype"     : "webkit",
                    "platform"     : "android",
                    "supports_certificate" : true
                }
            },

            // "match" : an array of regex and/or string match blocks which should be matched against the user agent.
            "match" : [
                // You can specify any number of matcher blocks.
                {
                    // There are 4 types of matches.
                    // "prefix" attempts to match the specified string at the beginning of the user-agent.
                    "prefix" : "Mozilla/5.0 (exampleDevice-v1"
                },
                {
                    // "suffix" attempts to match the specified string at the end of the user-agent.
                    "suffix" : "exampleDevice-v2)"
                },
                {
                    // "partial" attempts to perform a literal string match somewhere in the user-agent string.
                    "partial" : "exampleDevice"
                },
                {
                    // "regex" allows you full preg_match syntax for matching any part of the user-agent string.
                    // Note: Do not include delimiters in your regex string or escape any potential delimiters.
                    // This is done automatically by Kurogo.
                    "regex" : "exampleDevice-v(1|2)",

                    // Each of the 4 different types of matches can also include an optional "options" object.
                    // This object can contain various modifiers for the match functions.  While useable on the
                    // basic string matching operations, it's most useful in regex, where you can specify case insensitivity and/or newline matching for the dot token.
                    "options" : {
                        "DOT_ALL" : true,
                        "CASE_INSENSITIVE" : true
                    }
                }
            ]
        }
    ]
}



반응형

'WEB_APP > Kurogo' 카테고리의 다른 글

Kurogo Tutorial 12 - Logging in Kurogo -  (0) 2012.05.21
Kurogo Tutorial 11 - News Module -  (0) 2012.05.17
Kurogo Tutorial 10 - Module 만들기 -  (0) 2012.05.13
Kurogo Tutorial 09 - MAP Module -  (0) 2012.05.12
Kurogo Tutorial 08 - Configuration-  (1) 2012.05.11
Kurogo Tutorial 06 - 소스 코드 여행 -  (0) 2012.05.08
Kurogo Tutorial 05 - 모듈 생성하기 -  (0) 2012.05.08
Kurogo Tutorial 04  (0) 2012.05.08
Kurogo Tutorial 03  (1) 2012.05.08
Kurogo Tutorial 02  (0) 2012.05.08