1. Meteor로 만드는
Modern Web Application
이재호 (Founder of Appsoulute)
jhlee@appsoulute.com
http://github.com/acidsound
http://spectrumdig.blogspot.com
@acidsound
4. 구현 목표
관심사 Page단위 SNS 서비스
1.
2.
3.
4.
5.
6.
7.
8.
9.
화면 생성
포스트 입력 저장
입력 이벤트 처리
포스트 정렬 및 페이지 지정
페이지별 라우터 생성
스마트 패키지 이용 시간 처리
사용자 계정 적용
페이지별 가입/탈퇴 처리
마이페이지 구현
6. JS
>> client directory
if (Meteor.isClient) {
}
>> server directory
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
8. Head 1/2
<template name="head">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<!-- .btn-navbar is used as the toggle for collapsed
navbar content -->
<a class="btn btn-navbar" data-toggle="collapse"
data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
9. Head 2/2
<!-- Be sure to leave the brand out there if you want it
shown -->
<a class="brand" href="/">Sogon</a>
<!-- Everything you want hidden at 940px or less,
place within here -->
<div class="nav-collapse collapse">
<!-- .nav, .navbar-search, .navbar-form, etc -->
</div>
</div>
</div>
</div>
</template>
25. 비 로그인 시 Title 추가
<template name="title">
<div class="container hero-unit">
<h1>Hello Sogon!</h1>
<p>
Simple and Robust SNS
</p>
<button class="btn btn-info pull-right">Read
More..</button>
</div>
34. Form with User()
* template main
{{#if currentUser}}
<li class="row">
<form class="form-inline">
<textarea class="postText input-block-level"
placeholder="shift+enter to post.."></textarea>
<button type="reset" class="btn pull-right"><i class="
icon-trash"/></button>
<button type="submit" class="btn-primary submit btn
pull-right"><i class="icon-white icon-pencil"/></button>
</form>
</li>
35. Subscribers 구조
JSON Key/Value 구조
user()
ㄴ profile
ㄴ subscribers
ㄴ page1
ㄴ timestamp
ㄴ page2
ㄴ timestamp
>> 가입 여부 확인
!!Subscribers['page1'] -> 있으면 true 없으면 null이니까 false
>> 검색
Posts.find({page: {$in : [ 유저가 가입한 Page들의 이름 Array
]});
40. Posts collection subscribe
Page 에서 볼때 page 기준
유저의 MyPage 에선 User 하는 기준으로
following
Meteor.autosubscribe(function() {
Meteor.subscribe('posts', Session.get
('page'), Meteor.user());
});