mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
Merged
This commit is contained in:
parent
2fd22e9d41
commit
6e863598d1
13 changed files with 42 additions and 62 deletions
|
@ -9,7 +9,7 @@
|
||||||
<a href="#" class="approve-link goto-edit">Approve</a>
|
<a href="#" class="approve-link goto-edit">Approve</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
| {{i18n "score"}}: {{shortScore}}, {{i18n "clicks"}}: {{clicksCount}}, {{i18n "views"}}: {{viewsCount}}
|
| {{i18n "score"}}: {{shortScore}}, {{i18n "clicks"}}: {{clickCount}}, {{i18n "views"}}: {{viewCount}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template name="postCommentsLink">
|
<template name="postCommentsLink">
|
||||||
<div class="post-meta-item">
|
<div class="post-meta-item">
|
||||||
<a class="comments-link" href="/posts/{{_id}}">
|
<a class="comments-link" href="/posts/{{_id}}">
|
||||||
<span class="count">{{commentsCount}}</span>
|
<span class="count">{{commentCount}}</span>
|
||||||
<span class="action">{{i18n 'Comments'}}</span>
|
<span class="action">{{i18n 'Comments'}}</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template name="postDiscuss">
|
<template name="postDiscuss">
|
||||||
<a class="discuss-link go-to-comments" href="/posts/{{_id}}">
|
<a class="discuss-link go-to-comments" href="/posts/{{_id}}">
|
||||||
<i class="icon-comment"></i>
|
<i class="icon-comment"></i>
|
||||||
<span class="count">{{commentsCount}}</span>
|
<span class="count">{{commentCount}}</span>
|
||||||
<span class="action">{{i18n 'Discuss'}}</span>
|
<span class="action">{{i18n 'Discuss'}}</span>
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
|
@ -1,7 +1,7 @@
|
||||||
Template[getTemplate('postsLoadMore')].helpers({
|
Template[getTemplate('postsLoadMore')].helpers({
|
||||||
hasMorePosts: function(){
|
hasMorePosts: function(){
|
||||||
// as long as we ask for N posts and all N posts showed up, then keep showing the "load more" button
|
// as long as we ask for N posts and all N posts showed up, then keep showing the "load more" button
|
||||||
return parseInt(Session.get('postsLimit')) == this.postsCount
|
return parseInt(Session.get('postsLimit')) == this.postCount
|
||||||
},
|
},
|
||||||
loadMoreUrl: function () {
|
loadMoreUrl: function () {
|
||||||
var count = parseInt(Session.get('postsLimit')) + parseInt(getSetting('postsPerPage', 10));
|
var count = parseInt(Session.get('postsLimit')) + parseInt(getSetting('postsPerPage', 10));
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
<a href="mailto:{{getEmail}}">{{getEmail}}</a>
|
<a href="mailto:{{getEmail}}">{{getEmail}}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>{{createdAtFormatted}}</td>
|
<td>{{createdAtFormatted}}</td>
|
||||||
<td>{{postsCount}}</td>
|
<td>{{postCount}}</td>
|
||||||
<td>{{commentsCount}}</td>
|
<td>{{commentCount}}</td>
|
||||||
<td>{{getKarma}}</td>
|
<td>{{getKarma}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{#if invites}}
|
{{#if invites}}
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
<a class="{{activeClass 'createdAt'}}" href="{{sortBy 'createdAt'}}">{{i18n "Created"}}</a>
|
<a class="{{activeClass 'createdAt'}}" href="{{sortBy 'createdAt'}}">{{i18n "Created"}}</a>
|
||||||
<a class="{{activeClass 'karma'}}" href="{{sortBy 'karma'}}">{{i18n "Karma"}}</a>
|
<a class="{{activeClass 'karma'}}" href="{{sortBy 'karma'}}">{{i18n "Karma"}}</a>
|
||||||
<a class="{{activeClass 'username'}}" href="{{sortBy 'username'}}">{{i18n "Username"}}</a>
|
<a class="{{activeClass 'username'}}" href="{{sortBy 'username'}}">{{i18n "Username"}}</a>
|
||||||
<a class="{{activeClass 'postsCount'}}" href="{{sortBy 'postsCount'}}">{{i18n "Posts"}}</a>
|
<a class="{{activeClass 'postCount'}}" href="{{sortBy 'postCount'}}">{{i18n "Posts"}}</a>
|
||||||
<a class="{{activeClass 'commentsCount'}}" href="{{sortBy 'commentsCount'}}">{{i18n "Comments"}}</a>
|
<a class="{{activeClass 'commentCount'}}" href="{{sortBy 'commentCount'}}">{{i18n "Comments"}}</a>
|
||||||
<a class="{{activeClass 'invitedCount'}}" href="{{sortBy 'invitedCount'}}">{{i18n "InvitedCount"}}</a>
|
<a class="{{activeClass 'invitedCount'}}" href="{{sortBy 'invitedCount'}}">{{i18n "InvitedCount"}}</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -158,11 +158,11 @@ Meteor.methods({
|
||||||
|
|
||||||
// increment comment count
|
// increment comment count
|
||||||
Meteor.users.update({_id: user._id}, {
|
Meteor.users.update({_id: user._id}, {
|
||||||
$inc: {'commentsCount': 1}
|
$inc: {'commentCount': 1}
|
||||||
});
|
});
|
||||||
|
|
||||||
Posts.update(postId, {
|
Posts.update(postId, {
|
||||||
$inc: {commentsCount: 1},
|
$inc: {commentCount: 1},
|
||||||
$set: {lastCommentedAt: now},
|
$set: {lastCommentedAt: now},
|
||||||
$addToSet: {commenters: user._id}
|
$addToSet: {commenters: user._id}
|
||||||
});
|
});
|
||||||
|
@ -176,13 +176,13 @@ Meteor.methods({
|
||||||
if(canEdit(Meteor.user(), comment)){
|
if(canEdit(Meteor.user(), comment)){
|
||||||
// decrement post comment count and remove user ID from post
|
// decrement post comment count and remove user ID from post
|
||||||
Posts.update(comment.postId, {
|
Posts.update(comment.postId, {
|
||||||
$inc: {commentsCount: -1},
|
$inc: {commentCount: -1},
|
||||||
$pull: {commenters: comment.userId}
|
$pull: {commenters: comment.userId}
|
||||||
});
|
});
|
||||||
|
|
||||||
// decrement user comment count and remove comment ID from user
|
// decrement user comment count and remove comment ID from user
|
||||||
Meteor.users.update({_id: comment.userId}, {
|
Meteor.users.update({_id: comment.userId}, {
|
||||||
$inc: {'commentsCount': -1}
|
$inc: {'commentCount': -1}
|
||||||
});
|
});
|
||||||
|
|
||||||
// note: should we also decrease user's comment karma ?
|
// note: should we also decrease user's comment karma ?
|
||||||
|
|
|
@ -28,11 +28,11 @@ postSchemaObject = {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true
|
optional: true
|
||||||
},
|
},
|
||||||
viewsCount: {
|
viewCount: {
|
||||||
type: Number,
|
type: Number,
|
||||||
optional: false
|
optional: false
|
||||||
},
|
},
|
||||||
commentsCount: {
|
commentCount: {
|
||||||
type: Number,
|
type: Number,
|
||||||
optional: false
|
optional: false
|
||||||
},
|
},
|
||||||
|
@ -44,7 +44,7 @@ postSchemaObject = {
|
||||||
type: Date,
|
type: Date,
|
||||||
optional: true
|
optional: true
|
||||||
},
|
},
|
||||||
clicksCount: {
|
clickCount: {
|
||||||
type: Number,
|
type: Number,
|
||||||
optional: false
|
optional: false
|
||||||
},
|
},
|
||||||
|
@ -225,9 +225,9 @@ Meteor.methods({
|
||||||
author: getDisplayNameById(userId),
|
author: getDisplayNameById(userId),
|
||||||
upvotes: 0,
|
upvotes: 0,
|
||||||
downvotes: 0,
|
downvotes: 0,
|
||||||
commentsCount: 0,
|
commentCount: 0,
|
||||||
clicksCount: 0,
|
clickCount: 0,
|
||||||
viewsCount: 0,
|
viewCount: 0,
|
||||||
baseScore: 0,
|
baseScore: 0,
|
||||||
score: 0,
|
score: 0,
|
||||||
inactive: false
|
inactive: false
|
||||||
|
@ -282,7 +282,7 @@ Meteor.methods({
|
||||||
// ------------------------------ Post-Insert ------------------------------ //
|
// ------------------------------ Post-Insert ------------------------------ //
|
||||||
|
|
||||||
// increment posts count
|
// increment posts count
|
||||||
Meteor.users.update({_id: userId}, {$inc: {postsCount: 1}});
|
Meteor.users.update({_id: userId}, {$inc: {postCount: 1}});
|
||||||
|
|
||||||
var postAuthor = Meteor.users.findOne(post.userId);
|
var postAuthor = Meteor.users.findOne(post.userId);
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ Meteor.methods({
|
||||||
|
|
||||||
if(_.where(postViews, view).length == 0){
|
if(_.where(postViews, view).length == 0){
|
||||||
postViews.push(view);
|
postViews.push(view);
|
||||||
Posts.update(postId, { $inc: { viewsCount: 1 }});
|
Posts.update(postId, { $inc: { viewCount: 1 }});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
increasePostClicks: function(postId, sessionId){
|
increasePostClicks: function(postId, sessionId){
|
||||||
|
@ -336,7 +336,7 @@ Meteor.methods({
|
||||||
|
|
||||||
if(_.where(postClicks, click).length == 0){
|
if(_.where(postClicks, click).length == 0){
|
||||||
postClicks.push(click);
|
postClicks.push(click);
|
||||||
Posts.update(postId, { $inc: { clicksCount: 1 }});
|
Posts.update(postId, { $inc: { clickCount: 1 }});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deletePostById: function(postId) {
|
deletePostById: function(postId) {
|
||||||
|
@ -350,7 +350,7 @@ Meteor.methods({
|
||||||
var post = Posts.findOne({_id: postId});
|
var post = Posts.findOne({_id: postId});
|
||||||
if(!Meteor.userId() || !canEditById(Meteor.userId(), post)) throw new Meteor.Error(606, 'You need permission to edit or delete a post');
|
if(!Meteor.userId() || !canEditById(Meteor.userId(), post)) throw new Meteor.Error(606, 'You need permission to edit or delete a post');
|
||||||
|
|
||||||
Meteor.users.update({_id: post.userId}, {$inc: {postsCount: -1}});
|
Meteor.users.update({_id: post.userId}, {$inc: {postCount: -1}});
|
||||||
Posts.remove(postId);
|
Posts.remove(postId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -58,11 +58,11 @@ getUsersParameters = function(filterBy, sortBy, limit) {
|
||||||
case 'karma':
|
case 'karma':
|
||||||
sort = {karma: -1};
|
sort = {karma: -1};
|
||||||
break;
|
break;
|
||||||
case 'postsCount':
|
case 'postCount':
|
||||||
sort = {postsCount: -1};
|
sort = {postCount: -1};
|
||||||
break;
|
break;
|
||||||
case 'commentsCount':
|
case 'commentCount':
|
||||||
sort = {"commentsCount": -1};
|
sort = {"commentCount": -1};
|
||||||
case 'invitedCount':
|
case 'invitedCount':
|
||||||
sort = {invitedCount: -1};
|
sort = {invitedCount: -1};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
privacyOptions = { // true means exposed
|
privacyOptions = { // true means exposed
|
||||||
_id: true,
|
_id: true,
|
||||||
commentsCount: true,
|
commentCount: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
email_hash: true,
|
email_hash: true,
|
||||||
isInvited: true,
|
isInvited: true,
|
||||||
karma: true,
|
karma: true,
|
||||||
postsCount: true,
|
postCount: true,
|
||||||
slug: true,
|
slug: true,
|
||||||
username: true,
|
username: true,
|
||||||
'profile.name': true,
|
'profile.name': true,
|
||||||
|
|
|
@ -311,7 +311,7 @@ PostsListController = FastRender.RouteController.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
var parameters = getPostsParameters(this._terms),
|
var parameters = getPostsParameters(this._terms),
|
||||||
postsCount = Posts.find(parameters.find, parameters.options).count();
|
postCount = Posts.find(parameters.find, parameters.options).count();
|
||||||
|
|
||||||
parameters.find.createdAt = { $lte: Session.get('listPopulatedAt') };
|
parameters.find.createdAt = { $lte: Session.get('listPopulatedAt') };
|
||||||
var posts = Posts.find(parameters.find, parameters.options);
|
var posts = Posts.find(parameters.find, parameters.options);
|
||||||
|
@ -325,7 +325,7 @@ PostsListController = FastRender.RouteController.extend({
|
||||||
return {
|
return {
|
||||||
incoming: postsIncoming,
|
incoming: postsIncoming,
|
||||||
postsList: posts,
|
postsList: posts,
|
||||||
postsCount: postsCount,
|
postCount: postCount,
|
||||||
ready: this.postsListSub.ready
|
ready: this.postsListSub.ready
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -128,13 +128,13 @@ var migrationsList = {
|
||||||
if(typeof user.isAdmin === 'undefined')
|
if(typeof user.isAdmin === 'undefined')
|
||||||
properties.isAdmin = false;
|
properties.isAdmin = false;
|
||||||
|
|
||||||
// update postsCount
|
// update postCount
|
||||||
var postsByUser = Posts.find({userId: user._id});
|
var postsByUser = Posts.find({userId: user._id});
|
||||||
properties.postsCount = postsByUser.count();
|
properties.postCount = postsByUser.count();
|
||||||
|
|
||||||
// update commentsCount
|
// update commentCount
|
||||||
var commentsByUser = Comments.find({userId: user._id});
|
var commentsByUser = Comments.find({userId: user._id});
|
||||||
properties.commentsCount = commentsByUser.count();
|
properties.commentCount = commentsByUser.count();
|
||||||
|
|
||||||
Meteor.users.update(user._id, {$set:properties});
|
Meteor.users.update(user._id, {$set:properties});
|
||||||
|
|
||||||
|
@ -285,12 +285,12 @@ var migrationsList = {
|
||||||
});
|
});
|
||||||
return i;
|
return i;
|
||||||
},
|
},
|
||||||
commentsToCommentsCount: function () {
|
commentsToCommentCount: function () {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
Posts.find({commentsCount: {$exists : false}}).forEach(function (post) {
|
Posts.find({commentCount: {$exists : false}}).forEach(function (post) {
|
||||||
i++;
|
i++;
|
||||||
console.log("Post: "+post._id);
|
console.log("Post: "+post._id);
|
||||||
Posts.update(post._id, { $rename: { 'comments': 'commentsCount'}}, {multi: true, validate: false});
|
Posts.update(post._id, { $rename: { 'comments': 'commentCount'}}, {multi: true, validate: false});
|
||||||
console.log("---------------------");
|
console.log("---------------------");
|
||||||
});
|
});
|
||||||
return i;
|
return i;
|
||||||
|
@ -355,34 +355,14 @@ var migrationsList = {
|
||||||
});
|
});
|
||||||
return i;
|
return i;
|
||||||
},
|
},
|
||||||
commentCountToCommentsCount: function () {
|
clicksToClickCount: function () {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
Meteor.users.find({"commentsCount": {$exists : false}}).forEach(function (user) {
|
Posts.find({"clickCount": {$exists : false}}).forEach(function (post) {
|
||||||
i++;
|
|
||||||
console.log("User: " + user._id);
|
|
||||||
Meteor.users.update(user._id, { $rename: { 'commentCount': 'commentsCount'}}, {multi: true, validate: false});
|
|
||||||
console.log("---------------------");
|
|
||||||
});
|
|
||||||
return i;
|
|
||||||
},
|
|
||||||
clicksToClicksCount: function () {
|
|
||||||
var i = 0;
|
|
||||||
Posts.find({"clicksCount": {$exists : false}}).forEach(function (post) {
|
|
||||||
i++;
|
i++;
|
||||||
console.log("Post: " + post._id);
|
console.log("Post: " + post._id);
|
||||||
Posts.update(post._id, { $rename: { 'clicks': 'clicksCount'}}, {multi: true, validate: false});
|
Posts.update(post._id, { $rename: { 'clicks': 'clickCount'}}, {multi: true, validate: false});
|
||||||
console.log("---------------------");
|
console.log("---------------------");
|
||||||
});
|
});
|
||||||
return i;
|
return i;
|
||||||
},
|
|
||||||
postCountToPostsCount: function () {
|
|
||||||
var i = 0;
|
|
||||||
Meteor.users.find({"postsCount": {$exists : false}}).forEach(function (user) {
|
|
||||||
i++;
|
|
||||||
console.log("User: " + user._id);
|
|
||||||
Meteor.users.update(user._id, { $rename: { 'postCount': 'postsCount'}}, {multi: true, validate: false});
|
|
||||||
console.log("---------------------");
|
|
||||||
});
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -3,8 +3,8 @@ Accounts.onCreateUser(function(options, user){
|
||||||
profile: options.profile || {},
|
profile: options.profile || {},
|
||||||
karma: 0,
|
karma: 0,
|
||||||
isInvited: false,
|
isInvited: false,
|
||||||
postsCount: 0,
|
postCount: 0,
|
||||||
commentsCount: 0,
|
commentCount: 0,
|
||||||
invitedCount: 0,
|
invitedCount: 0,
|
||||||
votes: {
|
votes: {
|
||||||
upvotedPosts: [],
|
upvotedPosts: [],
|
||||||
|
|
Loading…
Add table
Reference in a new issue