mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
footer shows total topic post count
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
(function() {
|
||||
var num_users = document.getElementById('number_of_users'),
|
||||
post_stats = document.getElementById('post_stats'),
|
||||
latest_user = document.getElementById('latest_user'),
|
||||
active_users = document.getElementById('active_users'),
|
||||
user_label = document.getElementById('user_label'),
|
||||
@@ -10,6 +11,12 @@
|
||||
socket.on('user.count', function(data) {
|
||||
num_users.innerHTML = "We currently have <b>" + data.count + "</b> registered users.";
|
||||
});
|
||||
|
||||
socket.emit('post.stats');
|
||||
socket.on('post.stats', function(data) {
|
||||
post_stats.innerHTML = "Our uses have created " + data.topics + " topics and made " + data.posts + " posts.";
|
||||
});
|
||||
|
||||
socket.emit('user.latest', {});
|
||||
socket.on('user.latest', function(data) {
|
||||
if (data.username == '') {
|
||||
@@ -18,6 +25,7 @@
|
||||
latest_user.innerHTML = "The most recent user to register is <b><a href='/users/"+data.userslug+"'>" + data.username + "</a></b>.";
|
||||
}
|
||||
});
|
||||
|
||||
socket.emit('api:user.active.get');
|
||||
socket.on('api:user.active.get', function(data) {
|
||||
var plural_users = parseInt(data.users) !== 1,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<div id="footer" class="container hidden-phone" style="padding-top: 50px; display: none">
|
||||
<div class="alert alert-info">
|
||||
<span id="active_users"></span>; <span id="active_record"></span><br />
|
||||
<span id="number_of_users"></span><br />
|
||||
<span id="number_of_users"></span> <span id="post_stats"></span><br />
|
||||
<span id="latest_user"></span>
|
||||
</div>
|
||||
<footer class="footer">Copyright © 2013 <a target="_blank" href="http://www.nodebb.org">NodeBB</a> by <a target="_blank" href="https://github.com/psychobunny">psychobunny</a>, <a href="https://github.com/julianlam" target="_blank">julianlam</a>, <a href="https://github.com/barisusakli" target="_blank">barisusakli</a> from <a target="_blank" href="http://www.designcreateplay.com">designcreateplay</a></footer>
|
||||
|
||||
19
src/posts.js
19
src/posts.js
@@ -201,6 +201,8 @@ marked.setOptions({
|
||||
timeout: 2000
|
||||
});
|
||||
|
||||
Posts.getTopicPostStats(socket);
|
||||
|
||||
// Send notifications to users who are following this topic
|
||||
threadTools.notify_followers(tid, uid);
|
||||
|
||||
@@ -265,6 +267,8 @@ marked.setOptions({
|
||||
RDB.zadd(schema.topics().recent, timestamp, tid);
|
||||
RDB.set('tid:' + tid + ':lastposttime', timestamp);
|
||||
|
||||
RDB.incr('totalpostcount');
|
||||
|
||||
user.getUserFields(uid, ['username'], function(data) { // todo parallel
|
||||
//add active users to this category
|
||||
RDB.get('tid:' + tid + ':cid', function(err, cid) {
|
||||
@@ -339,4 +343,19 @@ marked.setOptions({
|
||||
});
|
||||
}
|
||||
|
||||
Posts.getTopicPostStats = function(socket) {
|
||||
RDB.mget(['totaltopiccount', 'totalpostcount'], function(err, data) {
|
||||
if(err === null) {
|
||||
var stats = {
|
||||
topics: data[1]?data[1]:0,
|
||||
posts: data[0]?data[0]:0
|
||||
};
|
||||
|
||||
socket.emit('post.stats', stats);
|
||||
}
|
||||
else
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
}(exports));
|
||||
@@ -368,6 +368,8 @@ marked.setOptions({
|
||||
io.sockets.in('category_' + category_id).emit('event:new_topic', topicData);
|
||||
io.sockets.in('recent_posts').emit('event:new_topic', topicData);
|
||||
});
|
||||
|
||||
posts.getTopicPostStats(socket);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -398,10 +400,12 @@ marked.setOptions({
|
||||
});
|
||||
|
||||
RDB.incr('cid:' + category_id + ':topiccount');
|
||||
RDB.incr('totaltopiccount');
|
||||
|
||||
feed.updateCategory(category_id);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
}(exports));
|
||||
@@ -160,6 +160,10 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
user.count(socket, data);
|
||||
});
|
||||
|
||||
socket.on('post.stats', function(data) {
|
||||
posts.getTopicPostStats(socket);
|
||||
});
|
||||
|
||||
socket.on('user.latest', function(data) {
|
||||
user.latest(socket, data);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user