mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 12:31:33 +01:00
Merge branch 'v0.8.x'
This commit is contained in:
2
app.js
2
app.js
@@ -95,7 +95,7 @@ function loadConfig() {
|
||||
// Ensure themes_path is a full filepath
|
||||
nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path')));
|
||||
nconf.set('core_templates_path', path.join(__dirname, 'src/views'));
|
||||
nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-vanilla/templates'));
|
||||
nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-persona/templates'));
|
||||
|
||||
if (!process.send) {
|
||||
// If run using `node app`, log GNU copyright info along with server info
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "nodebb",
|
||||
"license": "GPL-3.0",
|
||||
"description": "NodeBB Forum",
|
||||
"version": "0.7.3",
|
||||
"version": "0.8.0",
|
||||
"homepage": "http://www.nodebb.org",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -49,8 +49,8 @@
|
||||
"nodebb-plugin-spam-be-gone": "0.4.1",
|
||||
"nodebb-rewards-essentials": "0.0.3",
|
||||
"nodebb-theme-lavender": "1.0.52",
|
||||
"nodebb-theme-persona": "2.0.28",
|
||||
"nodebb-theme-vanilla": "3.0.17",
|
||||
"nodebb-theme-persona": "2.1.6",
|
||||
"nodebb-theme-vanilla": "3.1.3",
|
||||
"nodebb-widget-essentials": "1.0.5",
|
||||
"npm": "^2.1.4",
|
||||
"passport": "^0.3.0",
|
||||
|
||||
@@ -487,13 +487,16 @@ app.cacheBuster = null;
|
||||
};
|
||||
|
||||
function handleStatusChange() {
|
||||
$('#user-control-list .user-status').off('click').on('click', function(e) {
|
||||
$('[component="header/usercontrol"] [data-status]').off('click').on('click', function(e) {
|
||||
var status = $(this).attr('data-status');
|
||||
socket.emit('user.setStatus', status, function(err, data) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
$('#logged-in-menu #user_label #user-profile-link>i').attr('class', 'fa fa-circle status ' + status);
|
||||
$('[component="user/status"]')
|
||||
.removeClass('away online dnd offline')
|
||||
.addClass(status);
|
||||
|
||||
app.user.status = status;
|
||||
});
|
||||
e.preventDefault();
|
||||
@@ -553,7 +556,9 @@ app.cacheBuster = null;
|
||||
|
||||
handleNewTopic();
|
||||
|
||||
$('#logout-link').on('click', app.logout);
|
||||
require(['components'], function(components) {
|
||||
components.get('user/logout').on('click', app.logout);
|
||||
});
|
||||
|
||||
Visibility.change(function(e, state){
|
||||
if (state === 'visible') {
|
||||
|
||||
@@ -87,18 +87,20 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
|
||||
}
|
||||
|
||||
function updateHeader(picture, username, userslug) {
|
||||
if (parseInt(ajaxify.data.theirid, 10) !== parseInt(ajaxify.data.yourid, 10)) {
|
||||
return;
|
||||
}
|
||||
require(['components'], function(components) {
|
||||
if (parseInt(ajaxify.data.theirid, 10) !== parseInt(ajaxify.data.yourid, 10)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (picture) {
|
||||
$('#user-header-picture').attr('src', picture);
|
||||
}
|
||||
if (picture) {
|
||||
components.get('header/userpicture').attr('src', picture);
|
||||
}
|
||||
|
||||
if (username && userslug) {
|
||||
$('#user-profile-link').attr('href', config.relative_path + '/user/' + userslug);
|
||||
$('#user-header-name').text(username);
|
||||
}
|
||||
if (username && userslug) {
|
||||
components.get('header/profilelink').attr('href', config.relative_path + '/user/' + userslug);
|
||||
components.get('header/username').text(username);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function handleImageChange() {
|
||||
|
||||
@@ -7,9 +7,8 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
|
||||
var newMessage = false;
|
||||
|
||||
module.prepareDOM = function() {
|
||||
var chatsToggleEl = $('#chat_dropdown'),
|
||||
chatsListEl = $('#chat-list'),
|
||||
dropdownEl;
|
||||
var chatsToggleEl = components.get('chat/dropdown'),
|
||||
chatsListEl = components.get('chat/list');
|
||||
|
||||
// Sync open chats between all user socket sessions
|
||||
module.sync();
|
||||
@@ -19,46 +18,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
|
||||
return;
|
||||
}
|
||||
|
||||
socket.emit('modules.chats.getRecentChats', {after: 0}, function(err, chats) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
chats = chats.users;
|
||||
var userObj;
|
||||
|
||||
chatsListEl.empty();
|
||||
|
||||
if (!chats.length) {
|
||||
translator.translate('[[modules:chat.no_active]]', function(str) {
|
||||
$('<li />')
|
||||
.addClass('no_active')
|
||||
.html('<a href="#">' + str + '</a>')
|
||||
.appendTo(chatsListEl);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
for(var x = 0; x<chats.length; ++x) {
|
||||
userObj = chats[x];
|
||||
dropdownEl = $('<li class="' + (userObj.unread ? 'unread' : '') + '"/>')
|
||||
.attr('data-uid', userObj.uid)
|
||||
.html('<a data-ajaxify="false">'+
|
||||
'<img src="' + userObj.picture + '" title="' + userObj.username +'" />' +
|
||||
'<i class="fa fa-circle status ' + userObj.status + '"></i> ' +
|
||||
userObj.username + '</a>')
|
||||
.appendTo(chatsListEl);
|
||||
|
||||
(function(userObj) {
|
||||
dropdownEl.click(function() {
|
||||
if (!ajaxify.currentPage.match(/^chats\//)) {
|
||||
app.openChat(userObj.username, userObj.uid);
|
||||
} else {
|
||||
ajaxify.go('chats/' + utils.slugify(userObj.username));
|
||||
}
|
||||
});
|
||||
})(userObj);
|
||||
}
|
||||
});
|
||||
module.loadChats(chatsListEl);
|
||||
});
|
||||
|
||||
socket.on('event:chats.receive', function(data) {
|
||||
@@ -139,7 +99,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
|
||||
username: chatObj.options.title,
|
||||
uid: chatObj.options.touid,
|
||||
new: chatObj.element.hasClass('new')
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
callback(null, chats);
|
||||
@@ -170,6 +130,51 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
|
||||
});
|
||||
};
|
||||
|
||||
module.loadChats = function(chatsListEl) {
|
||||
var dropdownEl;
|
||||
|
||||
socket.emit('modules.chats.getRecentChats', {after: 0}, function(err, chats) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
chats = chats.users;
|
||||
var userObj;
|
||||
|
||||
chatsListEl.empty();
|
||||
|
||||
if (!chats.length) {
|
||||
translator.translate('[[modules:chat.no_active]]', function(str) {
|
||||
$('<li />')
|
||||
.addClass('no_active')
|
||||
.html('<a href="#">' + str + '</a>')
|
||||
.appendTo(chatsListEl);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
for(var x = 0; x<chats.length; ++x) {
|
||||
userObj = chats[x];
|
||||
dropdownEl = $('<li class="' + (userObj.unread ? 'unread' : '') + '"/>')
|
||||
.attr('data-uid', userObj.uid)
|
||||
.html('<a data-ajaxify="false">'+
|
||||
'<img src="' + userObj.picture + '" title="' + userObj.username +'" />' +
|
||||
'<i class="fa fa-circle status ' + userObj.status + '"></i> ' +
|
||||
userObj.username + '</a>')
|
||||
.appendTo(chatsListEl);
|
||||
|
||||
(function(userObj) {
|
||||
dropdownEl.click(function() {
|
||||
if (!ajaxify.currentPage.match(/^chats\//)) {
|
||||
app.openChat(userObj.username, userObj.uid);
|
||||
} else {
|
||||
ajaxify.go('chats/' + utils.slugify(userObj.username));
|
||||
}
|
||||
});
|
||||
})(userObj);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.bringModalToTop = function(chatModal) {
|
||||
var topZ = 0;
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
/* globals define, socket, utils, config, app, ajaxify, templates, Tinycon*/
|
||||
|
||||
define('notifications', ['sounds', 'translator'], function(sound, translator) {
|
||||
define('notifications', ['sounds', 'translator', 'components'], function(sound, translator, components) {
|
||||
var Notifications = {};
|
||||
|
||||
Notifications.prepareDOM = function() {
|
||||
var notifContainer = $('.notifications'),
|
||||
notifTrigger = notifContainer.children('a'),
|
||||
notifList = $('#notif-list'),
|
||||
notifIcon = $('.notification-icon');
|
||||
notifIcon = components.get('notifications/icon');
|
||||
|
||||
notifTrigger.on('click', function(e) {
|
||||
e.preventDefault();
|
||||
@@ -17,25 +17,7 @@ define('notifications', ['sounds', 'translator'], function(sound, translator) {
|
||||
return;
|
||||
}
|
||||
|
||||
socket.emit('notifications.get', null, function(err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
var notifs = data.unread.concat(data.read).sort(function(a, b) {
|
||||
return parseInt(a.datetime, 10) > parseInt(b.datetime, 10) ? -1 : 1;
|
||||
});
|
||||
|
||||
translator.toggleTimeagoShorthand();
|
||||
for(var i=0; i<notifs.length; ++i) {
|
||||
notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10)));
|
||||
}
|
||||
translator.toggleTimeagoShorthand();
|
||||
|
||||
templates.parse('partials/notifications_list', {notifications: notifs}, function(html) {
|
||||
notifList.translateHtml(html);
|
||||
});
|
||||
});
|
||||
Notifications.loadNotifications(notifList);
|
||||
});
|
||||
|
||||
notifList.on('click', '[data-nid]', function() {
|
||||
@@ -114,8 +96,30 @@ define('notifications', ['sounds', 'translator'], function(sound, translator) {
|
||||
});
|
||||
};
|
||||
|
||||
Notifications.loadNotifications = function(notifList) {
|
||||
socket.emit('notifications.get', null, function(err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
var notifs = data.unread.concat(data.read).sort(function(a, b) {
|
||||
return parseInt(a.datetime, 10) > parseInt(b.datetime, 10) ? -1 : 1;
|
||||
});
|
||||
|
||||
translator.toggleTimeagoShorthand();
|
||||
for(var i=0; i<notifs.length; ++i) {
|
||||
notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10)));
|
||||
}
|
||||
translator.toggleTimeagoShorthand();
|
||||
|
||||
templates.parse('partials/notifications_list', {notifications: notifs}, function(html) {
|
||||
notifList.translateHtml(html);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Notifications.updateNotifCount = function(count) {
|
||||
var notifIcon = $('.notification-icon');
|
||||
var notifIcon = components.get('notifications/icon');
|
||||
|
||||
if (count > 0) {
|
||||
notifIcon.removeClass('fa-bell-o').addClass('fa-bell');
|
||||
|
||||
@@ -27,7 +27,7 @@ categoriesController.list = function(req, res, next) {
|
||||
content: validator.escape(meta.config.description || '')
|
||||
}, {
|
||||
property: 'og:title',
|
||||
content: 'Index | ' + validator.escape(meta.config.title || 'NodeBB')
|
||||
content: '[[pages:categories]]'
|
||||
}, {
|
||||
property: 'og:type',
|
||||
content: 'website'
|
||||
|
||||
@@ -194,7 +194,7 @@ usersController.getMap = function(req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
data.sort(function(a, b) {
|
||||
return b.total - a.total;
|
||||
return b.users.length - a.users.length;
|
||||
});
|
||||
|
||||
data.forEach(function(room) {
|
||||
|
||||
@@ -34,7 +34,7 @@ module.exports = function(Meta) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var themeId = (themeData['theme:id'] || 'nodebb-theme-vanilla'),
|
||||
var themeId = (themeData['theme:id'] || 'nodebb-theme-persona'),
|
||||
baseThemePath = path.join(nconf.get('themes_path'), (themeData['theme:type'] && themeData['theme:type'] === 'local' ? themeId : 'nodebb-theme-vanilla')),
|
||||
paths = [
|
||||
baseThemePath,
|
||||
|
||||
@@ -119,7 +119,7 @@ module.exports = function(Meta) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var themeId = data.currentThemeId || 'nodebb-theme-vanilla';
|
||||
var themeId = data.currentThemeId || 'nodebb-theme-persona';
|
||||
|
||||
var themeObj = data.themesData.filter(function(themeObj) {
|
||||
return themeObj.id === themeId;
|
||||
|
||||
@@ -300,6 +300,10 @@ middleware.renderHeader = function(req, res, data, callback) {
|
||||
templateValues.template = {name: res.locals.template};
|
||||
templateValues.template[res.locals.template] = true;
|
||||
|
||||
if (req.route.path === '/') {
|
||||
modifyTitle(templateValues);
|
||||
}
|
||||
|
||||
plugins.fireHook('filter:middleware.renderHeader', {templateValues: templateValues, req: req, res: res}, function(err, data) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -342,6 +346,10 @@ middleware.processRender = function(req, res, next) {
|
||||
}
|
||||
|
||||
if (res.locals.isAPI) {
|
||||
if (req.route.path === '/api/') {
|
||||
options.title = '[[pages:home]]';
|
||||
}
|
||||
|
||||
return res.json(options);
|
||||
}
|
||||
|
||||
@@ -519,6 +527,21 @@ function redirectToLogin(req, res) {
|
||||
return controllers.helpers.redirect(res, '/login');
|
||||
}
|
||||
|
||||
function modifyTitle(obj) {
|
||||
var title = '[[pages:home]] | ' + validator.escape(meta.config.title || 'NodeBB');
|
||||
obj.browserTitle = title;
|
||||
|
||||
if (obj.metaTags) {
|
||||
obj.metaTags.forEach(function(tag, i) {
|
||||
if (tag.property === 'og:title') {
|
||||
obj.metaTags[i].content = title;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
module.exports = function(webserver) {
|
||||
app = webserver;
|
||||
middleware.admin = require('./admin')(webserver);
|
||||
|
||||
@@ -53,26 +53,14 @@ module.exports = function(User) {
|
||||
renamedUsername: function(next) {
|
||||
renameUsername(userData, next);
|
||||
},
|
||||
customFields: function(next) {
|
||||
plugins.fireHook('filter:user.custom_fields', [], next);
|
||||
},
|
||||
userData: function(next) {
|
||||
plugins.fireHook('filter:user.create', userData, next);
|
||||
plugins.fireHook('filter:user.create', {user: userData, data: data}, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var customData = {};
|
||||
results.customFields.forEach(function(customField) {
|
||||
if (data[customField]) {
|
||||
customData[customField] = data[customField];
|
||||
}
|
||||
});
|
||||
|
||||
userData = utils.merge(results.userData, customData);
|
||||
|
||||
var userNameChanged = !!results.renamedUsername;
|
||||
|
||||
if (userNameChanged) {
|
||||
|
||||
Reference in New Issue
Block a user