From 090d35f306bd8d471ab347d8f524afdb1bc244c3 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sat, 7 Dec 2013 15:48:30 -0500 Subject: [PATCH 01/10] clean up conditional comments in the DOM; conditionals now treat undefined variables as false; closes #617 --- public/src/templates.js | 9 +++++++-- src/database/mongo.js | 3 +-- src/database/redis.js | 2 -- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/public/src/templates.js b/public/src/templates.js index 6772f998b7..04972140a5 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -320,14 +320,16 @@ if (conditionalBlock[1]) { // there is an else statement if (!value) { - template = template.replace(matches[i], conditionalBlock[1]); + template = template.replace(matches[i], conditionalBlock[1].replace(//gi, '')); } else { - template = template.replace(matches[i], conditionalBlock[0]); + template = template.replace(matches[i], conditionalBlock[0].replace(//gi, '')); } } else { // regular if statement if (!value) { template = template.replace(matches[i], ''); + } else { + template = template.replace(matches[i], matches[i].replace(//gi, '')); } } } @@ -351,6 +353,9 @@ var regex = new RegExp("{" + namespace + "[\\s\\S]*?}", 'g'); template = template.replace(regex, ''); } + //console.log (template); + // clean up all undefined conditionals + template = template.replace(//gi, ''); return template; diff --git a/src/database/mongo.js b/src/database/mongo.js index c803e3a541..d6af3bc0b2 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -188,8 +188,7 @@ stats.raw = JSON.stringify(stats, null, 4); stats.mongo = true; - //remove this when andrew adds in undefined checking to templates - stats.redis = false; + callback(err, stats); }); diff --git a/src/database/redis.js b/src/database/redis.js index b3a27ef895..d24573384b 100644 --- a/src/database/redis.js +++ b/src/database/redis.js @@ -168,8 +168,6 @@ } redisData.raw = JSON.stringify(redisData, null, 4); redisData.redis = true; - //remove this when andrew adds in undefined checking to templates - redisData.mongo = false; callback(null, redisData); }); From 36745608bf5e3700b11faadb391e7cddc55cfd32 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sat, 7 Dec 2013 15:49:48 -0500 Subject: [PATCH 02/10] removed console.log --- public/src/templates.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/templates.js b/public/src/templates.js index 04972140a5..51dfd0dc65 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -353,7 +353,7 @@ var regex = new RegExp("{" + namespace + "[\\s\\S]*?}", 'g'); template = template.replace(regex, ''); } - //console.log (template); + // clean up all undefined conditionals template = template.replace(//gi, ''); From 34fc326a378c80b60fcd3dadb910982525533962 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Sat, 7 Dec 2013 15:59:44 -0500 Subject: [PATCH 03/10] closes #618 --- public/src/forum/footer.js | 2 +- public/src/modules/chat.js | 4 ++-- src/websockets.js | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/public/src/forum/footer.js b/public/src/forum/footer.js index eb8d0f3e20..046a7e8186 100644 --- a/public/src/forum/footer.js +++ b/public/src/forum/footer.js @@ -208,7 +208,7 @@ }); }); - socket.on('chatMessage', function(data) { + socket.on('event:chats.receive', function(data) { require(['chat'], function(chat) { var modal = null; if (chat.modalExists(data.fromuid)) { diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js index 2aeb2f02bf..8c3b551330 100644 --- a/public/src/modules/chat.js +++ b/public/src/modules/chat.js @@ -114,7 +114,7 @@ define(['taskbar'], function(taskbar) { } function getChatMessages(chatModal, callback) { - socket.emit('getChatMessages', {touid:chatModal.touid}, function(messages) { + socket.emit('api:chats.get', {touid:chatModal.touid}, function(messages) { for(var i = 0; i Date: Sat, 7 Dec 2013 16:11:37 -0500 Subject: [PATCH 04/10] added translation to new post creation, closes #627 --- public/src/forum/category.js | 51 +++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/public/src/forum/category.js b/public/src/forum/category.js index 44a11eaea9..5c7d6c7e99 100644 --- a/public/src/forum/category.js +++ b/public/src/forum/category.js @@ -83,36 +83,39 @@ define(function () { Category.onNewTopic = function(data) { var html = templates.prepare(templates['category'].blocks['topics']).parse({ topics: [data] - }), - topic = $(html), - container = $('#topics-container'), - topics = $('#topics-container').children('.category-item'), - numTopics = topics.length; - - jQuery('#topics-container, .category-sidebar').removeClass('hidden'); - jQuery('#category-no-topics').remove(); - - if (numTopics > 0) { - for (var x = 0; x < numTopics; x++) { - if ($(topics[x]).find('.fa-thumb-tack').length) { - if(x === numTopics - 1) { - topic.insertAfter(topics[x]); + }); + + translator.translate(html, function(translatedHTML) { + var topic = $(translatedHTML), + container = $('#topics-container'), + topics = $('#topics-container').children('.category-item'), + numTopics = topics.length; + + jQuery('#topics-container, .category-sidebar').removeClass('hidden'); + jQuery('#category-no-topics').remove(); + + if (numTopics > 0) { + for (var x = 0; x < numTopics; x++) { + if ($(topics[x]).find('.fa-thumb-tack').length) { + if(x === numTopics - 1) { + topic.insertAfter(topics[x]); + } + continue; } - continue; + topic.insertBefore(topics[x]); + break; } - topic.insertBefore(topics[x]); - break; + } else { + container.append(topic); } - } else { - container.append(topic); - } - topic.hide().fadeIn('slow'); - socket.emit('api:categories.getRecentReplies', templates.get('category_id')); + topic.hide().fadeIn('slow'); + socket.emit('api:categories.getRecentReplies', templates.get('category_id')); - addActiveUser(data); + addActiveUser(data); - $('#topics-container span.timeago').timeago(); + $('#topics-container span.timeago').timeago(); + }); } function addActiveUser(data) { From e0e153eafbc1a6c5d2d0081709e96d2c03a1e376 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sat, 7 Dec 2013 16:14:44 -0500 Subject: [PATCH 05/10] added translation to category infinite loader method --- public/src/forum/category.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/public/src/forum/category.js b/public/src/forum/category.js index 5c7d6c7e99..6b25a85701 100644 --- a/public/src/forum/category.js +++ b/public/src/forum/category.js @@ -134,20 +134,22 @@ define(function () { } Category.onTopicsLoaded = function(topics) { - var html = templates.prepare(templates['category'].blocks['topics']).parse({ topics: topics - }), - container = $('#topics-container'); + }); + + translator.translate(html, function(translatedHTML) { + var container = $('#topics-container'); - jQuery('#topics-container, .category-sidebar').removeClass('hidden'); - jQuery('#category-no-topics').remove(); + jQuery('#topics-container, .category-sidebar').removeClass('hidden'); + jQuery('#category-no-topics').remove(); - html = $(html); - container.append(html); + html = $(translatedHTML); + container.append(html); - $('#topics-container span.timeago').timeago(); - app.makeNumbersHumanReadable(html.find('.human-readable-number')); + $('#topics-container span.timeago').timeago(); + app.makeNumbersHumanReadable(html.find('.human-readable-number')); + }); } Category.loadMoreTopics = function(cid) { From 4c90d22e43f440083fa84d1da8fa94448ab57bea Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Sat, 7 Dec 2013 16:15:07 -0500 Subject: [PATCH 06/10] closes #619 --- src/websockets.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/websockets.js b/src/websockets.js index 6afcf16356..341038b508 100644 --- a/src/websockets.js +++ b/src/websockets.js @@ -696,9 +696,15 @@ websockets.init = function(io) { var msg = utils.strip_tags(data.message); - user.getUserField(uid, 'username', function(err, username) { + user.getMultipleUserFields([uid, touid], ['username'], function(err, usersData) { + if(err) { + return; + } + var finalMessage = username + ' : ' + msg, - notifText = 'New message from ' + username + ''; + notifText = 'New message from ' + username + '', + username = usersData[0].username, + toUsername = usersData[1].username; if (!isUserOnline(touid)) { notifications.create(notifText, 'javascript:app.openChat('' + username + '', ' + uid + ');', 'notification_' + uid + '_' + touid, function(nid) { @@ -731,7 +737,7 @@ websockets.init = function(io) { for (var x = 0; x < numSockets; ++x) { userSockets[uid][x].emit('event:chats.receive', { fromuid: touid, - username: username, + username: toUsername, message: 'You : ' + msg, timestamp: Date.now() }); From 98cf6eec71b58669ee068941c92115f7b0282b4d Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sat, 7 Dec 2013 16:18:01 -0500 Subject: [PATCH 07/10] shift clicking now opens links in a new window, closes #630 --- public/src/ajaxify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index bba039ea66..640c4da443 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -154,7 +154,7 @@ var ajaxify = {}; return; } - if (!e.ctrlKey && e.which === 1) { + if ((!e.ctrlKey && !e.shiftKey) && e.which === 1) { if (this.host === window.location.host) { // Internal link var url = this.href.replace(rootUrl + '/', ''); From ceac8e2dc9fe0f31fe8419dff7e09058d6481dca Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sat, 7 Dec 2013 16:20:31 -0500 Subject: [PATCH 08/10] added translation to unread infinite loader --- public/src/forum/unread.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/public/src/forum/unread.js b/public/src/forum/unread.js index 6debeeba84..5151eb37cb 100644 --- a/public/src/forum/unread.js +++ b/public/src/forum/unread.js @@ -74,15 +74,18 @@ define(function() { var html = templates.prepare(templates['unread'].blocks['topics']).parse({ topics: topics - }), - container = $('#topics-container'); + }); + + translator.translate(html, function(translatedHTML) { + var container = $('#topics-container'); - $('#category-no-topics').remove(); + $('#category-no-topics').remove(); - html = $(html); - container.append(html); - $('span.timeago').timeago(); - app.makeNumbersHumanReadable(html.find('.human-readable-number')); + html = $(translatedHTML); + container.append(html); + $('span.timeago').timeago(); + app.makeNumbersHumanReadable(html.find('.human-readable-number')); + }); } function loadMoreTopics() { From 6c9e28232fbe61b922285cb201619758cf94136d Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sat, 7 Dec 2013 16:21:12 -0500 Subject: [PATCH 09/10] added translation method to recent's infinite loader --- public/src/forum/recent.js | 18 ++++++++++-------- public/src/forum/unread.js | 1 - 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/public/src/forum/recent.js b/public/src/forum/recent.js index 6b162db34f..c883c9c54b 100644 --- a/public/src/forum/recent.js +++ b/public/src/forum/recent.js @@ -81,18 +81,20 @@ define(function() { } Recent.onTopicsLoaded = function(topics) { - var html = templates.prepare(templates['recent'].blocks['topics']).parse({ topics: topics - }), - container = $('#topics-container'); + }); + + translator.translate(html, function(translatedHTML) { + var container = $('#topics-container'); - $('#category-no-topics').remove(); + $('#category-no-topics').remove(); - html = $(html); - container.append(html); - $('span.timeago').timeago(); - app.makeNumbersHumanReadable(html.find('.human-readable-number')); + html = $(html); + container.append(html); + $('span.timeago').timeago(); + app.makeNumbersHumanReadable(html.find('.human-readable-number')); + }); } Recent.loadMoreTopics = function() { diff --git a/public/src/forum/unread.js b/public/src/forum/unread.js index 5151eb37cb..e0dd1dd7d7 100644 --- a/public/src/forum/unread.js +++ b/public/src/forum/unread.js @@ -71,7 +71,6 @@ define(function() { }); function onTopicsLoaded(topics) { - var html = templates.prepare(templates['unread'].blocks['topics']).parse({ topics: topics }); From ca087e6fa7f4a54f647dd159080cb7bceab47ec5 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sat, 7 Dec 2013 16:27:22 -0500 Subject: [PATCH 10/10] fixes #576 --- public/src/ajaxify.js | 2 +- public/templates/footer.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 640c4da443..24f1e2e105 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -90,7 +90,7 @@ var ajaxify = {}; translator.load(tpl_url); - jQuery('#footer, #content').addClass('ajaxifying'); + jQuery('#footer, #content').removeClass('hide').addClass('ajaxifying'); templates.flush(); templates.load_template(function () { diff --git a/public/templates/footer.tpl b/public/templates/footer.tpl index a9f51f2242..4434336ed8 100644 --- a/public/templates/footer.tpl +++ b/public/templates/footer.tpl @@ -59,7 +59,7 @@
-