live tiles on home page, ninjaed from andrew might need to randomize starting times, can be disabled by removing the slider class from the div, maybe this should be a setting in admin/categories

This commit is contained in:
Baris Soner Usakli
2013-07-06 22:02:24 -04:00
parent 8f4848cc69
commit ac04bef26e
6 changed files with 137 additions and 13 deletions

View File

@@ -200,6 +200,8 @@ var RDB = require('./redis.js'),
});
}
Categories.getModerators = function(cid, callback) {
RDB.smembers('cid:' + cid + ':moderators', function(err, mods) {
if (mods.length === 0)
@@ -274,11 +276,11 @@ var RDB = require('./redis.js'),
});
}
Categories.getRecentReplies = function(cid, callback) {
RDB.zrevrange('categories:recent_posts:cid:' + cid, 0, 4, function(err, pids) {
Categories.getRecentReplies = function(cid, count, callback) {
RDB.zrevrange('categories:recent_posts:cid:' + cid, 0, count, function(err, pids) {
if (pids.length == 0) {
callback(false);
callback([]);
return;
}
posts.getPostSummaryByPids(pids, function(posts) {
@@ -330,5 +332,7 @@ var RDB = require('./redis.js'),
});
}
};
}(exports));

View File

@@ -196,8 +196,6 @@ marked.setOptions({
RDB.del('cid:' + cid + ':read_by_uid', function(err, data) {
topics.markAsRead(tid, uid);
});
RDB.zadd('categories:recent_posts:cid:' + cid, Date.now(), pid);
});
Posts.getTopicPostStats(socket);
@@ -285,6 +283,8 @@ marked.setOptions({
feed.updateTopic(tid, cid);
RDB.zadd('categories:recent_posts:cid:' + cid, Date.now(), pid);
// this is a bit of a naive implementation, defn something to look at post-MVP
RDB.scard('cid:' + cid + ':active_users', function(amount) {
if (amount > 10) {
@@ -295,6 +295,8 @@ marked.setOptions({
});
});
user.onNewPostMade(uid, tid, pid, timestamp);
if (callback)

View File

@@ -186,9 +186,25 @@ var express = require('express'),
break;
case 'home' :
categories.getAllCategories(function(data) {
data.motd_class = (config.show_motd === '1' || config.show_motd === undefined) ? '' : 'none';
data.motd = marked(config.motd || "# NodeBB v0.1\nWelcome to NodeBB, the discussion platform of the future.\n\n<a target=\"_blank\" href=\"http://www.nodebb.org\" class=\"btn btn-large\"><i class=\"icon-comment\"></i> Get NodeBB</a> <a target=\"_blank\" href=\"https://github.com/designcreateplay/NodeBB\" class=\"btn btn-large\"><i class=\"icon-github-alt\"></i> Fork us on Github</a> <a target=\"_blank\" href=\"https://twitter.com/dcplabs\" class=\"btn btn-large\"><i class=\"icon-twitter\"></i> @dcplabs</a>");
res.json(data);
var async = require('async');
function iterator(category, callback) {
console.log(category.cid);
categories.getRecentReplies(category.cid, 2, function(posts) {
category["posts"] = posts;
category["post_count"] = posts.length;
callback(null);
});
}
async.each(data.categories, iterator, function(err) {
data.motd_class = (config.show_motd === '1' || config.show_motd === undefined) ? '' : 'none';
data.motd = marked(config.motd || "# NodeBB v0.1\nWelcome to NodeBB, the discussion platform of the future.\n\n<a target=\"_blank\" href=\"http://www.nodebb.org\" class=\"btn btn-large\"><i class=\"icon-comment\"></i> Get NodeBB</a> <a target=\"_blank\" href=\"https://github.com/designcreateplay/NodeBB\" class=\"btn btn-large\"><i class=\"icon-github-alt\"></i> Fork us on Github</a> <a target=\"_blank\" href=\"https://twitter.com/dcplabs\" class=\"btn btn-large\"><i class=\"icon-twitter\"></i> @dcplabs</a>");
res.json(data);
});
}, uid);
break;
case 'login' :

View File

@@ -287,7 +287,7 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
});
socket.on('api:categories.getRecentReplies', function(tid) {
categories.getRecentReplies(tid, function(replies) {
categories.getRecentReplies(tid, 4, function(replies) {
socket.emit('api:categories.getRecentReplies', replies);
});
});