From 031e8128c77259561e8cd5cc95413ac354129672 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 19 Feb 2014 14:33:34 -0500 Subject: [PATCH] fixed #912, added new page string for popular topics --- public/language/en_GB/pages.json | 1 + src/webserver.js | 37 ++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/public/language/en_GB/pages.json b/public/language/en_GB/pages.json index d01f5f8a9b..9fc75d3d2b 100644 --- a/public/language/en_GB/pages.json +++ b/public/language/en_GB/pages.json @@ -1,6 +1,7 @@ { "home": "Home", "unread": "Unread Topics", + "popular": "Popular Topics", "recent": "Recent Topics", "users": "Registered Users", "notifications": "Notifications", diff --git a/src/webserver.js b/src/webserver.js index d87c58b66d..fd6536e5e4 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -132,16 +132,6 @@ module.exports.server = server; href: nconf.get('relative_path') + '/favicon.ico' }); - // Browser Title - var metaTitle = templateValues.metaTags.filter(function(tag) { - return tag.property === 'og:title'; - }); - if (metaTitle.length > 0 && metaTitle[0].content) { - templateValues.browserTitle = metaTitle[0].content; - } else { - templateValues.browserTitle = meta.config.browserTitle || 'NodeBB'; - } - if(options.req.user && options.req.user.uid) { uid = options.req.user.uid; } @@ -153,15 +143,34 @@ module.exports.server = server; templateValues.customCSS = meta.config.customCSS; } - user.isAdministrator(uid, function(err, isAdmin) { - templateValues.isAdmin = isAdmin; + async.parallel([ + function(next) { + translator.get('pages:' + path.basename(options.req.url), function(translated) { + var metaTitle = templateValues.metaTags.filter(function(tag) { + return tag.name === 'title'; + }); + if (translated) { + templateValues.browserTitle = translated; + } else if (metaTitle.length > 0 && metaTitle[0].content) { + templateValues.browserTitle = metaTitle[0].content; + } else { + templateValues.browserTitle = meta.config.browserTitle || 'NodeBB'; + } + next(); + }); + }, + function(next) { + user.isAdministrator(uid, function(err, isAdmin) { + templateValues.isAdmin = isAdmin || false; + next(); + }); + } + ], function() { translator.translate(templates.header.parse(templateValues), function(template) { callback(null, template); }); }); - - }); };