From 4e2318fa1ebc1aaeabc90d8a1b444cd1c24957bd Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 23 Sep 2015 01:59:13 -0400 Subject: [PATCH] fix title in acp removed extra | --- public/src/app.js | 3 +++ src/controllers/api.js | 2 +- src/controllers/helpers.js | 9 +++++++++ src/middleware/middleware.js | 11 ++--------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/public/src/app.js b/public/src/app.js index 69fb1da0db..77b58014ed 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -291,6 +291,9 @@ app.cacheBuster = null; }; app.refreshTitle = function(title) { + if (!title) { + return; + } require(['translator'], function(translator) { title = config.titleLayout.replace(/{/g, '{').replace(/}/g, '}').replace('{pageTitle}', title).replace('{browserTitle}', config.browserTitle); translator.translate(title, function(translated) { diff --git a/src/controllers/api.js b/src/controllers/api.js index 5b8f2b2bb6..14dbe4b309 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -34,7 +34,7 @@ apiController.getConfig = function(req, res, next) { 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.titleLayout = (meta.config.titleLayout || '{pageTitle} || {browserTitle}').replace(/{/g, '{').replace(/}/g, '}'); + config.titleLayout = (meta.config.titleLayout || '{pageTitle} | {browserTitle}').replace(/{/g, '{').replace(/}/g, '}'); config.showSiteTitle = parseInt(meta.config.showSiteTitle, 10) === 1; config.postDelay = meta.config.postDelay; config.minimumTitleLength = meta.config.minimumTitleLength; diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index ce1938ca30..94dfe022c2 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -100,4 +100,13 @@ helpers.buildBreadcrumbs = function(crumbs) { return breadcrumbs; }; +helpers.buildTitle = function(pageTitle) { + var titleLayout = meta.config.titleLayout || '{pageTitle} | {browserTitle}'; + + var browserTitle = validator.escape(meta.config.browserTitle || meta.config.title || 'NodeBB'); + pageTitle = pageTitle || ''; + var title = titleLayout.replace('{pageTitle}', pageTitle).replace('{browserTitle}', browserTitle); + return title; +}; + module.exports = helpers; \ No newline at end of file diff --git a/src/middleware/middleware.js b/src/middleware/middleware.js index be2a97aa3f..6049970468 100644 --- a/src/middleware/middleware.js +++ b/src/middleware/middleware.js @@ -237,7 +237,7 @@ middleware.renderHeader = function(req, res, data, callback) { } }, title: function(next) { - next(null, buildTitle(data.title)); + next(null, controllers.helpers.buildTitle(data.title)); }, isAdmin: function(next) { user.isAdministrator(req.uid, next); @@ -454,17 +454,10 @@ function redirectToLogin(req, res) { return controllers.helpers.redirect(res, '/login'); } -function buildTitle(pageTitle) { - var titleLayout = meta.config.titleLayout || '{pageTitle} | {browserTitle}'; - var browserTitle = validator.escape(meta.config.browserTitle || meta.config.title || 'NodeBB'); - pageTitle = pageTitle || ''; - var title = titleLayout.replace('{pageTitle}', pageTitle).replace('{browserTitle}', browserTitle); - return title; -} function modifyTitle(obj) { - var title = buildTitle('[[pages:home]]'); + var title = controllers.helpers.buildTitle('[[pages:home]]'); obj.browserTitle = title; if (obj.metaTags) {