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

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리

Kurogo Tutorial 12 - Logging in Kurogo -

2012. 5. 21. 22:17 | Posted by 솔웅


반응형

Logging in Kurogo


Kurogo 에는 일반적인 logging과 예외적인 이벤트에 대한 logging이 있습니다. logging 시스템의 목적은 수정될 필요가 있는 중요한 상황에 대해 시스템 관리자에게 알리기 위한 점과 개발자에게 Kurogo code paths를 trace 하고 디버그 할 수 있도록 하기 위함입니다.

디폴트로 Kurogo event들은 SITE_DIR/logs/kurogo.log 에 log 됩니다. 각 entry들은 몇개의 부분들로 구성됩니다.


[date/time] area:priority method URI message


area는 이 메세지를 담당하고 있는 Kurogo component를 string으로 표현합니다. Kurogo는 몇개의 표준 area들을 정의하고 있습니다. 그 외에 개발자들은 필요에 따라 아무런 string을 사용하셔도 됩니다. priority는 이 메세지의 중요성(시급성) 등을 알리는 부분입니다. 이 priority map 들은 syslog function 의 priority들을 따릅니다. function/method는 이 메세지가 어디에서 나왔는지를 알 수 있도록 도와 줍니다. 이 URI는 유저가 본 페이지의 address 입니다.




Log Settings

Kurogo log의 behavior에 영향을 주는 몇가지 세팅이 있습니다. 이것들은 SITE_DIR/config/site.ini 에 위치해 있습니다.

  • KUROGO_LOG_FILE (default LOG_DIR/kurogo.log) - Kurogo log 파일의 위치입니다. 이 위치는 웹서버에 의해 write 가 가능해야 합니다. 여기에 모든 로그 메세지들이 저장되게 됩니다.
  • DEFAULT_LOGGING_LEVEL - logging level을 세팅합니다. 여기서 세팅된 레벨보다 높은 메세지만 log 됩니다. 레벨 이하의 로그는 무시됩니다.  
  • LOGGING_LEVEL[area] - 특별 area에 대한 logging 레벨을 세팅합니다. 이 기능은 개발자들이 특정 area에 대한 메세지만 보고 싶을 때 유용하기 사용하실 수 있습니다. 이 레벨은 이 area 에서 DEFAULT_LOGGING_LEVEL를 override 할 겁니다. 여러분은 원하는 만큼의 area를 override 할 수 있습니다. 

Priority Levels

Kurogo에 의해 사용되는 priority level constants가 있습니다. 대부분의 시스템에서는 이것을LOG_WARNING으로 세팅합니다. 이것을 LOG_INFO나 LOG_DEBUG로 세팅하면 여러분은 더 많은 메세지를 보실 수 있습니다. 일반적으로 디버깅을 위해서는 이것을 warning 보다 낮게 세팅하고 있습니다.

  • LOG_EMERG - system is unusable
  • LOG_ALERT - action must be taken immediately
  • LOG_CRIT -critical conditions
  • LOG_ERR - error conditions
  • LOG_WARNING - warning conditions
  • LOG_NOTICE -normal, but significant, condition
  • LOG_INFO -informational message
  • LOG_DEBUG - debug-level message

Standard areas in Kurogo

아래는 logging 메세지들을 구분하기 위한 Kurogo 내부 area들에 의해 사용되는 area들 입니다. 개발자들은 이 임의의 area를 만들어서 사용하실 수 있습니다.

  • admin - Admin console
  • auth - Authentication and authorization
  • config - Configuration
  • data - Used by libraries that retrieve external data.
  • db - Database
  • deviceDetection - Device Detection
  • exception - Exceptions
  • kurogo - Core functions including initialization
  • module - General module events
  • session - User session management
  • template - HTML templates

Logging in your module or library

Kurogo::log($priority, $message, $area) 메소드는 log에 메세지를 보냅니다. $priority 파라미터는 priority level constants 라야 합니다. message는 string 이어야 하고 area는 여러분이 log 하고 싶어하는 area로 string 이어야 합니다. 여러분은 여러분이 필요한 area에 대해 logging 세팅을 하기 위해 LOGGING_LEVEL[area]를 사용하실 수 있습니다.



반응형

Minority Report

2012. 5. 21. 10:16 | Posted by 솔웅


반응형




















반응형

수요일의 FAQ 5 번째 시간

2012. 5. 21. 06:58 | Posted by 솔웅


반응형

FAQ Wednesday #5


Question 1

Lua File System(LFS)를 추가하셨죠? /Documents directory 에서 파일 리스트를 얻으려면 어떻게 해야하죠?

Answer

Lua File System은 Corona build 2012.805 에서부터 추가됐습니다. 여기에서 튜토리얼을 읽어보실 수 있습니다.

LFS는 subdirectory도 만들고 지우고 접근할 수 있게 됐습니다. 구현은 디렉토리의 path를 담은 string을 만드는게 key 입니다. iOS와 Android에서는 3개의 main directory들이 있습니다. Resource, Temporary 그리고 Documents 가 그것입니다. 이것들은 Corona constant들을 사용해서 접근하게 됩니다. userdata constants들은 LFS에서 사용될 수  있으려면 string으로 변환 될 필요가 있습니다. system.pathForFile 는 userdata constant 로 변환 됩니다. (string 타입으로). 여러분은 base directory와 함께 파일이나 디렉토리명을 명시해주시면 됩니다. 그러면 그것은 전체 경로를 return 하게 됩니다.

