Merge branch 'v0.8.x'

v1.18.x
psychobunny 10 years ago
commit 822b45e193

@ -95,7 +95,7 @@ function loadConfig() {
// Ensure themes_path is a full filepath // Ensure themes_path is a full filepath
nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path'))); nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path')));
nconf.set('core_templates_path', path.join(__dirname, 'src/views')); 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 (!process.send) {
// If run using `node app`, log GNU copyright info along with server info // If run using `node app`, log GNU copyright info along with server info

@ -2,7 +2,7 @@
"name": "nodebb", "name": "nodebb",
"license": "GPL-3.0", "license": "GPL-3.0",
"description": "NodeBB Forum", "description": "NodeBB Forum",
"version": "0.7.3", "version": "0.8.0",
"homepage": "http://www.nodebb.org", "homepage": "http://www.nodebb.org",
"repository": { "repository": {
"type": "git", "type": "git",
@ -49,8 +49,8 @@
"nodebb-plugin-spam-be-gone": "0.4.1", "nodebb-plugin-spam-be-gone": "0.4.1",
"nodebb-rewards-essentials": "0.0.3", "nodebb-rewards-essentials": "0.0.3",
"nodebb-theme-lavender": "1.0.52", "nodebb-theme-lavender": "1.0.52",
"nodebb-theme-persona": "2.0.28", "nodebb-theme-persona": "2.1.6",
"nodebb-theme-vanilla": "3.0.17", "nodebb-theme-vanilla": "3.1.3",
"nodebb-widget-essentials": "1.0.5", "nodebb-widget-essentials": "1.0.5",
"npm": "^2.1.4", "npm": "^2.1.4",
"passport": "^0.3.0", "passport": "^0.3.0",

@ -487,13 +487,16 @@ app.cacheBuster = null;
}; };
function handleStatusChange() { 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'); var status = $(this).attr('data-status');
socket.emit('user.setStatus', status, function(err, data) { socket.emit('user.setStatus', status, function(err, data) {
if(err) { if(err) {
return app.alertError(err.message); 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; app.user.status = status;
}); });
e.preventDefault(); e.preventDefault();
@ -553,7 +556,9 @@ app.cacheBuster = null;
handleNewTopic(); handleNewTopic();
$('#logout-link').on('click', app.logout); require(['components'], function(components) {
components.get('user/logout').on('click', app.logout);
});
Visibility.change(function(e, state){ Visibility.change(function(e, state){
if (state === 'visible') { if (state === 'visible') {

@ -87,18 +87,20 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
} }
function updateHeader(picture, username, userslug) { function updateHeader(picture, username, userslug) {
if (parseInt(ajaxify.data.theirid, 10) !== parseInt(ajaxify.data.yourid, 10)) { require(['components'], function(components) {
return; if (parseInt(ajaxify.data.theirid, 10) !== parseInt(ajaxify.data.yourid, 10)) {
} return;
}
if (picture) { if (picture) {
$('#user-header-picture').attr('src', picture); components.get('header/userpicture').attr('src', picture);
} }
if (username && userslug) { if (username && userslug) {
$('#user-profile-link').attr('href', config.relative_path + '/user/' + userslug); components.get('header/profilelink').attr('href', config.relative_path + '/user/' + userslug);
$('#user-header-name').text(username); components.get('header/username').text(username);
} }
});
} }
function handleImageChange() { function handleImageChange() {

@ -7,9 +7,8 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
var newMessage = false; var newMessage = false;
module.prepareDOM = function() { module.prepareDOM = function() {
var chatsToggleEl = $('#chat_dropdown'), var chatsToggleEl = components.get('chat/dropdown'),
chatsListEl = $('#chat-list'), chatsListEl = components.get('chat/list');
dropdownEl;
// Sync open chats between all user socket sessions // Sync open chats between all user socket sessions
module.sync(); module.sync();
@ -19,46 +18,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
return; return;
} }
socket.emit('modules.chats.getRecentChats', {after: 0}, function(err, chats) { module.loadChats(chatsListEl);
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);
}
});
}); });
socket.on('event:chats.receive', function(data) { socket.on('event:chats.receive', function(data) {
@ -139,7 +99,7 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
username: chatObj.options.title, username: chatObj.options.title,
uid: chatObj.options.touid, uid: chatObj.options.touid,
new: chatObj.element.hasClass('new') new: chatObj.element.hasClass('new')
} };
}); });
callback(null, chats); 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) { module.bringModalToTop = function(chatModal) {
var topZ = 0; var topZ = 0;

@ -2,14 +2,14 @@
/* globals define, socket, utils, config, app, ajaxify, templates, Tinycon*/ /* 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 = {}; var Notifications = {};
Notifications.prepareDOM = function() { Notifications.prepareDOM = function() {
var notifContainer = $('.notifications'), var notifContainer = $('.notifications'),
notifTrigger = notifContainer.children('a'), notifTrigger = notifContainer.children('a'),
notifList = $('#notif-list'), notifList = $('#notif-list'),
notifIcon = $('.notification-icon'); notifIcon = components.get('notifications/icon');
notifTrigger.on('click', function(e) { notifTrigger.on('click', function(e) {
e.preventDefault(); e.preventDefault();
@ -17,25 +17,7 @@ define('notifications', ['sounds', 'translator'], function(sound, translator) {
return; return;
} }
socket.emit('notifications.get', null, function(err, data) { Notifications.loadNotifications(notifList);
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);
});
});
}); });
notifList.on('click', '[data-nid]', function() { 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) { Notifications.updateNotifCount = function(count) {
var notifIcon = $('.notification-icon'); var notifIcon = components.get('notifications/icon');
if (count > 0) { if (count > 0) {
notifIcon.removeClass('fa-bell-o').addClass('fa-bell'); notifIcon.removeClass('fa-bell-o').addClass('fa-bell');

@ -27,7 +27,7 @@ categoriesController.list = function(req, res, next) {
content: validator.escape(meta.config.description || '') content: validator.escape(meta.config.description || '')
}, { }, {
property: 'og:title', property: 'og:title',
content: 'Index | ' + validator.escape(meta.config.title || 'NodeBB') content: '[[pages:categories]]'
}, { }, {
property: 'og:type', property: 'og:type',
content: 'website' content: 'website'

@ -194,7 +194,7 @@ usersController.getMap = function(req, res, next) {
return next(err); return next(err);
} }
data.sort(function(a, b) { data.sort(function(a, b) {
return b.total - a.total; return b.users.length - a.users.length;
}); });
data.forEach(function(room) { data.forEach(function(room) {

@ -34,7 +34,7 @@ module.exports = function(Meta) {
return callback(err); 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')), baseThemePath = path.join(nconf.get('themes_path'), (themeData['theme:type'] && themeData['theme:type'] === 'local' ? themeId : 'nodebb-theme-vanilla')),
paths = [ paths = [
baseThemePath, baseThemePath,

@ -119,7 +119,7 @@ module.exports = function(Meta) {
return callback(err); return callback(err);
} }
var themeId = data.currentThemeId || 'nodebb-theme-vanilla'; var themeId = data.currentThemeId || 'nodebb-theme-persona';
var themeObj = data.themesData.filter(function(themeObj) { var themeObj = data.themesData.filter(function(themeObj) {
return themeObj.id === themeId; return themeObj.id === themeId;

@ -300,6 +300,10 @@ middleware.renderHeader = function(req, res, data, callback) {
templateValues.template = {name: res.locals.template}; templateValues.template = {name: res.locals.template};
templateValues.template[res.locals.template] = true; 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) { plugins.fireHook('filter:middleware.renderHeader', {templateValues: templateValues, req: req, res: res}, function(err, data) {
if (err) { if (err) {
return callback(err); return callback(err);
@ -342,6 +346,10 @@ middleware.processRender = function(req, res, next) {
} }
if (res.locals.isAPI) { if (res.locals.isAPI) {
if (req.route.path === '/api/') {
options.title = '[[pages:home]]';
}
return res.json(options); return res.json(options);
} }
@ -519,6 +527,21 @@ function redirectToLogin(req, res) {
return controllers.helpers.redirect(res, '/login'); 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) { module.exports = function(webserver) {
app = webserver; app = webserver;
middleware.admin = require('./admin')(webserver); middleware.admin = require('./admin')(webserver);

@ -53,26 +53,14 @@ module.exports = function(User) {
renamedUsername: function(next) { renamedUsername: function(next) {
renameUsername(userData, next); renameUsername(userData, next);
}, },
customFields: function(next) {
plugins.fireHook('filter:user.custom_fields', [], next);
},
userData: function(next) { userData: function(next) {
plugins.fireHook('filter:user.create', userData, next); plugins.fireHook('filter:user.create', {user: userData, data: data}, next);
} }
}, function(err, results) { }, function(err, results) {
if (err) { if (err) {
return callback(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; var userNameChanged = !!results.renamedUsername;
if (userNameChanged) { if (userNameChanged) {

Loading…
Cancel
Save