From 6690f49c4e32b0fba947aa864748acbfe46042ba Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Fri, 16 Aug 2013 13:03:56 -0400 Subject: [PATCH] added profile views to users, little cleanup to use app.addCommasToNumbers --- public/src/forum/account.js | 6 +----- public/src/forum/followers.js | 8 +------- public/src/forum/following.js | 9 +-------- public/src/forum/users.js | 8 ++------ public/templates/account.tpl | 14 ++++++++------ public/templates/followers.tpl | 4 ++-- public/templates/following.tpl | 4 ++-- public/templates/users.tpl | 4 ++-- src/routes/user.js | 6 +++++- src/user.js | 1 + 10 files changed, 25 insertions(+), 39 deletions(-) diff --git a/public/src/forum/account.js b/public/src/forum/account.js index 0d56ffbc9a..aba3eb33a1 100644 --- a/public/src/forum/account.js +++ b/public/src/forum/account.js @@ -5,11 +5,7 @@ $(document).ready(function() { - var rep = $('#reputation'); - rep.html(app.addCommas(rep.html())); - - var postcount = $('#postcount'); - postcount.html(app.addCommas(postcount.html())); + app.addCommasToNumbers(); var followBtn = $('#follow-btn'); var unfollowBtn = $('#unfollow-btn'); diff --git a/public/src/forum/followers.js b/public/src/forum/followers.js index d5ad575f02..5e4ec7a00d 100644 --- a/public/src/forum/followers.js +++ b/public/src/forum/followers.js @@ -10,13 +10,7 @@ $('#no-followers-notice').show(); } - $('.reputation').each(function(index, element) { - $(element).html(app.addCommas($(element).html())); - }); - - $('.postcount').each(function(index, element) { - $(element).html(app.addCommas($(element).html())); - }); + app.addCommasToNumbers(); }); diff --git a/public/src/forum/following.js b/public/src/forum/following.js index dfeec84c3f..836fc274ca 100644 --- a/public/src/forum/following.js +++ b/public/src/forum/following.js @@ -32,14 +32,7 @@ }); } - $('.reputation').each(function(index, element) { - $(element).html(app.addCommas($(element).html())); - }); - - $('.postcount').each(function(index, element) { - $(element).html(app.addCommas($(element).html())); - }); - + app.addCommasToNumbers(); }); diff --git a/public/src/forum/users.js b/public/src/forum/users.js index 74283a3467..8a6eae77cd 100644 --- a/public/src/forum/users.js +++ b/public/src/forum/users.js @@ -8,6 +8,8 @@ parts = url.split('/'), active = parts[parts.length-1]; + app.addCommasToNumbers(); + jQuery('.nav-pills li').removeClass('active'); jQuery('.nav-pills li a').each(function() { if (this.getAttribute('href').match(active)) { @@ -67,13 +69,7 @@ }); - $('.reputation').each(function(index, element) { - $(element).html(app.addCommas($(element).html())); - }); - $('.postcount').each(function(index, element) { - $(element).html(app.addCommas($(element).html())); - }); function onUsersLoaded(users) { var html = templates.prepare(templates['users'].blocks['users']).parse({ users: users }); diff --git a/public/templates/account.tpl b/public/templates/account.tpl index 7d69bb4679..0a64875a43 100644 --- a/public/templates/account.tpl +++ b/public/templates/account.tpl @@ -34,7 +34,6 @@
-

profile

-

recent posts

{posts.content} diff --git a/public/templates/followers.tpl b/public/templates/followers.tpl index 212d88b2a6..83d62c2552 100644 --- a/public/templates/followers.tpl +++ b/public/templates/followers.tpl @@ -24,11 +24,11 @@ {followers.username}
- {followers.reputation} + {followers.reputation}
- {followers.postcount} + {followers.postcount}
diff --git a/public/templates/following.tpl b/public/templates/following.tpl index 92124561cb..ace399b34c 100644 --- a/public/templates/following.tpl +++ b/public/templates/following.tpl @@ -26,11 +26,11 @@ {following.username}
- {following.reputation} + {following.reputation}
- {following.postcount} + {following.postcount}
Unfollow diff --git a/public/templates/users.tpl b/public/templates/users.tpl index 49ba5056a2..5d94ed01c3 100644 --- a/public/templates/users.tpl +++ b/public/templates/users.tpl @@ -24,11 +24,11 @@ {users.username}
- {users.reputation} + {users.reputation}
- {users.postcount} + {users.postcount}
diff --git a/src/routes/user.js b/src/routes/user.js index a164e8d8f5..89d2854ca5 100644 --- a/src/routes/user.js +++ b/src/routes/user.js @@ -69,7 +69,7 @@ var user = require('./../user.js'), app.build_header({ req: req, res: res }, function(err, header) { res.send(header + app.create_route('users/' + req.params.userslug, 'account') + templates['footer']); - }); + }); }); }); @@ -303,6 +303,10 @@ var user = require('./../user.js'), userData.posts = posts.filter(function(p) {return p.deleted !== "1";}); userData.isFollowing = isFollowing; userData.signature = postTools.markdownToHTML(userData.signature, true); + if(!userData.profileviews) + userData.profileviews = 1; + if(callerUID !== userData.uid) + user.incrementUserFieldBy(userData.uid, 'profileviews', 1); res.json(userData); }); }); diff --git a/src/user.js b/src/user.js index b6e9e943f5..3da6ca7b98 100644 --- a/src/user.js +++ b/src/user.js @@ -63,6 +63,7 @@ var utils = require('./../public/src/utils.js'), 'picture': gravatar, 'gravatarpicture' : gravatar, 'uploadedpicture': '', + 'profileviews': 0, 'reputation': 0, 'postcount': 0, 'lastposttime': 0,