Merge branch 'master' into persona-2.1

v1.18.x
psychobunny 10 years ago
commit 2e33ae2742

@ -1,7 +1,10 @@
{
"home": "Home",
"unread": "Unread Topics",
"popular": "Popular Topics",
"popular-day": "Popular topics today",
"popular-week": "Popular topics this week",
"popular-month": "Popular topics this month",
"popular-alltime": "All time popular topics",
"recent": "Recent Topics",
"users/online": "Online Users",
@ -25,15 +28,15 @@
"chats": "Chats",
"chat": "Chatting with %1",
"user.edit": "Editing \"%1\"",
"user.following": "People %1 Follows",
"user.followers": "People who Follow %1",
"user.posts": "Posts made by %1",
"user.topics": "Topics created by %1",
"user.groups": "%1's Groups",
"user.favourites": "%1's Favourite Posts",
"user.settings": "User Settings",
"user.watched": "Topics watched by %1",
"account/edit": "Editing \"%1\"",
"account/following": "People %1 follows",
"account/followers": "People who follow %1",
"account/posts": "Posts made by %1",
"account/topics": "Topics created by %1",
"account/groups": "%1's Groups",
"account/favourites": "%1's Favourite Posts",
"account/settings": "User Settings",
"account/watched": "Topics watched by %1",
"maintenance.text": "%1 is currently undergoing maintenance. Please come back another time.",
"maintenance.messageIntro": "Additionally, the administrator has left this message:"

@ -150,7 +150,7 @@ $(document).ready(function() {
$('#content, #footer').removeClass('ajaxifying');
app.refreshTitle(url);
app.refreshTitle(data.title);
});
});
}

@ -389,19 +389,13 @@ app.cacheBuster = null;
}
};
app.refreshTitle = function(url) {
if (!url) {
var a = document.createElement('a');
a.href = document.location;
url = a.pathname.slice(1);
}
socket.emit('meta.buildTitle', url, function(err, title, numNotifications) {
if (err) {
return;
}
titleObj.titles[0] = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
app.alternatingTitle('');
app.refreshTitle = function(title) {
require(['translator'], function(translator) {
translator.translate(title, function(translated) {
translated = translated ? (translated + ' | ' + config.browserTitle) : config.browserTitle;
titleObj.titles[0] = translated;
app.alternatingTitle('');
});
});
};

@ -230,6 +230,7 @@ function getFollow(tpl, name, req, res, next) {
userData.users = users;
userData.nextStart = 50;
userData.title = '[[pages:' + tpl + ', ' + userData.username + ']]';
res.render(tpl, userData);
});
@ -268,7 +269,7 @@ accountsController.getGroups = function(req, res, next) {
userData.groups = groupsData[0];
userData.groups.forEach(groups.escapeGroupData);
userData.title = '[[pages:account/groups, ' + userData.username + ']]';
res.render('account/groups', userData);
});
});
@ -321,6 +322,8 @@ function getFromUserSet(tpl, set, method, type, req, res, next) {
var pagination = require('../pagination');
userData.pagination = pagination.create(page, pageCount);
userData.title = '[[pages:' + tpl + ', ' + userData.username + ']]';
res.render(tpl, userData);
});
});
@ -377,7 +380,7 @@ accountsController.accountEdit = function(req, res, next) {
}
userData.hasPassword = !!password;
userData.title = '[[pages:account/edit, ' + userData.username + ']]';
res.render('account/edit', userData);
});
};
@ -514,6 +517,8 @@ accountsController.accountSettings = function(req, res, next) {
userData.disableCustomUserSkins = parseInt(meta.config.disableCustomUserSkins, 10) === 1;
userData.title = '[[pages:account/settings]]';
res.render('account/settings', userData);
});
};
@ -563,7 +568,8 @@ accountsController.getNotifications = function(req, res, next) {
return next(err);
}
res.render('notifications', {
notifications: notifications
notifications: notifications,
title: '[[pages:notifications]]'
});
});
};
@ -603,7 +609,8 @@ accountsController.getChats = function(req, res, next) {
chats: results.recentChats.users,
nextStart: results.recentChats.nextStart,
contacts: results.contacts,
allowed: true
allowed: true,
title: '[[pages:chats]]'
});
}
@ -631,7 +638,8 @@ accountsController.getChats = function(req, res, next) {
contacts: results.contacts,
meta: data.toUser,
messages: data.messages,
allowed: data.allowed
allowed: data.allowed,
title: '[[pages:chat, ' + data.toUser.username + ']]'
});
});
});

