From 976744480f945cc32b085fd05720a16f6537b9e3 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Wed, 5 Mar 2014 14:52:32 -0500 Subject: [PATCH 1/3] post summary change --- public/templates/account.tpl | 4 ++-- public/templates/accountposts.tpl | 6 +++--- public/templates/favourites.tpl | 8 ++++---- public/templates/search.tpl | 10 +++++----- src/posts.js | 8 +++----- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/public/templates/account.tpl b/public/templates/account.tpl index 7b660a185d..24fc37573b 100644 --- a/public/templates/account.tpl +++ b/public/templates/account.tpl @@ -140,8 +140,8 @@ [[global:posted]] [[global:in]] - - {posts.categoryName} + + {posts.category.name} diff --git a/public/templates/accountposts.tpl b/public/templates/accountposts.tpl index 710b693ba6..a407030ea3 100644 --- a/public/templates/accountposts.tpl +++ b/public/templates/accountposts.tpl @@ -25,10 +25,10 @@
- [[global:posted]] + [[global:posted]] [[global:in]] - - {posts.categoryName} + + {posts.category.name} diff --git a/public/templates/favourites.tpl b/public/templates/favourites.tpl index 273b88cfc5..e793d0475b 100644 --- a/public/templates/favourites.tpl +++ b/public/templates/favourites.tpl @@ -25,10 +25,10 @@
- posted - in - - {posts.categoryName} + [[global:posted]] + [[global:in]] + + {posts.category.name} diff --git a/public/templates/search.tpl b/public/templates/search.tpl index 393a6d7e04..ceb1082404 100644 --- a/public/templates/search.tpl +++ b/public/templates/search.tpl @@ -61,7 +61,7 @@
- + {posts.content} @@ -71,10 +71,10 @@ - posted - in - - {posts.categoryName} + [[global:posted]] + [[global:in]] + + {posts.category.name} diff --git a/src/posts.js b/src/posts.js index ac4a3d5e5a..812f60f78e 100644 --- a/src/posts.js +++ b/src/posts.js @@ -281,11 +281,9 @@ var db = require('./database'), return callback(null); } categories.getCategoryFields(topicData.cid, ['name', 'icon', 'slug'], function(err, categoryData) { - postData.categoryName = categoryData.name; - postData.categoryIcon = categoryData.icon; - postData.categorySlug = categoryData.slug; - postData.title = validator.escape(topicData.title); - postData.topicSlug = topicData.slug; + postData.category = categoryData; + topicData.title = validator.escape(topicData.title); + postData.topic = topicData; next(null, postData); }); }); From 33a5a2177e361e76a55620355348138379076f37 Mon Sep 17 00:00:00 2001 From: MrWaffle Date: Wed, 5 Mar 2014 20:57:32 +0100 Subject: [PATCH 2/3] Send the callback to the retry --- public/src/forum/admin/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/forum/admin/settings.js b/public/src/forum/admin/settings.js index 6f164115f4..d33a3f720e 100644 --- a/public/src/forum/admin/settings.js +++ b/public/src/forum/admin/settings.js @@ -9,7 +9,7 @@ define(['uploader'], function(uploader) { // Come back in 125ms if the config isn't ready yet if (!app.config) { setTimeout(function() { - Settings.prepare(); + Settings.prepare(callback); }, 125); return; } From c9c25bd1743601cb6c3444ba0a2325e033ed498b Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Wed, 5 Mar 2014 15:38:54 -0500 Subject: [PATCH 3/3] added getRecentPost --- src/posts.js | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/posts.js b/src/posts.js index 812f60f78e..565f4b867f 100644 --- a/src/posts.js +++ b/src/posts.js @@ -197,6 +197,35 @@ var db = require('./database'), }); }; + Posts.getRecentPosts = function(uid, start, stop, term, callback) { + var terms = { + day: 86400000, + week: 604800000, + month: 2592000000 + }; + + var since = terms.day; + if (terms[term]) { + since = terms[term]; + } + + var count = parseInt(stop, 10) === -1 ? stop : stop - start + 1; + + db.getSortedSetRevRangeByScore(['posts:pid', '+inf', Date.now() - since, 'LIMIT', start, count], function(err, pids) { + if(err) { + return callback(err); + } + + async.filter(pids, function(pid, next) { + postTools.privileges(pid, uid, function(err, privileges) { + next(!err && privileges.read); + }); + }, function(pids) { + Posts.getPostSummaryByPids(pids, true, callback); + }); + }); + }; + Posts.addUserInfoToPost = function(post, callback) { user.getUserFields(post.uid, ['username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) { if (err) { @@ -262,10 +291,10 @@ var db = require('./database'), if (parseInt(postData.deleted, 10) === 1) { return callback(null); - } else { - postData.relativeTime = utils.toISOString(postData.timestamp); - next(null, postData); } + + postData.relativeTime = utils.toISOString(postData.timestamp); + next(null, postData); }); }, function(postData, next) {