diff --git a/public/templates/category.tpl b/public/templates/category.tpl
index e37cbd10aa..52b2148ac5 100644
--- a/public/templates/category.tpl
+++ b/public/templates/category.tpl
@@ -43,6 +43,8 @@
+
+
-
-
diff --git a/src/topics.js b/src/topics.js
index bed9ac2416..82f353cc3e 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -1,4 +1,5 @@
-var RDB = require('./redis.js'),
+var RDB = require('./redis.js')
+ schema = require('./schema.js'),
posts = require('./posts.js'),
utils = require('./../public/src/utils.js'),
user = require('./user.js'),
@@ -17,12 +18,12 @@ marked.setOptions({
Topics.getTopicById = function(tid, current_user, callback) {
function getTopicData(next) {
RDB.multi()
- .get('tid:' + tid + ':title')
- .get('tid:' + tid + ':locked')
- .get('tid:' + tid + ':category_name')
- .get('tid:' + tid + ':category_slug')
- .get('tid:' + tid + ':deleted')
- .get('tid:' + tid + ':pinned')
+ .get(schema.topics(tid).title)
+ .get(schema.topics(tid).locked)
+ .get(schema.topics(tid).category_name)
+ .get(schema.topics(tid).category_slug)
+ .get(schema.topics(tid).deleted)
+ .get(schema.topics(tid).pinned)
.exec(function(err, replies) {
next(null, {
topic_name: replies[0],
@@ -118,14 +119,14 @@ marked.setOptions({
function get_topic_data(next) {
RDB.mget([
- 'tid:' + tid + ':title',
- 'tid:' + tid + ':uid',
- 'tid:' + tid + ':timestamp',
- 'tid:' + tid + ':slug',
- 'tid:' + tid + ':postcount',
- 'tid:' + tid + ':locked',
- 'tid:' + tid + ':pinned',
- 'tid:' + tid + ':deleted'
+ schema.topics(tid).title,
+ schema.topics(tid).uid,
+ schema.topics(tid).timestamp,
+ schema.topics(tid).slug,
+ schema.topics(tid).postcount,
+ schema.topics(tid).locked,
+ schema.topics(tid).pinned,
+ schema.topics(tid).deleted
], function(err, topic) {
if (err) {
throw new Error(err);
@@ -152,7 +153,7 @@ marked.setOptions({
function get_read_status(next) {
// posts.create calls this function - should be an option to skip this because its always true
if (uid && parseInt(uid) > 0) {
- RDB.sismember('tid:' + tid + ':read_by_uid', uid, function(err, read) {
+ RDB.sismember(schema.topics(tid).read_by_uid, uid, function(err, read) {
topicData.badgeclass = read ? '' : 'badge-important';
next();
@@ -181,7 +182,7 @@ marked.setOptions({
}
Topics.get_cid_by_tid = function(tid, callback) {
- RDB.get('tid:' + tid + ':cid', function(err, cid) {
+ RDB.get(schema.topics(tid).cid, function(err, cid) {
if (cid && parseInt(cid) > 0) {
callback(cid);
} else {
@@ -192,7 +193,7 @@ 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('tid:' + tid + ':read_by_uid', uid);
+ 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);
});
@@ -202,7 +203,7 @@ marked.setOptions({
var batch = RDB.multi();
for (var i=0, ii=tids.length; i 0) {
- RDB.lpush('tid:' + tid + ':posts', pid);
+ RDB.lpush(schema.topic(tid).posts, pid);
// Notify any users looking at the category that a new topic has arrived
Topics.get_topic(tid, uid, function(topicData) {
@@ -355,15 +357,15 @@ marked.setOptions({
// let everyone know that there is an unread topic in this category
RDB.del('cid:' + category_id + ':read_by_uid');
- RDB.zadd('topics:recent', (new Date()).getTime(), tid);
+ RDB.zadd(schema.topics().recent, (new Date()).getTime(), tid);
//RDB.zadd('topics:active', tid);
// in future it may be possible to add topics to several categories, so leaving the door open here.
RDB.sadd('categories:' + category_id + ':tid', tid);
- RDB.set('tid:' + tid + ':cid', category_id);
+ RDB.set(schema.topics(tid).cid, category_id);
categories.getCategories([category_id], function(data) {
- RDB.set('tid:' + tid + ':category_name', data.categories[0].name);
- RDB.set('tid:' + tid + ':category_slug', data.categories[0].slug);
+ RDB.set(schema.topics(tid).category_name, data.categories[0].name);
+ RDB.set(schema.topics(tid).category_slug, data.categories[0].slug);
});
RDB.incr('cid:' + category_id + ':topiccount');