기본 콘텐츠로 건너뛰기

라벨이 mrt인 게시물 표시

안드로이드 TV 스틱(armv7l)용 meteor branch를 만들었습니다.

https://github.com/acidsound/meteor/commit/d65a2a3530d89fd97c1b582b00ed28af9c5c608a 수정사항은 위와 같습니다. 필요한 의존성이 있으므로 sudo apt-get update sudo apt-get install build-essential openssl libssl-dev pkg-config git-core scons libpcre++-dev libboost-dev libboost-program-options-dev libboost-thread-dev libboost-filesystem-dev curl 먼저 받아놓습니다. 설치 방법은 git clone https://github.com/acidsound/meteor.git cd meteor git checkout devel_armv7l ./scripts/generate-dev-bundle.sh 이걸로 빌드한 후 ./meteor 로 확인해보면 됩니다. meteor 디렉토리를 path로 잡던가 meteor를 /usr/local/bin 에 넣던(확인 안해봄)하면 됩니다. meteorite(mrt) 설치는 그냥 npm install 을 사용해서 하면 별 이상 없이 잘 붙습니다. mongo는 포함하고 있지 않으므로 실행시엔 반드시 외부(ex.mongohq) mongo 서비스를 사용하시길 바랍니다. MONGO_URL=mongodb://id:pw@alex.mongohq.com:10058/yourdb mrt 식으로 실행하면 됩니다.

Multiple pub/sub collection in meteor

iron Router를 잘 쓰고 있는데 쓰다 보니 이상한 점이 있다. 페이지별로 subscribe 하는 것까지는 좋지만 당연히 여러 개의 page에 대해 subscribe를 해야 하는데 waitOn 같은 곳에서 여러 개의 collection에 대해 subscribe를 하다 보니 N번 화면을 갱신하기도 하고 코드도 좀 번거롭다. 여러 개의 Collection에 대한 pub/sub을 한 번에 할 수 없을까 생각하고 있었는데 https://github.com/meteor/meteor/pull/716 최근 내용을 보니까 구현이 되어있다! 이것도 undocumented라고 해야 하나 싶다. 아무튼, 좋다. Posts, Replies 두 개의 Collection이 있다고 할 때 autopublish package를 meteor(혹은 mrt) remove autopublish하여 삭제하고 수동 가입을 구현한다면 /model/model.coffee @Posts = new Meteor.Collection "posts" @Replies = new Meteor.Collection "replies" /client/subscribe.coffee Meteor.subscribe 'posts-replies' /server/publish.coffee Meteor.publish 'posts', ->   [Posts.find(), Replies.find()] 이렇게 [ ] 배열 형태로 묶어만 주면 된다. 좋은 패치라고 생각한다. 적극적으로 활용하자.

Meteor에서 REST API를 사용하는 방법 #2

server쪽 API를 router package를 사용해 쓰다보면 header 같은 걸 다루거나 할땐 너무 단순하게 만들어서 곤란할 수 있다. 이전에도 다룬 적( http://spectrumdig.blogspot.kr/2012/08/meteor-rest.html )이 있지만 __meteor_bootstrap__ 객체를 통해 접근하면 node.js 식의 접근이 가능하다. Meteor update와 함께 Npm 객체가 생겼으니 이를 이용해 connect 객체를 사용해보자 http://www.slideshare.net/cjoudrey/building-your-first-node-app-with-connect-express 위 슬라이드를 한번 보면 이해에 도움이 될 것이다. WebApp.connectHandlers 가 connect.createServer()라는 걸 기억하면 된다. connect = Npm.require 'connect' server = WebApp.connectHandlers server.use connect.router (app)-> app.get '/info', (req,res)-> res.end "info" app.get '/user/:id', (req,res)-> res.end "user id: #{req.params.id}" 이와 같은 코드를 server 디렉토리에 안에 넣거나 Meteor.isServer일때 실행하도록 하자. 파일 업로드나 쿼리 문자열 처리(ex: ?a=1&b=c)하려면 각각 bodyParser( http://www.senchalabs.org/connect/bodyParser.html ) 와 query( http://www.senchalabs.org/connect/query.html )를 추가하는 것이 좋다. 위의 해당 링크에 보면 소스까지 공개 해놓아서 이해하기 쉬우니 ...