Skip to content

Node.js based forum software built for the modern web

added profile views to users, little cleanup to use app.addCommasToNumbers

Baris Soner Usakli6690f49c4e32
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 @@
</div>
<div class="span4">
- <h4>profile</h4>
<div class="inline-block">
<div class="account-bio-block">
<span class="account-bio-label">email</span><i class="icon-eye-close {emailClass}" title="Email hidden"></i>
@@ -61,20 +60,24 @@
<span>{joindate}</span>
<br/>
+ <span class="account-bio-label">profile views</span>
+ <span class="formatted-number">{profileviews}</span>
+ <br/>
+
<span class="account-bio-label">reputation</span>
- <span id='reputation'>{reputation}</span>
+ <span class="formatted-number">{reputation}</span>
<br/>
<span class="account-bio-label">posts</span>
- <span id='postcount'>{postcount}</span>
+ <span class="formatted-number">{postcount}</span>
<br/>
<span class="account-bio-label">followers</span>
- <span>{followerCount}</span>
+ <span class="formatted-number">{followerCount}</span>
<br/>
<span class="account-bio-label">following</span>
- <span>{followingCount}</span>
+ <span class="formatted-number">{followingCount}</span>
<br/>
<hr/>
@@ -87,7 +90,6 @@
</div>
<div class="span6 user-recent-posts">
- <h4>recent posts </h4>
<!-- BEGIN posts -->
<div class="topic-row img-polaroid clearfix" topic-url="topic/{posts.tid}/#{posts.pid}">
<span>{posts.content}</span>
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 @@
<a href="/users/{followers.userslug}">{followers.username}</a>
<br/>
<div title="reputation">
- <span class='reputation'>{followers.reputation}</span>
+ <span class='formatted-number'>{followers.reputation}</span>
<i class='icon-star'></i>
</div>
<div title="post count">
- <span class='postcount'>{followers.postcount}</span>
+ <span class='formatted-number'>{followers.postcount}</span>
<i class='icon-pencil'></i>
</div>
</div>
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 @@
<a href="/users/{following.userslug}">{following.username}</a>
<br/>
<div title="reputation">
- <span class='reputation'>{following.reputation}</span>
+ <span class='formatted-number'>{following.reputation}</span>
<i class='icon-star'></i>
</div>
<div title="post count">
- <span class='postcount'>{following.postcount}</span>
+ <span class='formatted-number'>{following.postcount}</span>
<i class='icon-pencil'></i>
</div>
<a id="unfollow-btn" href="#" class="btn unfollow-btn" followingUid="{following.uid}" data-username="{following.username}">Unfollow</a>
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 @@
<a href="/users/{users.userslug}">{users.username}</a>
<br/>
<div title="reputation">
- <span class='reputation'>{users.reputation}</span>
+ <span class='formatted-number'>{users.reputation}</span>
<i class='icon-star'></i>
</div>
<div title="post count">
- <span class='postcount'>{users.postcount}</span>
+ <span class='formatted-number'>{users.postcount}</span>
<i class='icon-pencil'></i>
</div>
</div>
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,