Merge branch 'master' of github.com:designcreateplay/NodeBB

v1.18.x
Julian Lam 12 years ago
commit 6de3dba239

@ -90,7 +90,7 @@ var ajaxify = {};
translator.load(tpl_url); translator.load(tpl_url);
jQuery('#footer, #content').addClass('ajaxifying'); jQuery('#footer, #content').removeClass('hide').addClass('ajaxifying');
templates.flush(); templates.flush();
templates.load_template(function () { templates.load_template(function () {
@ -154,7 +154,7 @@ var ajaxify = {};
return; return;
} }
if (!e.ctrlKey && e.which === 1) { if ((!e.ctrlKey && !e.shiftKey) && e.which === 1) {
if (this.host === window.location.host) { if (this.host === window.location.host) {
// Internal link // Internal link
var url = this.href.replace(rootUrl + '/', ''); var url = this.href.replace(rootUrl + '/', '');

@ -83,36 +83,39 @@ define(function () {
Category.onNewTopic = function(data) { Category.onNewTopic = function(data) {
var html = templates.prepare(templates['category'].blocks['topics']).parse({ var html = templates.prepare(templates['category'].blocks['topics']).parse({
topics: [data] topics: [data]
}), });
topic = $(html),
container = $('#topics-container'), translator.translate(html, function(translatedHTML) {
topics = $('#topics-container').children('.category-item'), var topic = $(translatedHTML),
numTopics = topics.length; container = $('#topics-container'),
topics = $('#topics-container').children('.category-item'),
jQuery('#topics-container, .category-sidebar').removeClass('hidden'); numTopics = topics.length;
jQuery('#category-no-topics').remove();
jQuery('#topics-container, .category-sidebar').removeClass('hidden');
if (numTopics > 0) { jQuery('#category-no-topics').remove();
for (var x = 0; x < numTopics; x++) {
if ($(topics[x]).find('.fa-thumb-tack').length) { if (numTopics > 0) {
if(x === numTopics - 1) { for (var x = 0; x < numTopics; x++) {
topic.insertAfter(topics[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]); } else {
break; container.append(topic);
} }
} else {
container.append(topic);
}
topic.hide().fadeIn('slow'); topic.hide().fadeIn('slow');
socket.emit('api:categories.getRecentReplies', templates.get('category_id')); 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) { function addActiveUser(data) {
@ -131,20 +134,22 @@ define(function () {
} }
Category.onTopicsLoaded = function(topics) { Category.onTopicsLoaded = function(topics) {
var html = templates.prepare(templates['category'].blocks['topics']).parse({ var html = templates.prepare(templates['category'].blocks['topics']).parse({
topics: topics topics: topics
}), });
container = $('#topics-container');
translator.translate(html, function(translatedHTML) {
var container = $('#topics-container');
jQuery('#topics-container, .category-sidebar').removeClass('hidden'); jQuery('#topics-container, .category-sidebar').removeClass('hidden');
jQuery('#category-no-topics').remove(); jQuery('#category-no-topics').remove();
html = $(html); html = $(translatedHTML);
container.append(html); container.append(html);
$('#topics-container span.timeago').timeago(); $('#topics-container span.timeago').timeago();
app.makeNumbersHumanReadable(html.find('.human-readable-number')); app.makeNumbersHumanReadable(html.find('.human-readable-number'));
});
} }
Category.loadMoreTopics = function(cid) { Category.loadMoreTopics = function(cid) {

@ -208,7 +208,7 @@
}); });
}); });
socket.on('chatMessage', function(data) { socket.on('event:chats.receive', function(data) {
require(['chat'], function(chat) { require(['chat'], function(chat) {
var modal = null; var modal = null;
if (chat.modalExists(data.fromuid)) { if (chat.modalExists(data.fromuid)) {

@ -81,18 +81,20 @@ define(function() {
} }
Recent.onTopicsLoaded = function(topics) { Recent.onTopicsLoaded = function(topics) {
var html = templates.prepare(templates['recent'].blocks['topics']).parse({ var html = templates.prepare(templates['recent'].blocks['topics']).parse({
topics: topics topics: topics
}), });
container = $('#topics-container');
translator.translate(html, function(translatedHTML) {
var container = $('#topics-container');
$('#category-no-topics').remove(); $('#category-no-topics').remove();
html = $(html); html = $(html);
container.append(html); container.append(html);
$('span.timeago').timeago(); $('span.timeago').timeago();
app.makeNumbersHumanReadable(html.find('.human-readable-number')); app.makeNumbersHumanReadable(html.find('.human-readable-number'));
});
} }
Recent.loadMoreTopics = function() { Recent.loadMoreTopics = function() {

@ -71,18 +71,20 @@ define(function() {
}); });
function onTopicsLoaded(topics) { function onTopicsLoaded(topics) {
var html = templates.prepare(templates['unread'].blocks['topics']).parse({ var html = templates.prepare(templates['unread'].blocks['topics']).parse({
topics: topics topics: topics
}), });
container = $('#topics-container');
$('#category-no-topics').remove(); translator.translate(html, function(translatedHTML) {
var container = $('#topics-container');
html = $(html); $('#category-no-topics').remove();
container.append(html);
$('span.timeago').timeago(); html = $(translatedHTML);
app.makeNumbersHumanReadable(html.find('.human-readable-number')); container.append(html);
$('span.timeago').timeago();
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
});
} }
function loadMoreTopics() { function loadMoreTopics() {

@ -114,7 +114,7 @@ define(['taskbar'], function(taskbar) {
} }
function getChatMessages(chatModal, callback) { 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<messages.length; ++i) { for(var i = 0; i<messages.length; ++i) {
module.appendChatMessage(chatModal, messages[i].content, messages[i].timestamp); module.appendChatMessage(chatModal, messages[i].content, messages[i].timestamp);
} }
@ -141,7 +141,7 @@ define(['taskbar'], function(taskbar) {
var msg = app.strip_tags(chatModal.find('#chat-message-input').val()); var msg = app.strip_tags(chatModal.find('#chat-message-input').val());
if(msg.length) { if(msg.length) {
msg = msg +'\n'; msg = msg +'\n';
socket.emit('sendChatMessage', { touid:chatModal.touid, message:msg}); socket.emit('api:chats.send', { touid:chatModal.touid, message:msg});
chatModal.find('#chat-message-input').val(''); chatModal.find('#chat-message-input').val('');
} }
} }

@ -320,14 +320,16 @@
if (conditionalBlock[1]) { if (conditionalBlock[1]) {
// there is an else statement // there is an else statement
if (!value) { if (!value) {
template = template.replace(matches[i], conditionalBlock[1]); template = template.replace(matches[i], conditionalBlock[1].replace(/<!-- ((\IF\b)|(\bENDIF\b))(.*?)-->/gi, ''));
} else { } else {
template = template.replace(matches[i], conditionalBlock[0]); template = template.replace(matches[i], conditionalBlock[0].replace(/<!-- ((\IF\b)|(\bENDIF\b))(.*?)-->/gi, ''));
} }
} else { } else {
// regular if statement // regular if statement
if (!value) { if (!value) {
template = template.replace(matches[i], ''); template = template.replace(matches[i], '');
} else {
template = template.replace(matches[i], matches[i].replace(/<!-- ((\IF\b)|(\bENDIF\b))(.*?)-->/gi, ''));
} }
} }
} }
@ -351,6 +353,9 @@
var regex = new RegExp("{" + namespace + "[\\s\\S]*?}", 'g'); var regex = new RegExp("{" + namespace + "[\\s\\S]*?}", 'g');
template = template.replace(regex, ''); template = template.replace(regex, '');
} }
// clean up all undefined conditionals
template = template.replace(/<!-- IF([\s\S]*?)ENDIF([\s\S]*?)-->/gi, '');
return template; return template;

@ -59,7 +59,7 @@
<div id="alert_window"></div> <div id="alert_window"></div>
<footer id="footer" class="container footer"> <footer id="footer" class="container footer hide">
{footerHTML} {footerHTML}
<div class="copyright"> <div class="copyright">
Copyright &copy; 2013 <a target="_blank" href="http://www.nodebb.com">NodeBB Forums</a> | <a target="_blank" href="//github.com/designcreateplay/NodeBB/graphs/contributors">Contributors</a> Copyright &copy; 2013 <a target="_blank" href="http://www.nodebb.com">NodeBB Forums</a> | <a target="_blank" href="//github.com/designcreateplay/NodeBB/graphs/contributors">Contributors</a>

@ -188,8 +188,7 @@
stats.raw = JSON.stringify(stats, null, 4); stats.raw = JSON.stringify(stats, null, 4);
stats.mongo = true; stats.mongo = true;
//remove this when andrew adds in undefined checking to templates
stats.redis = false;
callback(err, stats); callback(err, stats);
}); });

@ -168,8 +168,6 @@
} }
redisData.raw = JSON.stringify(redisData, null, 4); redisData.raw = JSON.stringify(redisData, null, 4);
redisData.redis = true; redisData.redis = true;
//remove this when andrew adds in undefined checking to templates
redisData.mongo = false;
callback(null, redisData); callback(null, redisData);
}); });

@ -677,7 +677,7 @@ websockets.init = function(io) {
}); });
}); });
socket.on('getChatMessages', function(data, callback) { socket.on('api:chats.get', function(data, callback) {
var touid = data.touid; var touid = data.touid;
Messaging.getMessages(uid, touid, function(err, messages) { Messaging.getMessages(uid, touid, function(err, messages) {
if (err) if (err)
@ -687,7 +687,7 @@ websockets.init = function(io) {
}); });
}); });
socket.on('sendChatMessage', function(data) { socket.on('api:chats.send', function(data) {
var touid = data.touid; var touid = data.touid;
if (touid === uid || uid === 0) { if (touid === uid || uid === 0) {
@ -696,9 +696,15 @@ websockets.init = function(io) {
var msg = utils.strip_tags(data.message); 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, var finalMessage = username + ' : ' + msg,
notifText = 'New message from <strong>' + username + '</strong>'; notifText = 'New message from <strong>' + username + '</strong>',
username = usersData[0].username,
toUsername = usersData[1].username;
if (!isUserOnline(touid)) { if (!isUserOnline(touid)) {
notifications.create(notifText, 'javascript:app.openChat(&apos;' + username + '&apos;, ' + uid + ');', 'notification_' + uid + '_' + touid, function(nid) { notifications.create(notifText, 'javascript:app.openChat(&apos;' + username + '&apos;, ' + uid + ');', 'notification_' + uid + '_' + touid, function(nid) {
@ -715,7 +721,7 @@ websockets.init = function(io) {
numSockets = userSockets[touid].length; numSockets = userSockets[touid].length;
for (var x = 0; x < numSockets; ++x) { for (var x = 0; x < numSockets; ++x) {
userSockets[touid][x].emit('chatMessage', { userSockets[touid][x].emit('event:chats.receive', {
fromuid: uid, fromuid: uid,
username: username, username: username,
message: finalMessage, message: finalMessage,
@ -729,9 +735,9 @@ websockets.init = function(io) {
numSockets = userSockets[uid].length; numSockets = userSockets[uid].length;
for (var x = 0; x < numSockets; ++x) { for (var x = 0; x < numSockets; ++x) {
userSockets[uid][x].emit('chatMessage', { userSockets[uid][x].emit('event:chats.receive', {
fromuid: touid, fromuid: touid,
username: username, username: toUsername,
message: 'You : ' + msg, message: 'You : ' + msg,
timestamp: Date.now() timestamp: Date.now()
}); });

Loading…
Cancel
Save