local path = system.pathForFile( "data", system.DocumentsDirectory )

위 코드는 다음과 같은 string을 return 할 겁니다. “/var/mobile/Applications//Documents/data”



아래에 file들 리스트를 LFS로 어떻게 출력되게 하는지에 대한 코드가 있습니다.


local lfs = require "lfs"

-- Print the files in the path
--
local function printDir( path )
    print( "\nFiles in path: " .. tostring( path ) )
 
    local pathType = ""
 
    -- Check to see if path exists
    if path and lfs.attributes( path ) then
        pathType = lfs.attributes( path ).mode
    end
 
    if pathType == "directory" then
        for file in lfs.dir( path ) do
            local str

            -- Skip the current and up-one directories
            if "." ~= file and ".." ~= file then
                str = file

                local fileAtr = lfs.attributes( path .. "/" .. file )
                if fileAtr then
                    str = str .. " --> (" .. fileAtr.mode .. ")"
                else
                    str = str .. " --> (none)"
                end

                print( str )
            end
        end
    else
        str = "Path is not a directory!"
        print( str )
    end
end


그리고 아래는 /Documents directory와 /Documents/data subdirectory 를 어떻게 불러서 출력하는지를 보여 줍니다. (만약 존재한다면)

path = system.pathForFile( nil, system.DocumentsDirectory)
printDir( path )
path = system.pathForFile( data, system.DocumentsDirectory)
printDir( path )


위 코드는 파일 이름들을 출력하는 대신 table(배열)에 담아서 활용할 수도 있을 겁니다.


Question 2


Resource 디렉토리의 파일에 접근을 시도할 때 warning과 error를 하나씩 받았습니다. 이거 버그인가요?


Answer

system.pathForFile 를 사용하고 베이스 디렉토리가 system.ResourceDirectory 일때  코로나는 file이 존재하는지 살펴보고 그 path에 대해 nil 값이 받아지면 warning 메세지를 발생시킵니다. 그런데 이것은 filename 파라미터가 실제로 디렉토리 이름이면 작동하지 않습니다. 이것을 이용해서 다음과 같은 트릭을 쓰기도 합니다. 

local path = system.pathForFile( nil, system.ResourceDirectory )


이렇게 하면 warning 메세지를 발생하지 않습니다. 그리고 Resource directory를 가리키는 string을 return 하죠. 이 Resource directory 밑에 subdirectory 의 경로를 생성할 필요가 있으면 다음과 같이 이것을 append 하시면 됩니다.

path = system.pathForFile( nil, system.ResourceDirectory)
printDir( path )
path = system.pathForFile( nil, system.ResourceDirectory) .."/".."data"
printDir( path )

Note : system.ResourceDirectory는 안드로이드에서는 Resource directory가 실제 file system의 일부분이 아니기 때문에 작동하지 않습니다.

그리고 Resource directory는 read-only 디렉토리라서 write 할 수 없다는 것도 기억하세요.


Question 3

single touch app에 Multitouch 세팅하기

Answer

이건 질문은 아니지만 하나의 tip으로서 알려드립니다. 코로나에서 디폴트는 multitouch off 입니다. 이 말은 touch listener 가 있다면 한번에 하나의 touch 이벤트를 받는 다는 말입니다. 만약에 유저가 스크린을 터치하고 있는데 다른 손가락으로 버튼을 tap 한다거나 다른 객체를 move 하면 아무 일도 일어나지 않습니다. 왜냐하면 이미 다른 touch 가 active 돼 있기 때문이죠. 이것은 landscape 모드에서 유저가 손가락을 스크린에 대고 있느라고 자주 발생할 수 있는 현상이죠.

해결 방법은 여러분 코드에 아래와 같이 구현하는 겁니다.

system.activate( "multitouch" )

이렇게 하면 스크린에 손가락으로 하는 모든 touch에 touch event를 발생할 겁니다. touch 리스너를 걸어놓은 객체를 터치하지 않는 이상 아무일도 발생하지 않을 겁니다. 그리고 리스너가 있는 객체를 터치하면 동작이 일어나구요. 그렇게 되면 좀 더 user friendly 한 앱이 될 겁니다.


Question 4

iOS에서 앱 아이콘의 badge number를 어떻게 clear 하게 할 수 있을까요?


Answer


Local Notification은 해당 Notification이 일어나면 앱의 아이콘에 badge number를 세팅할 겁니다.(그것은 뭔가 pending 된게 있다는 것을 알리기 위함이죠.) 하지만 이것을 어떻게 clear 시킬 수 있을 까요? 해답은 native.setProperty API에 있습니다.

native.setProperty( "ApplicationBadgeIconNumber", 0 )

이렇게 하면 앱 아이콘에 있는 badge number를 없앨 수 있습니다.

아래 badge를 clears 시키는 Local Notification code 예제가 있습니다.

display.newText( "Setting Local Notification ...", 10, 30 )

-- Options for iOS
local options = {
   alert = "Wake up!",
   badge = 1,
   sound = "alarm.caf",
   custom = { foo = "bar" }
}

-- schedule using UTC (Coordinated Universal Time) time + 60 seconds
local utcTime = os.date( "!*t", os.time() + 60 )
local notification = system.scheduleNotification( utcTime, options )