@ -27,6 +27,7 @@ apiController.getConfig = function(req, res, next) {
config.websocketAddress = nconf.get('socket.io:address') || '';
config.version = nconf.get('version');
config.siteTitle = validator.escape(meta.config.title || meta.config.browserTitle || 'NodeBB');
config.browserTitle = validator.escape(meta.config.browserTitle || meta.config.title || 'NodeBB');
config.showSiteTitle = parseInt(meta.config.showSiteTitle, 10) === 1;
config.postDelay = meta.config.postDelay;
config.minimumTitleLength = meta.config.minimumTitleLength;

@ -65,6 +65,8 @@ categoriesController.list = function(req, res, next) {
return next(err);
}
data.title = '[[pages:categories]]';
plugins.fireHook('filter:categories.build', {req: req, res: res, templateData: data}, function(err, data) {
if (err) {
return next(err);
@ -250,7 +252,7 @@ categoriesController.get = function(req, res, next) {
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
data.rssFeedUrl = nconf.get('relative_path') + '/category/' + data.cid + '.rss';
data.pagination = pagination.create(data.currentPage, data.pageCount);
data.title = data.name;
data.pagination.rel.forEach(function(rel) {
res.locals.linkTags.push(rel);
});

@ -16,6 +16,7 @@ groupsController.list = function(req, res, next) {
if (err) {
return next(err);
}
data.title = '[[pages:groups]]';
res.render('groups/list', data);
});
};
@ -97,6 +98,7 @@ groupsController.details = function(req, res, next) {
return helpers.notFound(req, res);
}
results.title = '[[pages:group, ' + results.group.displayName + ']]';
res.render('groups/details', results);
});
});

@ -61,7 +61,8 @@ Controllers.reset = function(req, res, next) {
valid: valid,
displayExpiryNotice: req.session.passwordExpired,
code: req.params.code ? req.params.code : null,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]', url: '/reset'}, {text: '[[reset_password:update_password]]'}])
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]', url: '/reset'}, {text: '[[reset_password:update_password]]'}]),
title: '[[pages:reset]]'
});
delete req.session.passwordExpired;
@ -69,7 +70,8 @@ Controllers.reset = function(req, res, next) {
} else {
res.render('reset', {
code: req.params.code ? req.params.code : null,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]'}])
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]'}]),
title: '[[pages:reset]]'
});
}
@ -90,6 +92,7 @@ Controllers.login = function(req, res, next) {
data.allowLoginWith = '[[login:' + (meta.config.allowLoginWith || 'username-email') + ']]';
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:login]]'}]);
data.error = req.flash('error')[0];
data.title = '[[pages:login]]';
res.render('login', data);
};
@ -128,6 +131,7 @@ Controllers.register = function(req, res, next) {
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[register:register]]'}]);
data.regFormEntry = [];
data.error = req.flash('error')[0];
data.title = '[[pages:register]]';
plugins.fireHook('filter:register.build', {req: req, res: res, templateData: data}, next);
}

