v1.18.x
psychobunny 10 years ago
parent 298625225a
commit eb4baf62b5

@ -24,6 +24,8 @@ var fs = require('fs'),
websockets = require('../socket.io');
function userNotFound(res) {
res.locals.notFound = true;
if (res.locals.isAPI) {
res.status(404).json('no-user');
} else {

@ -15,7 +15,7 @@ module.exports = function(Meta) {
isUserPage: /^user\/[^\/]+(\/[\w]+)?/
};
Meta.title.build = function (urlFragment, language, callback) {
Meta.title.build = function (urlFragment, language, locals, callback) {
var uri = '';
try {
uri = decodeURIComponent(urlFragment);
@ -23,7 +23,8 @@ module.exports = function(Meta) {
winston.error('Invalid url fragment : ' + urlFragment, e.stack);
return callback(null, Meta.config.browserTitle || 'NodeBB');
}
Meta.title.parseFragment(uri, language, function(err, title) {
Meta.title.parseFragment(uri, language, locals, function(err, title) {
if (err) {
title = Meta.config.browserTitle || 'NodeBB';
} else {
@ -34,7 +35,7 @@ module.exports = function(Meta) {
});
};
Meta.title.parseFragment = function (urlFragment, language, callback) {
Meta.title.parseFragment = function (urlFragment, language, locals, callback) {
urlFragment = validator.escape(urlFragment);
var translated = ['', 'recent', 'unread', 'users', 'notifications'];
if (translated.indexOf(urlFragment) !== -1) {
@ -69,6 +70,10 @@ module.exports = function(Meta) {
return callback(err);
}
if (locals.notFound) {
username = '[[error:no-user]]';
}
if (!subpage) {
return callback(null, username);
}

@ -339,10 +339,10 @@ middleware.renderHeader = function(req, res, callback) {
if (err) {
return next(err);
}
meta.title.build(req.url.slice(1), settings.language, next);
meta.title.build(req.url.slice(1), settings.language, res.locals, next);
});
} else {
meta.title.build(req.url.slice(1), meta.config.defaultLang, next);
meta.title.build(req.url.slice(1), meta.config.defaultLang, res.locals, next);
}
},
isAdmin: function(next) {

Loading…
Cancel
Save