-- Local Notification listener
local notificationListener = function( event )
   display.newText( "Notification Received " ..  event.badge, 10, 70 )
   native.setProperty( "applicationIconBadgeNumber", 0 )
end

Runtime:addEventListener( "notification", notificationListener )

Note: badge number 가 증가하거나 감소하는것에 대해서 badge 관련된 부분의 documentation에 설명 돼 있습니다. 이것은 애플의 documentation에서 인용한 겁니다. 그리고 그 의미는 여러분이 코드 내에서 그 badge number를 증가시키거나 감소시킬 수 있다는 것이죠. 코드 내에서 여러분이 명시한 badge number는 icon 에 display 되게 됩니다. 이 badge number 를 0으로 세팅하면 badge를 clear(remove) 하게 됩니다.

Local이나 Push Notification은 아직까지 iOS에서만 가능합니다.

Question 5

유저가 스크린을 터치하지 않고 있으면 device가 sleep 모드로 가는데 제가 만든 게임을 하는 동안에는 그 현상이 안 일어났으면 좋겠습니다. 가능한가요?


Answer

Yes, and the solution is one of the “system” APIs that works on both iOS and Android (but not in the simulators).

가능합니다. system API를 이용하시면 iOS와 Android 모두에서 가능합니다. (시뮬레이터에서는 안 됩니다.)

system.setIdleTimer( false )  -- disable device sleep mode

idle timer를 false로 해서 디바이스가 sleep 모드로 가지 않도록 합니다. true로 가면 sleep 모드로 가게 됩니다. 디폴트는 true 입니다. 이것을 false로 하면 디바이스의 배터리가 더 빨리 닳을 수가 있다는 것을 감안해서 사용하시기 바랍니다.

여기까지가 오늘의 Question들 입니다. 여러분에게 유용한 정보가 되었기를 바랍니다.

감사합니다.


반응형


반응형

스페인에서 Corona SDK 대사로 활동하고 있는 Tomas라는 친구가 전 세계적인 Corona 연맹 결성을 제안했습니다. 좀 황당하게 들렸지만 글을 읽어보니 열정이 느껴지네요. ^^



Spain’s Corona Ambassador and owner of Inkubica Labs, Tomas Martinez Buero, is calling on developers around the world to form a Corona Alliance. The Spanish chapter’s first Corona SDK Meetup will be taking place on May 31 in Madrid – don’t forget to register if you’re in the area!


스페인의 코로나 명예대사이자 Inkubica Labs의 owner인 Tomas Martinez Buero는 전세계적으로 코로나 연맹을 결성할 것을 제의했습니다. Spanish 쪽의 첫번째 Corona SDK Meetup이 5월 31일 마드리드에서 열릴겁니다. 근처에 사시는 분은 꼭 register하시는 것을 잊지 마세요.





Inkubica Labs is a software “gamification” company that is constantly improving its platform for edutainment apps, interactive books and serious games. The demand for these kind of apps is so big that we are looking for studios and independent Corona SDK developers worldwide to create a Corona Alliance!


Inkubica Labs은 edutainment apps, interactive books와 게임등을 꾸준히 개발하면서 성장해가는 software “gamification” company 입니다. 이런 종류의 앱들에 대한 수요는 아주 많습니다. 그래서 우리는 전세계적인 개별 코로나 SDK 개발자들이 참여하는 Corona 연맹을 만들기를 원합니다.


Inkubica Labs is the dream of two entrepreneurial Computer Sciences engineers, my partner Oscar Cuenca and I, who think that intelligent production of software can change the world. The name of Inkubica has two meanings: the broader one, that is related to the fact that we incubate business projects based on software, and the more specific one, associated with what we are doing now, “raising the INK into the third dimension.” (We help publishers produce interactive books and edutainment apps around the world.)


Inkubica Labs는 두 기업가 마인드를 가진 컴퓨터 공학들의 꿈입니다. 제 파트너인 Oscar Cuenca와 저는 intelligent 한 소프트웨어 제품이 세상을 변하게 할 수 있다고 생각합니다. Inkubica라는 이름은 두가지 의미가 있습니다. 하나는 더 넓게 라는 의미이고 이것은 소프트웨어분야를 바탕으로 비지니스 프로젝트를 incubate 하겠다는 것과 관련이 있구요. 두번째는 좀 더 specific 한 이란 뜻으로 지금 현재 저희가 하고 있는 “raising the INK into the third dimension.” (잉크를 3차원으로 끌어올리자... 라고 해석하면 될까요???;;)와 관련 돼 있습니다. (우리는 전 세계적으로 interactive book이나 edutainment app 들을 만들어내는 publisher들을 도와주고 있습니다.)


The Inkubica Labs team has very solid experience developing many kinds of software. In 1999, we programed our first mobile applications, starting with WAP when it wasn’t available for mobile! At that time, we were visionaries but we came too early. In 2001, we were expecting to see many mobile devices using 3G with WAP, and we were not the only ones to fail in these predictions. Now, we don’t need to be visionaries to know that this is a big time for mobile apps. And in regards to tablets, that’s a whole new world we didn´t predict 13 years ago!