@ -36,7 +36,8 @@ popularController.get = function(req, res, next) {
topics: topics,
'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1,
rssFeedUrl: nconf.get('relative_path') + '/popular/' + (req.params.term || 'daily') + '.rss',
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[global:header.popular]]'}])
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[global:header.popular]]'}]),
title: '[[pages:popular-' + term + ']]'
};
if (!req.uid) {

@ -21,6 +21,7 @@ recentController.get = function(req, res, next) {
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
data.rssFeedUrl = nconf.get('relative_path') + '/recent.rss';
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[recent:title]]'}]);
data.title = '[[pages:recent]]';
plugins.fireHook('filter:recent.build', {req: req, res: res, templateData: data}, function(err, data) {
if (err) {

@ -62,7 +62,8 @@ tagsController.getTag = function(req, res, next) {
topics: results.topics,
tag: tag,
nextStart: stop + 1,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]', url: '/tags'}, {text: tag}])
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]', url: '/tags'}, {text: tag}]),
title: '[[pages:tag, ' + tag + ']]'
};
res.render('tag', data);
});
@ -76,7 +77,8 @@ tagsController.getTags = function(req, res, next) {
var data = {
tags: tags,
nextStart: 100,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]'}])
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]'}]),
title: '[[pages:tags]]'
};
res.render('tags', data);
});

@ -55,6 +55,8 @@ unreadController.get = function(req, res, next) {
}
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[unread:title]]'}]);
data.title = '[[pages:unread]]';
res.render('unread', data);
});
};

@ -49,7 +49,8 @@ usersController.getOnlineUsers = function(req, res, next) {
loadmore_display: results.count > 50 ? 'block' : 'hide',
users: results.users,
anonymousUserCount: websockets.getOnlineAnonCount(),
defaultGravatar: user.createGravatarURLFromEmail('')
defaultGravatar: user.createGravatarURLFromEmail(''),
title: '[[pages:users/online]]'
};
render(req, res, userData, next);
@ -69,6 +70,11 @@ usersController.getUsersSortedByJoinDate = function(req, res, next) {
};
usersController.getUsers = function(set, start, stop, req, res, next) {
var setToTitles = {
'users:postcount': '[[pages:users/sort-posts]]',
'users:reputation': '[[pages:users/sort-reputation]]',
'users:joindate': '[[pages:users/latest]]'
};
usersController.getUsersAndCount(set, req.uid, start, stop, function(err, data) {
if (err) {
return next(err);
@ -78,7 +84,8 @@ usersController.getUsers = function(set, start, stop, req, res, next) {
search_display: 'hidden',
loadmore_display: data.count > (stop - start + 1) ? 'block' : 'hide',
users: data.users,
pagination: pagination.create(1, pageCount)
pagination: pagination.create(1, pageCount),
title: setToTitles[set] || '[[pages:users/latest]]'
};
userData['route_' + set] = true;
render(req, res, userData, next);
@ -119,7 +126,8 @@ usersController.getUsersForSearch = function(req, res, next) {
var userData = {
search_display: 'block',
loadmore_display: 'hidden',
users: data.users
users: data.users,
title: '[[pages:users/search]]'
};
render(req, res, userData, next);
@ -195,7 +203,7 @@ usersController.getMap = function(req, res, next) {
}
});
res.render('usersMap', {rooms: data});
res.render('usersMap', {rooms: data, title: '[[pages:users/map]]'});
});
};

@ -17,7 +17,6 @@ var async = require('async'),
require('./meta/configs')(Meta);
require('./meta/themes')(Meta);
require('./meta/title')(Meta);
require('./meta/js')(Meta);
require('./meta/css')(Meta);
require('./meta/sounds')(Meta);

