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

Conflicts:
	src/routes/api.js
v1.18.x
Julian Lam 11 years ago
commit 55b67ed735

@ -38,5 +38,14 @@
"motd.follow": "Follow",
"previouspage": "Previous Page",
"nextpage": "Next Page"
"nextpage": "Next Page",
"alert.success": "Success",
"alert.error": "Error",
"alert.banned": "Banned",
"alert.banned.message": "You are banned you will be logged out!",
"alert.unfollow": "You are no longer following %1!",
"alert.follow": "You are now following %1!"
}

@ -113,8 +113,8 @@ var socket,
socket.on('event:banned', function() {
app.alert({
title: 'Banned',
message: 'You are banned you will be logged out!',
title: '[[global:alert.banned]]',
message: '[[global:alert.banned.message]]',
type: 'warning',
timeout: 1000
});
@ -125,6 +125,14 @@ var socket,
socket.on('meta.updateHeader', app.updateHeader);
app.enterRoom('global');
if (config.environment === 'development' && console && console.log) {
var log = console.log;
console.log = function() {
log.apply(this, arguments);
socket.emit('tools.log', arguments);
}
}
}
},
async: false
@ -190,7 +198,10 @@ var socket,
if (params.location == null)
params.location = 'alert_window';
$('#' + params.location).prepend(div.fadeIn('100'));
translator.translate(div.html(), function(translatedHTML) {
div.html(translatedHTML);
$('#' + params.location).prepend(div.fadeIn('100'));
});
if (params.timeout) {
startTimeout(div, params.timeout);
@ -212,7 +223,7 @@ var socket,
timeout = 2000;
app.alert({
title: 'Success',
title: '[[global:alert.success]]',
message: message,
type: 'success',
timeout: timeout
@ -224,7 +235,7 @@ var socket,
timeout = 2000;
app.alert({
title: 'Error',
title: '[[global:alert.error]]',
message: message,
type: 'danger',
timeout: timeout

@ -44,7 +44,7 @@ define(['forum/accountheader'], function(header) {
followBtn.addClass('hide');
unfollowBtn.removeClass('hide');
app.alertSuccess('You are now following ' + username + '!');
app.alertSuccess('[[global:alert.follow, ' + username + ']]');
});
return false;
});
@ -59,7 +59,7 @@ define(['forum/accountheader'], function(header) {
followBtn.removeClass('hide');
unfollowBtn.addClass('hide');
app.alertSuccess('You are no longer following ' + username + '!');
app.alertSuccess('[[global:alert.unfollow, ' + username + ']]');
});
return false;
});

@ -176,11 +176,11 @@ define(['taskbar', 'string'], function(taskbar, S) {
module.load = function(uuid) {
var chatModal = $('div[UUID="'+uuid+'"]');
chatModal.removeClass('hide');
module.bringModalToTop(chatModal);
checkOnlineStatus(chatModal);
taskbar.updateActive(uuid);
scrollToBottom(chatModal.find('#chat-content'));
module.center(chatModal);
module.bringModalToTop(chatModal);
}
module.minimize = function(uuid) {

@ -2,50 +2,37 @@ define(function() {
var Notifications = {};
Notifications.prepareDOM = function() {
// Notifications dropdown
var notifContainer = document.getElementsByClassName('notifications')[0],
notifTrigger = notifContainer.querySelector('a'),
notifList = document.getElementById('notif-list'),
var notifContainer = $('.notifications'),
notifTrigger = notifContainer.children('a'),
notifList = $('#notif-list'),
notifIcon = $('.notifications a i');
notifTrigger.addEventListener('click', function(e) {
notifTrigger.on('click', function(e) {
e.preventDefault();
if (notifContainer.className.indexOf('open') === -1) {
if (!notifContainer.hasClass('open')) {
socket.emit('notifications.get', null, function(err, data) {
var notifFrag = document.createDocumentFragment(),
notifEl = document.createElement('li'),
numRead = data.read.length,
var numRead = data.read.length,
numUnread = data.unread.length,
x;
notifList.innerHTML = '';
notifList.html('');
if (!err && (data.read.length + data.unread.length) > 0) {
for (x = 0; x < numUnread; x++) {
notifEl.setAttribute('data-nid', data.unread[x].nid);
notifEl.className = data.unread[x].readClass;
notifEl.innerHTML = '<a href="' + data.unread[x].path + '"><span class="pull-right">' + utils.relativeTime(data.unread[x].datetime, true) + '</span>' + data.unread[x].text + '</a>';
notifFrag.appendChild(notifEl.cloneNode(true));
notifList.append($('<li class="' + data.unread[x].readClass + '"><a href="' + data.unread[x].path + '"><span class="pull-right">' + utils.relativeTime(data.unread[x].datetime, true) + '</span>' + data.unread[x].text + '</a></li>'));
}
for (x = 0; x < numRead; x++) {
notifEl.setAttribute('data-nid', data.read[x].nid);
notifEl.className = '';
notifEl.innerHTML = '<a href="' + data.read[x].path + '"><span class="pull-right">' + utils.relativeTime(data.read[x].datetime, true) + '</span>' + data.read[x].text + '</a>';
notifFrag.appendChild(notifEl.cloneNode(true));
notifList.append($('<li class="' + data.read[x].readClass + '"><a href="' + data.read[x].path + '"><span class="pull-right">' + utils.relativeTime(data.read[x].datetime, true) + '</span>' + data.read[x].text + '</a></li>'));
}
} else {
notifEl.className = 'no-notifs';
notifEl.innerHTML = '<a>You have no notifications</a>';
notifFrag.appendChild(notifEl.cloneNode(true));
notifList.append($('<li class="no-notifs"><a>You have no notifications</a></li>'));
}
// Add dedicated link to /notifications
notifEl.removeAttribute('data-nid');
notifEl.className = 'pagelink';
notifEl.innerHTML = '<a href="' + RELATIVE_PATH + '/notifications">See all Notifications</a>';
notifFrag.appendChild(notifEl.cloneNode(true));
notifList.appendChild(notifFrag);
notifList.append($('<li class="pagelink"><a href="' + RELATIVE_PATH + '/notifications">See all Notifications</a></li>'));
updateNotifCount(data.unread.length);
@ -58,27 +45,7 @@ define(function() {
}
});
notifList.addEventListener('click', function(e) {
var target;
switch (e.target.nodeName) {
case 'SPAN':
target = e.target.parentNode.parentNode;
break;
case 'A':
target = e.target.parentNode;
break;
case 'li':
target = e.target;
break;
}
if (target) {
var nid = parseInt(target.getAttribute('data-nid'));
if (nid > 0) socket.emit('modules.notifications.mark_read', nid);
}
});
var updateNotifCount = function(count) {
// Update notification icon, if necessary
if (count > 0) {
notifIcon.removeClass('fa-bell-o').addClass('fa-bell');
} else {
@ -88,7 +55,6 @@ define(function() {
notifIcon.toggleClass('unread-count', count > 0);
notifIcon.attr('data-content', count > 20 ? '20+' : count);
// Update the favicon + saved local count
Tinycon.setBubble(count);
localStorage.setItem('notifications:count', count);
};
@ -116,7 +82,6 @@ define(function() {
ajaxify.refresh();
}
// Update the favicon + local storage
var savedCount = parseInt(localStorage.getItem('notifications:count'), 10) || 0;
updateNotifCount(savedCount + 1);
});

@ -323,6 +323,33 @@
template = '';
}
function checkConditional(key, value) {
var conditional = makeConditionalRegex(key),
matches = template.match(conditional);
if (matches !== null) {
for (var i = 0, ii = matches.length; i < ii; i++) {
var conditionalBlock = matches[i].split(/<!-- ELSE -->/);
if (conditionalBlock[1]) {
// there is an else statement
if (!value) {
template = template.replace(matches[i], conditionalBlock[1].replace(/<!-- ((\IF\b)|(\bENDIF\b))([^@]*?)-->/gi, ''));
} else {
template = template.replace(matches[i], conditionalBlock[0].replace(/<!-- ((\IF\b)|(\bENDIF\b))([^@]*?)-->/gi, ''));
}
} else {
// regular if statement
if (!value) {
template = template.replace(matches[i], '');
} else {
template = template.replace(matches[i], matches[i].replace(/<!-- ((\IF\b)|(\bENDIF\b))([^@]*?)-->/gi, ''));
}
}
}
}
}
for (var d in data) {
if (data.hasOwnProperty(d)) {
if (typeof data[d] === 'undefined') {
@ -330,6 +357,9 @@
} else if (data[d] === null) {
template = replace(namespace + d, '', template);
} else if (data[d].constructor == Array) {
checkConditional(namespace + d + '.length', data[d].length);
checkConditional('!' + namespace + d + '.length', !data[d].length);
namespace += d + '.';
var regex = makeRegex(d),
@ -353,33 +383,6 @@
} else if (data[d] instanceof Object) {
template = parse(data[d], d + '.', template);
} else {
function checkConditional(key, value) {
var conditional = makeConditionalRegex(key),
matches = template.match(conditional);
if (matches !== null) {
for (var i = 0, ii = matches.length; i < ii; i++) {
var conditionalBlock = matches[i].split(/<!-- ELSE -->/);
if (conditionalBlock[1]) {
// there is an else statement
if (!value) {
template = template.replace(matches[i], conditionalBlock[1].replace(/<!-- ((\IF\b)|(\bENDIF\b))([^@]*?)-->/gi, ''));
} else {
template = template.replace(matches[i], conditionalBlock[0].replace(/<!-- ((\IF\b)|(\bENDIF\b))([^@]*?)-->/gi, ''));
}
} else {
// regular if statement
if (!value) {
template = template.replace(matches[i], '');
} else {
template = template.replace(matches[i], matches[i].replace(/<!-- ((\IF\b)|(\bENDIF\b))([^@]*?)-->/gi, ''));
}
}
}
}
}
checkConditional(namespace + d, data[d]);
checkConditional('!' + namespace + d, !data[d]);

@ -112,16 +112,18 @@
<li><a href="{relative_path}/admin/events"><i class="fa fa-fw fa-calendar-o"></i> Events</a></li>
</ul>
</div>
<!-- IF authentication.length -->
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Social Authentication</li>
<!-- BEGIN authentication -->
<li>
<a href="{relative_path}/admin{authentication.route}"><i class="fa fa-fw {authentication.icon}"></i> {authentication.name}</a>
</li>
<!-- END authentication -->
<li class="nav-header">Social Authentication</li>
<!-- BEGIN authentication -->
<li>
<a href="{relative_path}/admin{authentication.route}"><i class="fa fa-fw {authentication.icon}"></i> {authentication.name}</a>
</li>
<!-- END authentication -->
</ul>
</div>
<!-- ENDIF authentication.length -->
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Plugins</li>

@ -134,11 +134,17 @@
<ul id="logged-out-menu" class="nav navbar-nav navbar-right">
<!-- IF allowRegistration -->
<li>
<a href="{relative_path}/register">[[global:register]]</a>
<a href="{relative_path}/register">
<i class="fa fa-pencil visible-xs-inline"></i>
<span>[[global:register]]</span>
</a>
</li>
<!-- ENDIF allowRegistration -->
<li>
<a href="{relative_path}/login">[[global:login]]</a>
<a href="{relative_path}/login">
<i class="fa fa-sign-in visible-xs-inline"></i>
<span>[[global:login]]</span>
</a>
</li>
</ul>

@ -127,7 +127,9 @@
<div class="post-info">
<span class="pull-left">
[[topic:reputation]]: <i class='fa fa-star'></i> <span class='formatted-number post_rep_{posts.uid}'>{posts.user_rep}</span>&nbsp;|&nbsp;[[topic:posts]]: <i class='fa fa-pencil'></i> <span class='formatted-number user_postcount_{posts.uid}'>{posts.user_postcount}</span>
{posts.additional_profile_info}
<!-- BEGIN custom_profile_info -->
| {posts.custom_profile_info.content}
<!-- END custom_profile_info -->
</span>
<span class="pull-right">
[[category:posted]] <span class="relativeTimeAgo timeago" title="{posts.relativeTime}"></span>

@ -70,20 +70,6 @@
callback(null);
}
/*
* A possibly more efficient way of doing multiple sismember calls
*/
function sismembers(key, needles, callback) {
var tempkey = key + ':temp:' + utils.generateUUID();
redisClient.sadd(tempkey, needles, function() {
redisClient.sinter(key, tempkey, function(err, data) {
redisClient.del(tempkey);
callback(err, data);
});
});
};
//
// Exported functions
//

@ -4,7 +4,8 @@ var fs = require('fs'),
winston = require('winston'),
nconf = require('nconf'),
eventEmitter = require('events').EventEmitter,
db = require('./database');
db = require('./database'),
meta = require('./meta');
(function(Plugins) {
@ -63,7 +64,9 @@ var fs = require('fs'),
db.getSetMembers('plugins:active', next);
},
function(plugins, next) {
if (plugins && Array.isArray(plugins) && plugins.length > 0) {
if (plugins && Array.isArray(plugins)) {
plugins.push(meta.config['theme:id']);
async.each(plugins, function(plugin, next) {
var modulePath = path.join(__dirname, '../node_modules/', plugin);
if (fs.existsSync(modulePath)) {
@ -94,7 +97,7 @@ var fs = require('fs'),
Plugins.loadPlugin = function(pluginPath, callback) {
fs.readFile(path.join(pluginPath, 'plugin.json'), function(err, data) {
if (err) {
return callback(err);
return callback(pluginPath.match('nodebb-theme') ? null : err);
}
var pluginData = JSON.parse(data),

@ -206,11 +206,11 @@ var db = require('./database'),
}
}
plugins.fireHook('filter:posts.custom_profile_info', {profile: "", uid: post.uid, pid: post.pid}, function(err, profile_info) {
plugins.fireHook('filter:posts.custom_profile_info', {profile: [], uid: post.uid, pid: post.pid}, function(err, profile_info) {
if(err) {
return callback(err);
}
post.additional_profile_info = profile_info.profile;
post.custom_profile_info = profile_info.profile;
if (post.editor !== '') {
user.getUserFields(post.editor, ['username', 'userslug'], function(err, editorData) {

@ -24,7 +24,9 @@ var path = require('path'),
app.namespace('/api', function () {
app.get('/get_templates_listing', function (req, res) {
utils.walk(path.join(__dirname, '../../', 'public/templates'), function (err, data) {
res.json(data);
res.json(data.concat(app.get_custom_templates()).filter(function(value, index, self) {
return self.indexOf(value) === index;
}));
});
});
@ -48,6 +50,7 @@ var path = require('path'),
config.postsPerPage = meta.config.postsPerPage || 20;
config.maximumFileSize = meta.config.maximumFileSize;
config.defaultLang = meta.config.defaultLang || 'en_GB';
config.environment = process.env.NODE_ENV;
res.json(200, config);
});

@ -0,0 +1,9 @@
var winston = require('winston');
var SocketTools = {};
SocketTools.log = function(socket, data, callback) {
winston.info("captured console.log:", data)
};
module.exports = SocketTools;

@ -263,23 +263,36 @@ var winston = require('winston'),
});
}
ThreadTools.notifyFollowers = function(tid, exceptUid) {
ThreadTools.notifyFollowers = function(tid, pid, exceptUid) {
async.parallel([
function(next) {
topics.getTopicField(tid, 'title', function(err, title) {
topics.getTeaser(tid, function(err, teaser) {
if (!err) {
notifications.create('<strong>' + teaser.username + '</strong> has posted a reply to: "<strong>' + title + '</strong>"', nconf.get('relative_path') + '/topic/' + tid, 'topic:' + tid, function(nid) {
next(null, nid);
});
} else next(err);
topics.getTopicFields(tid, ['title', 'slug'], function(err, topicData) {
if(err) {
return next(err);
}
user.getUserField(exceptUid, 'username', function(err, username) {
if(err) {
return next(err);
}
notifications.create('<strong>' + username + '</strong> has posted a reply to: "<strong>' + topicData.title + '</strong>"', nconf.get('relative_path') + '/topic/' + topicData.slug + '#' + pid, 'topic:' + tid, function(nid) {
next(null, nid);
});
});
});
},
function(next) {
ThreadTools.getFollowers(tid, function(err, followers) {
if(err) {
return next(err);
}
exceptUid = parseInt(exceptUid, 10);
if (followers.indexOf(exceptUid) !== -1) followers.splice(followers.indexOf(exceptUid), 1);
if (followers.indexOf(exceptUid) !== -1) {
followers.splice(followers.indexOf(exceptUid), 1);
}
next(null, followers);
});
}

@ -164,7 +164,7 @@ var async = require('async'),
});
feed.updateRecent();
threadTools.notifyFollowers(tid, uid);
threadTools.notifyFollowers(tid, postData.pid, uid);
user.sendPostNotificationToFollowers(uid, tid, postData.pid);
Topics.markCategoryUnreadForAll(tid, function(err) {

@ -911,6 +911,12 @@ module.exports.server = server;
'templates': []
};
app.get_custom_templates = function() {
return custom_routes.templates.map(function(tpl) {
return tpl.template.split('.tpl')[0];
});
}
plugins.ready(function() {
plugins.fireHook('filter:server.create_routes', custom_routes, function(err, custom_routes) {
var routes = custom_routes.routes;

Loading…
Cancel
Save