Inkubica Labs 팀은 다양한 종류의 소프트웨어를 개발한 경험을 가지고 있습니다. 1999년에 우리는 첫번째 모바일 애플리케이션을 프로그래밍 했습니다. WAP을 사용한다는 개념이었는데요. 당시에는 이것이 모부일쪽에 사용되지 않을 때였습니다. 당시 우리는 공상가였을 뿐이지만 그것이 현실화 되는 것은 생각보다 빨리 왔습니다. 2001년 WAP과 함께 3G를 사용하는 많은 모바일 디바이스를 기대했었습니다. 지금은 여러분이 아시다시피 모바일앱이 더이상 공상이 아니라 실제로 큰 시장이 돼 버렸습니다. 그리고 태블릿쪽은 13년전에 우리가 상상하지도 못했던 분야입니다.


So here we are, in our second opportunity to be successful with mobile (and now with tablets too). The first thing we decided was to chose the right partners. After evaluating several tools, frameworks, platforms, etc. we fell in love with Corona SDK, not only because it enables us to code once and have the apps ready for iOS and Android, but also because we found very powerful APIs that help us do complex things very fast. And speed is the key of this market!


이제 우리는 모바일로 두번째 성공할 기회를 맞고 있습니다.(뿐만아니라 태블릿도 있죠.) 첫번째로 우리는 좋은 파트너를 골라야겠다고 결심했습니다. 여러 툴들과 프레임워크들과 플랫폼 등등에대한 검토 결과 Corona SDK 와 사랑에 빠지게 됐습니다. 한번 코딩해서 iOS와 안드로이드에 동시에 빌드할 수 있다는 이유만이 아닙니다. 아주 복잡한 것을 쉽고 빠르게 구현하게 해 주는 아주 powerful한 API도 중요한 이유입니다. 속도(빠른 대응)은 시장에서 가장 중요한 요소입니다.


We want to keep moving with the support and improvements of Ansca Mobile – developing apps with geolocalization, augmented reality, simulations, and QR codes and are very interested in forming a Corona Alliance. The main publishers of the Spanish and Portuguese speaking world have headquarters in Spain, with offices in Brazil, Mexico, Argentina, Chile, Colombia, Portugal, and Peru. Let’s join forces and go for them together! You don’t need to speak Spanish or Portuguese to work with us, but we do ask that you can communicate in English. :-)


우리는 Ansca Mobile의 지원과 꾸준한 성능향상과 함께 나갈겁니다. developing apps with geolocalization, augmented reality, simulations, and QR codes 들은 Corona 연맹의 주요 관심사항들 입니다. 스페인어와 포르투갈어를 사용하는 세계의 헤드쿼터는 스페인에 있습니다. 그리고 지부 사부실은 브라질과 멕시코, 아르헨티나, 칠레, 콜롬비아, 포르투갈 그리고 페루에 있습니다. 들어오셔서 같이 합시다. 우리와 같이 일하기 위해 꼭 스페인어와 포르투갈어를 사용하실 필요가 없습니다. 그런경우 영어로 소통할 수도 있습니다.


If you are interested, just send me an mail to tomas.martinez@inkubica.com.

On May 31, we will be hosting the first Corona SDK Meeting in Spain! Please join us and register here.


관심 있으시면  tomas.martinez@inkubica.com로 메일을 보내주세요. 5월 31일 우리는 첫번째 corona SDK Meeting을 스페인에서 가질 예정입니다. 함께 하시려면  here에 등록해 주세요.


Tomas Martinez Buero, Inkubica Labs


Madrid, Spain


반응형


반응형

피델리티 인베스트먼트에서 후원을 한 MOFILM 2012 텍사스 비디오 콘테스트 당선작입니다.

요즘 이 회사 관련된 프로젝트를 하고 있어서 모바일 웹 만들다가 Content로 들어와서 보게 된 건데요.


재밌어서 공유합니다.


주제가 일상에서 불편한 점들에 뭔가 더 좋은 방법을 생각해 보자라는 것 같습니다.

한국팀도 Best 5 안에 하나 든 것 같네요.



1. A Better Way to Connect



Director: JR Strickland
Producer: Villian, JR Strickland
Cast: Derek Cox, Cecilee Von Rhea



2. A Better Way to Cut Onions



Director: MChristie



3. A Better Way to Fold



Creative/Producer/Editors: Lawrence Chen and Hagan Wong
Director: Lawrence Chen
Actors: Jesse Hsu and Alex Ellinport



4. A Better Way All Day



Director: Shin Seung Hwan
Producer: Jude Chun
Actor: Jo Dong Hyun



5. A Better Way To Start A Day



Director: MChristie
Actor: Ryan Powers



반응형

Kurogo Tutorial 11 - News Module -

2012. 5. 17. 00:07 | Posted by 솔웅


반응형

이번에는 Kurogo의 News Module 을 살펴봐야겠네요. 관련된 일을 받았거든요.


News Module

뉴스 모듈은 RSS feed 로부터 받은 stories/articles 리스트를 보여 줍니다. 그 feed 가 full textual content를 제공한다면 그 article은 모바일에 맞는 포맷으로 유저에게 보여질 겁니다. 만약 그 feed가 full text를 담고 있지 않다면 그 article로 지정된 URL로부터 content를 fetch 하도록 configure 될 수 있습니다. (아래 FETCH_CONTENT 를 보세요.)

General Options