@ -1,142 +0,0 @@
'use strict';
var winston = require('winston'),
validator = require('validator'),
user = require('../user'),
groups = require('../groups'),
plugins = require('../plugins'),
translator = require('../../public/src/modules/translator');
module.exports = function(Meta) {
Meta.title = {};
var tests = {
isCategory: /^category\/\d+\/?/,
isTopic: /^topic\/\d+\/?/,
isTag: /^tags\/[\s\S]+\/?/,
isUserPage: /^user\/[^\/]+(\/[\w]+)?/,
isGroup: /^groups\/[\s\S]+\/?/,
isChat: /^chats\/[\s\S]+\/?/
};
Meta.title.build = function (urlFragment, language, callback) {
var uri = '';
var fallbackTitle = validator.escape(Meta.config.browserTitle || Meta.config.title || 'NodeBB');
try {
uri = decodeURIComponent(urlFragment);
} catch(e) {
winston.error('Invalid url fragment : ' + urlFragment, e.stack);
return callback(null, fallbackTitle);
}
Meta.title.parseFragment(uri, language, function(err, title) {
if (err) {
title = fallbackTitle;
} else {
if (title) {
title = validator.escape(title);
}
title = (title ? title + ' | ' : '') + fallbackTitle;
}
callback(null, title);
});
};
Meta.title.parseFragment = function (urlFragment, language, callback) {
var translated = [
'', 'recent', 'unread', 'notifications', 'popular', 'tags', 'chats', 'register', 'login', 'reset', 'categories', 'groups',
'users/online', 'users/latest', 'users/sort-posts', 'users/sort-reputation', 'users/map', 'users/search'
];
var onParsed = function(err, translated) {
if (err) {
return callback(err);
}
plugins.fireHook('filter:parse.title', {
fragment: urlFragment,
language: language,
parsed: translated
}, function(err, data) {
if (err) {
return callback(err);
}
callback(null, data.parsed);
});
};
if (translated.indexOf(urlFragment) !== -1) {
if (!urlFragment.length) {
urlFragment = 'home';
}
translator.translate('[[pages:' + urlFragment + ']]', language, function(translated) {
onParsed(null, translated);
});
} else if (tests.isCategory.test(urlFragment)) {
var cid = urlFragment.match(/category\/(\d+)/)[1];
require('../categories').getCategoryField(cid, 'name', onParsed);
} else if (tests.isTopic.test(urlFragment)) {
var tid = urlFragment.match(/topic\/(\d+)/)[1];
require('../topics').getTopicField(tid, 'title', onParsed);
} else if (tests.isTag.test(urlFragment)) {
var tag = urlFragment.match(/tags\/([\s\S]+)/)[1];
translator.translate('[[pages:tag, ' + tag + ']]', language, function(translated) {
onParsed(null, translated);
});
} else if (tests.isGroup.test(urlFragment)) {
var slug = urlFragment.match(/groups\/([\s\S]+)/)[1];
groups.getGroupNameByGroupSlug(slug, function(err, groupname) {
if (err) {
return onParsed(err);
}
translator.translate('[[pages:group, ' + groupname + ']]', language, function(translated) {
onParsed(null, translated);
});
});
} else if (tests.isChat.test(urlFragment)) {
var userslug = urlFragment.match(/chats\/([\s\S]+)/)[1];
user.getUsernameByUserslug(userslug, function(err, username) {
if (err) {
return onParsed(err);
}
translator.translate('[[pages:chat, ' + username + ']]', language, function(translated) {
onParsed(null, translated);
});
});
} else if (tests.isUserPage.test(urlFragment)) {
var matches = urlFragment.match(/user\/([^\/]+)\/?([\w]+)?/),
userslug = matches[1],
subpage = matches[2];
user.getUsernameByUserslug(userslug, function(err, username) {
if (err) {
return onParsed(err);
}
if (!username) {
username = '[[error:no-user]]';
}
if (!subpage) {
return onParsed(null, username);
}
translator.translate('[[pages:user.' + subpage + ', ' + username + ']]', language, function(translated) {
onParsed(null, translated);
});
});
} else {
onParsed(null);
}
};
};

@ -52,7 +52,7 @@ middleware.buildHeader = function(req, res, next) {
});
};
middleware.renderHeader = function(req, res, next) {
middleware.renderHeader = function(req, res, data, next) {
var custom_header = {
'plugins': [],
'authentication': []
@ -92,7 +92,7 @@ middleware.renderHeader = function(req, res, next) {
}
res.locals.config = results.config;
var data = {
var templateValues = {
relative_path: nconf.get('relative_path'),
configJSON: JSON.stringify(results.config),
user: userData,
@ -104,10 +104,10 @@ middleware.renderHeader = function(req, res, next) {
env: process.env.NODE_ENV ? true : false,
};
data.template = {name: res.locals.template};
data.template[res.locals.template] = true;
templateValues.template = {name: res.locals.template};
templateValues.template[res.locals.template] = true;
app.render('admin/header', data, next);
app.render('admin/header', templateValues, next);
});
});
};

