Vulcan/client/templates/user_item.js

55 lines
1.3 KiB
JavaScript
Raw Normal View History

2012-09-18 12:21:43 +09:00
Template.user_item.rendered = function(){
};
2012-09-18 15:43:37 +09:00
Template.user_item.avatar_url = function(){
return Gravatar.getGravatar(this, {
d: 'http://telescope.herokuapp.com/img/default_avatar.png',
s: 30
});
};
Template.user_item.created_at_formatted = function(){
// return moment(this.created_at).format("MMMM Do YYYY, HH:mm");
2012-09-24 11:31:45 +09:00
// console.log("user: ", this);
// if(!this.created_at && !window.foo){
// Meteor.users.update(this._id,
// {
// $set: {
// created_at: new Date().getTime()
// }
// }, function(error){
// console.log(error);
// throwError(error.reason);
// }
// );
// window.foo=true;
// }
return moment(this.created_at).fromNow();
}
Template.user_item.email = function(){
2012-09-18 16:29:26 +09:00
if(this.emails){
return this.emails[0].email;
}
}
2012-09-18 16:38:40 +09:00
Template.user_item.posts = function(){
return Posts.find({'user_id':this._id});
}
Template.user_item.posts_count = function(){
return Posts.find({'user_id':this._id}).count();
}
2012-09-18 16:38:40 +09:00
Template.user_item.comments = function(){
return Comments.find({'user_id':this._id});
}
Template.user_item.comments_count = function(){
// Posts.find({'user_id':this._id}).forEach(function(post){console.log(post.headline);});
return Comments.find({'user_id':this._id}).count();
2012-09-19 10:15:03 +09:00
}
Template.user_item.is_admin = function(){
return isAdmin(this);
2012-09-18 15:43:37 +09:00
}