SITE_DIR/config/news/module.ini  안에 뉴스 모듈의 기본 작동에 관해 configure 할 수 있는 몇개의 옵션이 있습니다.

  • MAX_RESULTS (10) - 뉴스 리스트에 보여질 아이템의 갯수 
  • SHARING_ENABLED (1) - news entries에 sharing link를 걸 수 있는지 없는지 지정. 0으로 하면 지정할 수 없도록 함

Configuring News Feeds

news 모듈을 사용하기 위해 우선 여러분의 data로 연결하는 connection을 setup 해야 합니다. 이를 위해서는 2가지를 반드시 세팅해야 합니다.  이 작업을 하기 위해 Administration Module 를 이용하거나 SITE_DIR/config/news/feeds.ini file 에서 곧바로 값을 수정하시면 됩니다.

이 모듈은 multiple feeds를 지원합니다. 각 feed 는 configuration file안의 section에 의해 지정됩니다. 그 section의 이름은 0-indexed number 이어야 합니다 (i.e. 첫번째 feed는 0 이고 두번째 feed 는 1 ...). 아래의 값들이 필요합니다.

  • TITLE 값은 여러분 feed 의 이름을 가르킵니다. 이 이름은 feed를 선택하기 위해 drop down list 했을 때 보여지게 됩니다.
  • BASE_URL은 여러분의 News feed의 url을 세팅하면 됩니다. static file이 될 수도 있고 Web service 가 될 수도 있습니다.




Optional values

  • RETRIEVER_CLASS - data를 get 하기 위해 alternate data retriever  를 세팅할 수 있도록 합니다. 디폴트는 URLDataRetriever 입니다.
  • PARSER_CLASS - DataParser의 subclass로 세팅합니다. 여러분의 데이터 소스가 RSS/Atom 이나 RDF가 아닌 포맷으로 return 될 때에만 바꾸시면 됩니다. 디폴트는 RSSDataParser 입니다.
  • SHOW_IMAGES - feed의 thumbnail 이미지를 보여줍니다. 이미지가 없으면 placeholder image 가 보일 겁니다. 만약에 모든 feed가 이미지를 가지고 있지 않으면 SHOW_IMAGES=0 으로 세팅하실 수 있습니다.
  • SHOW_PUBDATE - 뉴스 리스트에 publish date를 보여 줌. (published date는 detail page에서는 항상 보여 짐)
  • SHOW_AUTHOR - 뉴스리스트에 저자를 보여 줌 (detail page에서는 항상 저자를 보여 줌) 
  • SHOW_LINK - full article에 대한 link를 보여 줌. feed에 introductory paragraph 만을 포함하고 있을 때 유용함. 

Additional Configuration for RSS Feeds

특정 RSS feeds에 대한 옵션들이 있습니다. RSSDataParser 가 디폴트 parser 이면 이것은 대부분의 feed들에 적용이 될 겁니다.

  • CHANNEL_CLASS   RSS channel 에 대해 다른 클래스 이름을 세팅할 수 있도록 해 줌. 여러분은 custom subclass를 생성해서 unique하게 RSS 아이템을 핸들링 할 수 있습니다. 흔히 사용되지는 않습니다.
  • ITEM_CLASS  feed 안에서 각 아이템에 대해 다른 클래스 이름을 세팅할 수 있도록 함. custom matter 안에 custom fields 나 parse fields를 가지고 있는 feed 를 핸들링 할 수 있도록 해 줍니다.
  • ENCLOSURE_CLASS enclosures에 다른 클래스 이름을 세팅할 수 있도록 해 줍니다. enclosures에 대해 custom behavior를 핸들링 할 수 있도록 해 줍니다. 
  • IMAGE_ENCLOSURE_CLASS  image enclosures에 대해 다른 클래스 이름을 세팅할 수 있도록 해 줍니다. 이미지에 대해 custom behavior를 핸들링 할 수 있도록 해 줍니다.
  • REMOVE_DUPLICATES - feed에서 duplicate entry 들을 remove 합니다. (i.e. 같은 GUID를 가지고 있는 아이템).
  • HTML_ESCAPED_CDATA - 1로 세팅하면 content와 description field 에 있는 HTML을 decode 할 겁니다. CDATA block에 wrapping 하기 위해 HTML data를 encode 하면서 feed가 HTML data를 encode 하는데 문제가 생길 경우 on으로 설정할 필요가 있습니다.
  • USE_DESCRIPTION_FOR_CONTENT - 1로 세팅 돼 있으면 description field는 full content로서 사용될 겁니다.
  • FETCH_CONTENT - 1로 세팅되면 Kurogo는 아이템에서 명시된 URL에서 content를 fetch 하는 것을 시도할 겁니다. 그리고 그 content를 extract 할 겁니다.



반응형


반응형

회사에서 해야할 Kurogo 관련 일을 이제 거의 끝마쳤습니다.

JQuery Mobile 쪽을 너무 오래 다루지 않은 것 같아서 지난번 글에 이어서 계속 Tutorial을 정리하겠습니다.


Prefetching pages

여러분 앱의 페이지들을 하나의 큰 템플릿에 보관하는 것 보다 조그만 여러개의 페이지 템플릿(single-page templates)으로 나눠서 보관하는게 더 좋은 생각입니다. 그렇게 하면 페이지의 DOM size를 줄일 수 있습니다.

