var RDB = require('./redis.js'), posts = require('./posts.js'), utils = require('./utils.js'); (function(Topics) { //data structure //*global:next_topic_id // *tid:1:title // *tid:1:uid // *tid:1:posts (array of pid) // *tid:1:timestamp // *uid:1:tozpics // *topic:slug:how-to-eat-chicken:tid Topics.get_by_category = function(callback, category, start, end) { } Topics.generate_topic_body = function(callback, tid, start, end) { var topic_body = global.templates['topic']; posts.get(function(data) { topic_body = topic_body.parse(data); callback(topic_body); }, tid, start, end); }; // this needs to move into forum.js Topics.generate_forum_body = function(callback, start, end) { var forum_body = global.templates['home']; Topics.get(function(data) { forum_body = forum_body.parse(data); callback(forum_body); }, start, end); }; Topics.get = function(callback, start, end) { if (start == null) start = 0; if (end == null) end = start + 10; RDB.lrange('topics:tid', start, end, function(tids) { var title = [], uid = [], timestamp = [], slug = [], postcount = []; for (var i=0, ii=tids.length; i 0) { RDB.multi() .mget(title) .mget(uid) .mget(timestamp) .mget(slug) .mget(postcount) .exec(function(err, replies) { title = replies[0]; uid = replies[1]; timestamp = replies[2]; slug = replies[3]; postcount = replies[4]; var topics = []; for (var i=0, ii=title.length; i