From 1ec67264592d960328fffbc9c709740f099f96b7 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Mon, 4 Nov 2013 16:00:34 -0500 Subject: [PATCH] template changes to recent and unread --- public/templates/recent.tpl | 80 +++++++++++++++++++------------------ public/templates/unread.tpl | 78 +++++++++++++++++++----------------- src/categories.js | 8 +--- src/topics.js | 16 ++++++-- 4 files changed, 96 insertions(+), 86 deletions(-) diff --git a/public/templates/recent.tpl b/public/templates/recent.tpl index 3542bde8a2..e9c86be854 100644 --- a/public/templates/recent.tpl +++ b/public/templates/recent.tpl @@ -24,49 +24,51 @@
+ diff --git a/public/templates/unread.tpl b/public/templates/unread.tpl index 0f232b22cd..641df62c1b 100644 --- a/public/templates/unread.tpl +++ b/public/templates/unread.tpl @@ -19,46 +19,50 @@
+ diff --git a/src/categories.js b/src/categories.js index d39dc1a729..df155d69f1 100644 --- a/src/categories.js +++ b/src/categories.js @@ -310,13 +310,7 @@ var RDB = require('./redis.js'), }; Categories.getCategoryFields = function(cid, fields, callback) { - RDB.hmgetObject('category:' + cid, fields, function(err, data) { - if (err === null) { - callback(data); - } else { - winston.err(err); - } - }); + RDB.hmgetObject('category:' + cid, fields, callback); }; Categories.setCategoryField = function(cid, field, value) { diff --git a/src/topics.js b/src/topics.js index 94551b5350..571f57a545 100644 --- a/src/topics.js +++ b/src/topics.js @@ -306,7 +306,14 @@ var RDB = require('./redis.js'), }); } - async.parallel([getUserInfo, hasReadTopic, getTeaserInfo, getPrivileges], function(err, results) { + function getCategoryInfo(next) { + categories.getCategoryFields(topicData.cid, ['name', 'slug', 'icon'], function(err, categoryData) { + console.log(categoryData); + next(err, categoryData); + }); + } + + async.parallel([getUserInfo, hasReadTopic, getTeaserInfo, getPrivileges, getCategoryInfo], function(err, results) { callback({ username: results[0].username, userslug: results[0].userslug, @@ -314,7 +321,8 @@ var RDB = require('./redis.js'), userbanned: results[0].banned, hasread: results[1], teaserInfo: results[2], - privileges: results[3] + privileges: results[3], + categoryData: results[4] }); }); } @@ -339,13 +347,15 @@ var RDB = require('./redis.js'), topicData.username = topicInfo.username; topicData.userslug = topicInfo.userslug; topicData.picture = topicInfo.picture; + topicData.categoryIcon = topicInfo.categoryData.icon; + topicData.categoryName = topicInfo.categoryData.name; + topicData.categorySlug = topicInfo.categoryData.slug; topicData.badgeclass = (topicInfo.hasread && current_user != 0) ? '' : 'badge-important'; topicData.teaser_text = topicInfo.teaserInfo.text || '', topicData.teaser_username = topicInfo.teaserInfo.username || ''; topicData.teaser_userslug = topicInfo.teaserInfo.userslug || ''; topicData.teaser_userpicture = topicInfo.teaserInfo.picture || require('gravatar').url('', {}, https = nconf.get('https')); topicData.teaser_pid = topicInfo.teaserInfo.pid; - topicData.teaser_timestamp = topicInfo.teaserInfo.timestamp ? (new Date(parseInt(topicInfo.teaserInfo.timestamp, 10)).toISOString()) : ''; if (isTopicVisible(topicData, topicInfo))