From 390937a20b086520d0ca5466bf752ef98d112176 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Mon, 25 Nov 2013 16:29:28 -0500 Subject: [PATCH 1/5] added err to getAllTopics --- src/routes/admin.js | 2 +- src/sitemap.js | 2 +- src/topics.js | 6 +++++- src/websockets.js | 12 ++++++------ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/routes/admin.js b/src/routes/admin.js index 0c562ce7c8..9c80f45231 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -244,7 +244,7 @@ var user = require('./../user.js'), }); app.get('/topics', function (req, res) { - topics.getAllTopics(10, null, function (topics) { + topics.getAllTopics(10, null, function (err, topics) { res.json({ topics: topics, notopics: topics.length === 0 diff --git a/src/sitemap.js b/src/sitemap.js index 26be952b21..af15e3961e 100644 --- a/src/sitemap.js +++ b/src/sitemap.js @@ -43,7 +43,7 @@ var path = require('path'), }, function(next) { var topicUrls = []; - topics.getAllTopics(null, null, function(topics) { + topics.getAllTopics(null, null, function(err, topics) { topics.forEach(function(topic) { if (topic.deleted !== '1') { topicUrls.push({ diff --git a/src/topics.js b/src/topics.js index 89eb940c6d..237a315ea2 100644 --- a/src/topics.js +++ b/src/topics.js @@ -588,6 +588,10 @@ var RDB = require('./redis.js'), Topics.getAllTopics = function(limit, after, callback) { RDB.smembers('topics:tid', function(err, tids) { + if(err) { + return callback(err, null); + } + var topics = [], numTids, x; @@ -623,7 +627,7 @@ var RDB = require('./redis.js'), next(); }); }, function(err) { - callback(topics); + callback(err, topics); }); }); } diff --git a/src/websockets.js b/src/websockets.js index 2eeb1474e9..cdc38a9c49 100644 --- a/src/websockets.js +++ b/src/websockets.js @@ -13,7 +13,7 @@ var cookie = require('cookie'), client: RDB, ttl: 60 * 60 * 24 * 14 }), - + user = require('./user'), Groups = require('./groups'), posts = require('./posts'), @@ -31,7 +31,7 @@ var cookie = require('cookie'), 'categories': require('./admin/categories'), 'user': require('./admin/user') }, - plugins = require('./plugins'); + plugins = require('./plugins'); var users = {}, @@ -578,7 +578,7 @@ module.exports.init = function(io) { } posts.getTopicPostStats(); - + io.sockets.in('topic_' + data.tid).emit('event:post_deleted', { pid: data.pid }); @@ -591,9 +591,9 @@ module.exports.init = function(io) { if(err) { return callback(err); } - + posts.getTopicPostStats(); - + io.sockets.in('topic_' + data.tid).emit('event:post_restored', { pid: data.pid }); @@ -861,7 +861,7 @@ module.exports.init = function(io) { }); socket.on('api:admin.topics.getMore', function(data, callback) { - topics.getAllTopics(data.limit, data.after, function(topics) { + topics.getAllTopics(data.limit, data.after, function(err, topics) { callback(JSON.stringify(topics)); }); }); From 8d12ecb7584d5d0ae984fdcd520b0ef9efb17574 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 25 Nov 2013 16:37:23 -0500 Subject: [PATCH 2/5] moved pagination into header --- public/src/forum/topic.js | 4 ++-- public/templates/header.tpl | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 8bab291ebb..3ef3cc6d1f 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -36,7 +36,7 @@ define(function() { app.enterRoom('topic_' + tid); - if($('#post-container .sub-posts').length > 1) { + if($('#post-container .posts').length > 1) { $('.topic-main-buttons').removeClass('hide').parent().removeClass('hide'); } @@ -799,7 +799,7 @@ define(function() { var count = 0, smallestNonNegative = 0; - jQuery('.sub-posts').each(function() { + jQuery('.posts > .post-row').each(function() { count++; this.postnumber = count; diff --git a/public/templates/header.tpl b/public/templates/header.tpl index 87b87a93bf..a2a8a47e6f 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -72,7 +72,6 @@ - -
- - - -
+ From 070c95d8de50b6334c5ed1738fa41de0e23546d5 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 25 Nov 2013 16:38:45 -0500 Subject: [PATCH 3/5] fixed regression from main_posts deprecation - bottom post bar restored --- public/src/forum/topic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 3ef3cc6d1f..0a3b188f04 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -36,7 +36,7 @@ define(function() { app.enterRoom('topic_' + tid); - if($('#post-container .posts').length > 1) { + if($('#post-container .posts .post-row').length > 1) { $('.topic-main-buttons').removeClass('hide').parent().removeClass('hide'); } From 4be5ac2c23d147e1819ba40672b255d42c061993 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 25 Nov 2013 16:47:06 -0500 Subject: [PATCH 4/5] removed mobile overlay for topics - will reimplement as a plugin --- public/src/forum/topic.js | 10 +--------- public/templates/topic.tpl | 11 ----------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 0a3b188f04..32eee15a67 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -764,7 +764,7 @@ define(function() { - var postAuthorImage, mobileAuthorOverlay, pagination; + var pagination; var postcount = templates.get('postcount'); function updateHeader() { @@ -776,10 +776,6 @@ define(function() { app.scrollToBottom(); }); } - - jQuery('.mobile-author-overlay').css('bottom', '0px'); - postAuthorImage = postAuthorImage || document.getElementById('mobile-author-image'); - mobileAuthorOverlay = mobileAuthorOverlay || document.getElementById('mobile-author-overlay'); pagination = pagination || document.getElementById('pagination'); pagination.parentNode.style.display = 'block'; @@ -790,8 +786,6 @@ define(function() { if (scrollTop < 50 && postcount > 1) { localStorage.removeItem("topic:" + tid + ":bookmark"); - postAuthorImage.src = (jQuery('.posts .avatar img').attr('src')); - mobileAuthorOverlay.innerHTML = 'Posted by ' + jQuery('.posts').attr('data-username') + ', ' + jQuery('.posts').find('.relativeTimeAgo').html(); pagination.innerHTML = '0 out of ' + postcount; return; } @@ -819,8 +813,6 @@ define(function() { } pagination.innerHTML = this.postnumber + ' out of ' + postcount; - postAuthorImage.src = (jQuery(this).find('.profile-image-block img').attr('src')); - mobileAuthorOverlay.innerHTML = 'Posted by ' + jQuery(this).attr('data-username') + ', ' + jQuery(this).find('.relativeTimeAgo').html(); } }); diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 8e7c2735d5..ddcf205c7e 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -153,17 +153,6 @@
-
-
-
- -
-
-

-
-
-
-