기본 콘텐츠로 건너뛰기

11월, 2013의 게시물 표시

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()] 이렇게 [ ] 배열 형태로 묶어만 주면 된다. 좋은 패치라고 생각한다. 적극적으로 활용하자.

iron-router에서 /#/(hashbang) 을 사용할때 주의점( ex. verify-email등)

iron-router 적응 중인데 역시 대세다. 최근 server-side도 반영되어 구 router package에서 안심하고 넘어와도 되겠다 싶었다. E-mail 인증( http://spectrumdig.blogspot.kr/2013/10/meteor-e-mail.html )을 구현해 놓았는데 이게 실제로 해보니까 iron-router 에선 제대로 되지 않는다. 찾아보니 Server 쪽에서 해당 URL이 들어올때 패치하는 방법이 있다. https://github.com/EventedMind/iron-router/issues/3#issuecomment-20917649 Server 아래 Route 관련 부분에 Accounts.urls.resetPassword = (token) ->   Meteor.absoluteUrl "reset-password/#{token}" Accounts.urls.verifyEmail = (token) ->   Meteor.absoluteUrl "verify-email/#{token}" Accounts.urls.enrollAccount = (token) ->   Meteor.absoluteUrl "enroll-account/#{token}" 이런 식으로 넣어주면 된다.

meteor에서 특정 조건에서 head를 조작하기

server/header.js 식으로 server에서만 작동하는 코드를 만들자. Fiber = Npm.require("fibers"); WebApp.connectHandlers.use(function(req, res, next) { if (req.url==='/connect') { res.writeHead(200, {'Content-Type': 'text/html'}); Fiber(function() { res.write('<html>') res.write('<head>'); res.write('<meta property="qc:admins" content="2311172222411526554572637573766534" />'); res.write('<head>'); res.write('<body></body>'); res.write('</html>') res.end(); }).run(); } else { next(); } }); 위 코드는 weiyun 인증의 경우인데 <meta property="qc:admins" ... 를 사이트에서 요구하는 경우이다. 이런 식으로 meta를 요구하는 경우가 종종 있는데 아마 구글 서비스 중에도 있을 듯. 사이트 도구? 아마 그럴 것이다. 저번에도 이야기 했지만 WebApp.connectHandlers 요거 좋은 놈이다. 서버쪽에서 특정 url로 들어왔을때 예외처리를 하고 싶다면 이걸 사용하면 된다. 예의 경우는 /connect 로 들어왔을 때만 예외처리를 하고 나머지는 그냥 next()로 넘겼다.

SoX Library 컴파일하기(for OS X)

./osxbuild 실행 오류 $ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" $ brew install automake 재시도 $ ./osxbuild configure.ac:21: installing './compile' configure.ac:10: installing './config.guess' configure.ac:10: installing './config.sub' configure.ac:12: installing './install-sh' configure.ac:12: installing './missing' libgsm/Makefile.am:35: error: Libtool library used but 'LIBTOOL' is undefined libgsm/Makefile.am:35:   The usual way to define 'LIBTOOL' is to add 'LT_INIT' libgsm/Makefile.am:35:   to 'configure.ac' and run 'aclocal' and 'autoconf' again. libgsm/Makefile.am:35:   If 'LT_INIT' is in 'configure.ac', make sure libgsm/Makefile.am:35:   its definition is in aclocal's search path. libgsm/Makefile.am: installing './depcomp' lpc10/Makefile.am:8: error: Libtool library used but 'LIBTOOL' is undefined