@ -68,7 +68,7 @@ middleware.pageView = function(req, res, next) {
middleware.pluginHooks = function(req, res, next) {
async.each(plugins.loadedHooks['filter:router.page'] || [], function(hookObj, next) {
hookObj.method(req, res, next)
hookObj.method(req, res, next);
}, function(req, res) {
// If it got here, then none of the subscribed hooks did anything, or there were no hooks
next();
@ -143,12 +143,12 @@ middleware.checkAccountPermissions = function(req, res, next) {
}
user.isAdministrator(req.uid, next);
}
}
], function (err, allowed) {
if (err || allowed) {
return next(err);
}
controllers.helpers.notAllowed(req, res);
controllers.helpers.notAllowed(req, res);
});
};
@ -202,7 +202,7 @@ middleware.buildHeader = function(req, res, next) {
});
};
middleware.renderHeader = function(req, res, callback) {
middleware.renderHeader = function(req, res, data, callback) {
var registrationType = meta.config.registrationType || 'normal';
var templateValues = {
bootswatchCSS: meta.config['theme:src'],
@ -237,23 +237,18 @@ middleware.renderHeader = function(req, res, callback) {
templateValues.useCustomJS = parseInt(meta.config.useCustomJS, 10) === 1;
next(null, templateValues.useCustomJS ? meta.config.customJS : '');
},
title: function(next) {
settings: function(next) {
if (req.uid) {
user.getSettings(req.uid, function(err, settings) {
if (err) {
return next(err);
}
if (settings.bootswatchSkin && settings.bootswatchSkin !== 'default') {
templateValues.bootswatchCSS = '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + settings.bootswatchSkin + '/bootstrap.min.css';
}
meta.title.build(req.url.slice(1), settings.userLang, next);
});
user.getSettings(req.uid, next);
} else {
meta.title.build(req.url.slice(1), meta.config.defaultLang, next);
next();
}
},
title: function(next) {
var title = validator.escape(meta.config.browserTitle || meta.config.title || 'NodeBB');
title = data.title ? (data.title + ' | ' + title) : title;
next(null, title);
},
isAdmin: function(next) {
user.isAdministrator(req.uid, next);
},
@ -280,13 +275,16 @@ middleware.renderHeader = function(req, res, callback) {
if (results.user && parseInt(results.user.banned, 10) === 1) {
req.logout();
res.redirect('/');
return;
return res.redirect('/');
}
results.user.isAdmin = results.isAdmin || false;
results.user.uid = parseInt(results.user.uid, 10);
results.user['email:confirmed'] = parseInt(results.user['email:confirmed'], 10) === 1;
if (results.settings && results.settings.bootswatchSkin && results.settings.bootswatchSkin !== 'default') {
templateValues.bootswatchCSS = '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + settings.bootswatchSkin + '/bootstrap.min.css';
}
templateValues.browserTitle = results.title;
templateValues.navigation = results.navigation;
templateValues.metaTags = results.tags.meta;
@ -364,7 +362,7 @@ middleware.processRender = function(req, res, next) {
if (res.locals.renderHeader || res.locals.renderAdminHeader) {
var method = res.locals.renderHeader ? middleware.renderHeader : middleware.admin.renderHeader;
method(req, res, function(err, template) {
method(req, res, options, function(err, template) {
if (err) {
return fn(err);
}

@ -35,18 +35,6 @@ emitter.on('nodebb:ready', function() {
});
});
SocketMeta.buildTitle = function(socket, text, callback) {
if (socket.uid) {
user.getSettings(socket.uid, function(err, settings) {
if (err) {
return callback(err);
}
meta.title.build(text, settings.userLang, callback);
});
} else {
meta.title.build(text, meta.config.defaultLang, callback);
}
};
/* Rooms */

Loading…
Cancel
Save