mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-04 12:18:28 +02:00
Merge branch 'master' of https://github.com/designcreateplay/NodeBB
This commit is contained in:
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -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>
|
||||
|
||||
@@ -267,7 +267,26 @@ var RDB = require('./redis.js'),
|
||||
});
|
||||
}
|
||||
|
||||
Categories.isTopicsRead = function(cid, uid, callback) {
|
||||
RDB.smembers('categories:' + cid + ':tid', function(err, tids) {
|
||||
|
||||
topics.hasReadTopics(tids, uid, function(hasRead) {
|
||||
|
||||
var allread = true;
|
||||
for (var i=0, ii=tids.length; i<ii; i++) {
|
||||
if(hasRead[i] === 0) {
|
||||
allread = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
callback(allread);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Categories.markAsRead = function(cid, uid) {
|
||||
RDB.sadd('cid:' + cid + ':read_by_uid', uid);
|
||||
}
|
||||
|
||||
Categories.hasReadCategories = function(cids, uid, callback) {
|
||||
var batch = RDB.multi();
|
||||
|
||||
25
src/posts.js
25
src/posts.js
@@ -186,11 +186,11 @@ marked.setOptions({
|
||||
RDB.del('tid:' + tid + ':read_by_uid'); // let everybody know there is an unread post
|
||||
|
||||
Posts.get_cid_by_pid(pid, function(cid) {
|
||||
RDB.del('cid:' + cid + ':read_by_uid');
|
||||
RDB.del('cid:' + cid + ':read_by_uid', function(err, data) {
|
||||
topics.markAsRead(tid, uid);
|
||||
});
|
||||
|
||||
RDB.zadd('categories:recent_posts:cid:' + cid, Date.now(), pid);
|
||||
|
||||
topics.markAsRead(tid, uid);
|
||||
});
|
||||
|
||||
|
||||
@@ -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[0]?data[0]:0,
|
||||
posts: data[1]?data[1]:0
|
||||
};
|
||||
|
||||
socket.emit('post.stats', stats);
|
||||
}
|
||||
else
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
}(exports));
|
||||
@@ -218,10 +218,16 @@ marked.setOptions({
|
||||
}
|
||||
|
||||
Topics.markAsRead = function(tid, uid) {
|
||||
// there is an issue with this fn. if you read a topic that is previously read you will mark the category as read anyways - there is no check
|
||||
|
||||
RDB.sadd(schema.topics(tid).read_by_uid, uid);
|
||||
|
||||
Topics.get_cid_by_tid(tid, function(cid) {
|
||||
RDB.sadd('cid:' + cid + ':read_by_uid', uid);
|
||||
|
||||
categories.isTopicsRead(cid, uid, function(read) {
|
||||
if(read) {
|
||||
categories.markAsRead(cid, uid);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -368,11 +374,11 @@ 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);
|
||||
}
|
||||
});
|
||||
|
||||
Topics.markAsRead(tid, uid);
|
||||
|
||||
// User Details - move this out later
|
||||
RDB.lpush('uid:' + uid + ':topics', tid);
|
||||
|
||||
@@ -384,8 +390,11 @@ marked.setOptions({
|
||||
});
|
||||
|
||||
// let everyone know that there is an unread topic in this category
|
||||
RDB.del('cid:' + category_id + ':read_by_uid');
|
||||
RDB.del('cid:' + category_id + ':read_by_uid', function(err, data) {
|
||||
Topics.markAsRead(tid, uid);
|
||||
});
|
||||
|
||||
|
||||
RDB.zadd(schema.topics().recent, Date.now(), tid);
|
||||
//RDB.zadd('topics:active', tid);
|
||||
|
||||
@@ -398,10 +407,12 @@ marked.setOptions({
|
||||
});
|
||||
|
||||
RDB.incr('cid:' + category_id + ':topiccount');
|
||||
RDB.incr('totaltopiccount');
|
||||
|
||||
feed.updateCategory(category_id);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
}(exports));
|
||||
@@ -32,7 +32,7 @@ var express = require('express'),
|
||||
};
|
||||
|
||||
// Middlewares
|
||||
app.use(express.favicon()); // 2 args: string path and object options (i.e. expire time etc)
|
||||
app.use(express.favicon(path.join(__dirname, '../', 'public', 'favicon.ico')));
|
||||
app.use(require('less-middleware')({ src: path.join(__dirname, '../', 'public') }));
|
||||
app.use(express.static(path.join(__dirname, '../', 'public')));
|
||||
app.use(express.bodyParser()); // Puts POST vars in request.body
|
||||
|
||||
@@ -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