single-page templates를 사용할 때 DOM에 대해 prefetch pages를 사용하실 수 있습니다. 그러면 유저기 그 페이지를 방문할 때 즉시 서비스를 할 수 있습니다. 페이지를 prefetch 하기 위해서는 link에 data-prefetch 속성을 추가하면 됩니다. JQuery Mobile은 그러면 primary page가 로드된 다음에  target 페이지를 background에서 로드합니다. 그리고 pagecreate event가 trigger 됩니다. 아래 예제가 있습니다.

<a href="prefetchThisPage.html" data-prefetch> ... </a>

여러분이 원하시면 원하시는 대로 linked page에 prefetch를 설정할 수 있습니다. 단지 링크에 data-prefetch 만 추가하시면 됩니다.


또한 $.mobile.loadPage():를 사용해서 프로그램적으로 페이지를 prefetch 하실 수 있습니다.

$.mobile.loadPage( pageUrl, { showLoadMsg: false } );

페이지를 prefetching 하는데에는 또다른 잇점이 있습니다. 유저가 이 prefetch된 페이지를 방문할 때는 Ajax 로딩 메세지를 안 보게 될 겁니다 Ajax 로딩 메세지는 prefetching이 끝나지 않았을 때만 나타날 겁니다.

Prefetching 페이지는 자연스럽게  추가적인 HTTP request를 생성하고 bandwidth를 사용합니다. 그러니까 페이지를 prefetching 하는 것은 자주 방문되는 페이지에 한해 사용하시는 것이 좋습니다. 일반적으로 previous, next 가 많이 사용되는 Photo Gallery 같은데 사용해서 유저가 사진을 보는데 좀 더 빠르게 화면에 표시하도록 만들 필요가 있을 때 사용할 수 있을 겁니다.





DOM size management

animated 된 화면전환을 위해서 화면전환이 일어나는 두 페이지가 모두 DOM 안에 있을 필요가 있습니다. 어쨌든 DOM 에 있는 이전 페이지를 계속 가지고 있으면 브라우저의 메모리를 차지하게 될 것이고 어떤 모바일 브라우저에서는 속도가 저하되거나 crash가 일어날 수도 있을 겁니다.

jQuery Mobile은 DOM에 작게 보관할 수 있는 간단한 메카니즘을 가지고 있습니다. Ajax를 통해서 페이지를 load 할 때마다 jQuery Mobile는 그 페이지를 flag 하고 나중에 그 페이지를 떠 날 때 DOM에서 remove 할 수 있도록 합니다. (기술적으로 말하자면 pagehide event 시 이 일이 일어 납니다.) 만약 유저가 remove 된 페이지를 다시 방문하면 캐쉬에서 그 페이지의 HTML 파일을 retrieve 할 겁니다. 만약 그렇지 않으면 서버에서 refetch 하겠죠. (nested list views 인 경우에는 jQuery Mobile은 필요에 따라 더 이상 관련 없는 nested page를 remove 하게 됩니다.)

multi-page template 안에 있는 페이지들은 이 기능에 영향을 받지 않습니다. - jQuery Mobile은 Ajax 를 통해 로드된 페이지들만 remove 합니다.


Caching pages in the DOM

If you prefer, you can tell jQuery Mobile to keep previously-visited pages in the DOM instead of removing them. This lets you cache pages so that they're available instantly if the user returns to them.


원하시면 이전에 방문했던 페이지를 remove 하지 않고 DOM 에 보관하라고 jQuery Mobile에 지시할 수 있습니다. 그러면 유저가 다시 그 페이지를 방문할 때 빨리 보여줄 수 있겠죠.

To keep all previously-visited pages in the DOM, set the domCache option on the page plugin to true, like this:


방문했던 모든 페이지를 DOM에 보관하려면 domChache 옵션을 true로 세팅하면 됩니다.


$.mobile.page.prototype.options.domCache = true;

특정 페이지만 cache 하시려면 그 페이지의 콘테이너에 data-dom-cache="true" 속성을 추가하시면 됩니다.


<div data-role="page" id="cacheMe" data-dom-cache="true">

programmatically 페이지를 cache 할 수도 있습니다.

pageContainerElement.page({ domCache: true });

DOM caching의 drawback하면 DOM이 아주 크게 될 수 있습니다. 그러면 속도가 느려지거나 어떤 디바이스에서는 저장용량 문제가 발생할 수 있습니다. DOM caching 을 할 때는 이런 부분을 잘 관리하셔야 합니다. 그리고 여러 디바이스에서 충분히 테스트 해 보셔야 합니다.


반응형


반응형


예전에 한겨레신문에서 올렸던 MB 주변 인물 비리를 올린적 있었죠?

제목이 좀 오그라들던데.. 여기 가시면 보실 수 있습니다. 


이번에는 경향신문에서 올렸네요.

MB 측근 비리를 한 눈에 볼 수 있는 인포그래픽이예요.

오른쪽에 약간 짤리는 거 같은데... 전체를 보시려면 여기로 가세요.


요즘 통합진보당이 너무 실망스러운 모습을 보이네요.

그쪽 지지를 접을까 합니다.


그렇다고 가카의 업적을 기리고 거기에 상응하는 포상을 받게끔 해 드리는 일은 멈출수가 없겠죠?





반응형

Kurogo Tutorial 10 - Module 만들기 -

2012. 5. 13. 05:27 | Posted by 솔웅


반응형

이번주 제가 회사에서 할당받은 일이 Kurogo의 Map 과 관련된 것 하고 새 모듈을 하나 만드는 겁니다.

지금 Kurogo Tutorial 을 번역하고 있는데요.

급하게 제가 처리해야 할 일이 생겨서 그 부분 부터 번역을 하고 있는데요.

지난번에 MAP 부분을 정리했고 이번에는 Module 만들기를 정리합니다.


=====================


Writing Modules

쿠로고 프레임워크는 모듈을 기본으로 만들어 졌습니다. 각 모듈들은 유저에게 보여지는 그들만의 데이타 세트와 서비스들을 제공합니다.


The Module Object


각 모듈은 Module object의 subclass 입니다. 대부분의 core logic이 이 클래스에 위치해 있습니다.


  • configuration과 런타임 파라미터들을 수집하는것
  • internal URL들의 생성
  • Authorization


웹에서 유저에게 제공되는 모듈을 만들기 위해서는 (홈 스크린에 나타나던지 그렇지 않던지 간에) 그 모듈은 반드시 WebModule 객체의 subclass 이어야 합니다. 웹서비스로서 native(iOS같은) 앱이나 앱의 AJAX functionality 들이 그 데이터를 사용하도록 만드려면 그 모듈은 반드시 APIModule 객체의 subclass 이어야 합니다.


대부분의 모듈들은 WebModule과 APIModule 모두의 subclass 입니다. 모듈이 이 중 하나의 subclass 이고 다른 하나의 subclass가 아닌 경우도 있을 수 있습니다. 예를 들어 에러 모듈의 경우에는 유저에게 에러를 알려주기 위한 웹 인터페이스인데 API counterpart를 가지고 있지 않습니다.각 모듈들의 WebModule과 APIModule subclass 는 대부분 비슷합니다. WebModule과 APIModule에 관한 자세한 사항들은 아래 링크로 가서 확인하세요.



    The WebModule Object
    The APIModule Object




Module life cycle

request가 한번 만들어지면 loading system은 factory method를 사용해서 어떤 모듈이 load 되어야 결정하고 모듈을 생성합니다. URL은 어떤 모듈이 로드 되고 어떤 페이지가 할당되고 includ 돈 파라미터들을 설정합니다.

url의 첫번째 path component 는 모듈의 아이디 입니다. 이것은 어떤 모듈을 로드할 지를 정할 수 있도록 해 줍니다. factory method는 SITE_DIR/config/ID/ 에서 config 폴더를 찾아봅니다. 그리고 module.ini 파일을 로드하죠. 그 파일 안에서 id 값을 찾고 해당 ID의 module을 로드합니다. 만약 ID property가 없다면 config folder 를 id로 module을 load 할 겁니다.

그 URL에 대한 config folder가 없다면 site.ini에 있는 CREATE_DEFAULT_CONFIG 의 값을 찾아보게 됩니다.

    만약 true 이면 그 ID를 근거로 모듈을 로드하려고 할 겁니다. 그리고나서 모듈이 발견되면 자동적으로 config folder를 생성합니다.
    만약 false면 (디폴트임) 또는 그 ID로 모듈을 찾을 수가 없으면 fail이 일어날 겁니다.

두번째 path component는 (WebModule에 대한) page 입니다. 이것으로 로드할 code path와 template file 을 설정합니다. 만약 가리키는 page가 없으면 그 페이지는 index로 세팅 될 겁니다.

APIModule에 대해서는 이것은 command 입니다. 이 command는 항상 존재해야 합니다. 필요한 id/command URL format의 single exception(예외상황)은 CoreAPIModule을 request 하는 것입니다. CoreAPIModule은 single command (hello) 이고 모듈 아이디가 없습니다.

After instantiating the object, the init method is called. This does several things:
객체를 초기화(instantiating) 하고 나서 init method 가 call 됩니다. 여기에 몇가지가 있습니다.

    - page, args, pagetype, platform 을 포함한 필요한 프로퍼티들을 할당한다.
    - data structure들을 셋업하기 위해 사용되는 initialize() 메소드를 call 합니다. 이 data structure는 inside a page와 outside(예를 들어 federated search 안의 instance에 대한 경우)를 사용합니다.
    - WebModules안에서 initializeForPage() 메소드가 call 됩니다. 이 메소드는 그 모듈 로직에 대한 primary entry point를 보여 줍니다. 특히 그 모듈이 그 페이지 프로퍼티으 ㅣ값에 근거한 다룬 로직을 처리하게 됩니다.
    - APIModules 안에서는 initializeForCommand() 메소드가 call 됩니다. 특히 이 모듈은 command property의 값에 근거한 다른 로직을 처리하게 됩니다.


마지막으로 output은 다음과 같은 것을 generate 됩니다. WebModule은 templatePage 프로퍼티의 값에 근거해 display 할 template을 선택합니다. 초기에는 page property로 셋하지만 좀 더 다이나믹한 template display 를 위해 필요하다면 overridden 할 수 있습니다. APIModule은 모듈 id, API version, command requested, response payload 를 포함한 JSON response를 생성합니다.

Methods to use

모듈 객체에는 많은 메소드가 있습니다. 대부분은 내부적으로 사용됩니다. 그러므로 얘기 나눌 부분은 별로 없습니다. 새로운 모듈을 만들 때 주의해야할 몇개의 메소드가 있습니다. WebModuleAPIModule을 위한 메소드들도 보셔야 합니다.

Accessors

    getArg($key, $default) - Retrieves an argument sent via GET/POST, if the $key is not present, then it will return the value specified in $default

Configuration

configuration data를 로드하기 위한 여러 메소드들이 있습니다. Configuratin은 server locations, urls 그리고 소스코드 밖의 다른 값들 같은 특정 detail 값들을 keep 할 수 있도록 해 줍니다. 각 모듈은 configuration file들의 폴더가 있습니다. primary configuration data 는 module.ini 파일안에 있습니다. pages.ini 모듈 안에 있는 Page data는 필요로 하는 configuration structure를 사용할 수 있습니다. 많은 경우 complex data structure는 다른 파일에 있을 필요가 있을 겁니다.

여러분은 key나 전체 section을 이용해서 값을 retrieve 할 수 있습니다. (배열로서 값을 받을 겁니다.) Module 객체에는 아래 메소드들이 있습니다.

    getModuleVar($key, $section=null, $config=’module’) - Gets a required module variable $key. If you specify $section it will only look in that section. Will throw an exception if the value is not present
    getOptionalModuleVar($key, $default=’‘, $section=null, $config=’module’) - Gets an optional module variable $key. If you specify $section it will only look in that section. If it is not present, $default will be used (empty string by default)
    getModuleSection($section, $config=’module’) returns an array of values in a module section. Will throw an exception if the section is not present
    getOptionalModuleSection($section, $config=’module’) returns an array of values in a module section. Will return an empty array if the section is not present
    getModuleSections($config) - Returns a complete dictionary of sections=>vars=>values for a particular config file. Very handy when you basically want the array structure of an entire file
    getOptionalModuleSections($config) - Like getModuleSections(), but if the config file does not exist it will return false


site configuration (site.ini)에서도 값을 retrieve 할 수 있습니다. 이것들은 모든 모듈에 의해 사용되는 값들입니다. Kurogo 객체의 static methods가 있습니다.

    Kurogo::getSiteVar($key, $section=null) - similar to getModuleVar
    Kurogo::getOptionalSiteVar($key, $default=’‘, $section=null) - similar to getOptionalModule Var
    Kurogo::getSiteSection($section) - similar to getModuleSection
    Kurogo::getOptionalSiteSection($section) similar to getOptionalModuleSection


site string(strings.ini)을 get 하기 위한 또 다른 2개의 다른 메소드들이 있습니다.

    Kurogo::getSiteString($key) - returns a site string. Will throw an exception if not present
    Kurogo::getOptionalSiteString($key, $default=’‘) - returns a site string. Will return $default if not present


User Sessions


    isLoggedIn() returns whether a user is logged in or not (see Authentication)
    getUser() returns a User object of the current user (or AnonymousUser if the user is not logged in)
    getSession() returns the Session object of hte current session.




반응형


반응형

새로 아파트에 들어왔습니다.
그동안 Holiday Inn 에서 출퇴근하다 10일에 이사를 했어요.

새로 인터넷을 신청했는데 17일에나 설치를 해 준다네요.

인터넷 쓸 일이 있어서 집 근처 스타벅스에 와서 인터넷 사용하고 있습니다.


==========================

My Favorite Corona App - Twitter Contest

by ANSCA Inc on Tuesday, May 8, 2012 at 2:15pm ·


We couldn't get enough of all the Twitter love from last week's contest, and this week we're going to up the ante!


지난주 열화와 같은 참여와 성원에 감사드립니다. 이번주도 금주의 콘테스트로 여러분을 찾아 뵙습니다.

 

Tweet us your FAVORITE Corona-built app for a chance to win a 3-month subscription to (or extension of) a Corona Pro license. We'll select two (2) lucky winners at random. If you need some inspiration for great Corona-made apps, check out our showcase: http://developer.anscamobile.com/showcase/Browse_All


Corona로 만든 앱 중에 여러분이 가장 좋아하는 앱을 저희에게 트윗해 주세요. 당첨되신 분께는 코로나 SDK 3개월 무료 이용 권한을 드립니다. (기존 회원은 3개월 연장 시켜 드릴거구요.) 랜덤하게 두분을 추첨할 겁니다. 코로나로 만든 앱이 어떤 것이 있는지 알고 싶으신 분들은 저의 홈페이지의 showcase를 들러 주세요.

http://developer.anscamobile.com/showcase/Browse_All

 





The rules are simple:


규칙은 간단합니다.

  1. Follow @ansca on Twitter.  트위터에서 @ansca를 팔로우하세요.
  2. Like us on Facebook: www.facebook.com/ansca . Facebook에서도 등록해 주세요.
  3. Tweet us your very favorite Corona-made app . 여러분이 좋아하는 코로나로 만든 앱을 트윗해 주세요.

Last day to enter the contest is Sunday, May 13 at 11:59pm PT.


마감일은 미국 태평양 시간(PT)으로 5월 13일 11:59PM 까지 입니다.


Happy tweeting and good luck!


===============================================


여러분들도 많이 참여하시고 행운도 얻으세요...




반응형