mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 01:56:12 +01:00
remove meta/title.js and meta.title.build #3481
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
{
|
{
|
||||||
"home": "Home",
|
"home": "Home",
|
||||||
"unread": "Unread Topics",
|
"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",
|
"recent": "Recent Topics",
|
||||||
|
|
||||||
"users/online": "Online Users",
|
"users/online": "Online Users",
|
||||||
@@ -25,15 +28,15 @@
|
|||||||
"chats": "Chats",
|
"chats": "Chats",
|
||||||
"chat": "Chatting with %1",
|
"chat": "Chatting with %1",
|
||||||
|
|
||||||
"user.edit": "Editing \"%1\"",
|
"account/edit": "Editing \"%1\"",
|
||||||
"user.following": "People %1 Follows",
|
"account/following": "People %1 follows",
|
||||||
"user.followers": "People who Follow %1",
|
"account/followers": "People who follow %1",
|
||||||
"user.posts": "Posts made by %1",
|
"account/posts": "Posts made by %1",
|
||||||
"user.topics": "Topics created by %1",
|
"account/topics": "Topics created by %1",
|
||||||
"user.groups": "%1's Groups",
|
"account/groups": "%1's Groups",
|
||||||
"user.favourites": "%1's Favourite Posts",
|
"account/favourites": "%1's Favourite Posts",
|
||||||
"user.settings": "User Settings",
|
"account/settings": "User Settings",
|
||||||
"user.watched": "Topics watched by %1",
|
"account/watched": "Topics watched by %1",
|
||||||
|
|
||||||
"maintenance.text": "%1 is currently undergoing maintenance. Please come back another time.",
|
"maintenance.text": "%1 is currently undergoing maintenance. Please come back another time.",
|
||||||
"maintenance.messageIntro": "Additionally, the administrator has left this message:"
|
"maintenance.messageIntro": "Additionally, the administrator has left this message:"
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$('#content, #footer').removeClass('ajaxifying');
|
$('#content, #footer').removeClass('ajaxifying');
|
||||||
|
|
||||||
app.refreshTitle(url);
|
app.refreshTitle(data.title);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -389,19 +389,13 @@ app.cacheBuster = null;
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
app.refreshTitle = function(url) {
|
app.refreshTitle = function(title) {
|
||||||
if (!url) {
|
require(['translator'], function(translator) {
|
||||||
var a = document.createElement('a');
|
translator.translate(title, function(translated) {
|
||||||
a.href = document.location;
|
translated = translated ? (translated + ' | ' + config.browserTitle) : config.browserTitle;
|
||||||
url = a.pathname.slice(1);
|
titleObj.titles[0] = translated;
|
||||||
}
|
app.alternatingTitle('');
|
||||||
|
});
|
||||||
socket.emit('meta.buildTitle', url, function(err, title, numNotifications) {
|
|
||||||
if (err) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
titleObj.titles[0] = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
|
|
||||||
app.alternatingTitle('');
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ function getFollow(tpl, name, req, res, next) {
|
|||||||
|
|
||||||
userData.users = users;
|
userData.users = users;
|
||||||
userData.nextStart = 50;
|
userData.nextStart = 50;
|
||||||
|
userData.title = '[[pages:' + tpl + ', ' + userData.username + ']]';
|
||||||
|
|
||||||
res.render(tpl, userData);
|
res.render(tpl, userData);
|
||||||
});
|
});
|
||||||
@@ -268,7 +269,7 @@ accountsController.getGroups = function(req, res, next) {
|
|||||||
|
|
||||||
userData.groups = groupsData[0];
|
userData.groups = groupsData[0];
|
||||||
userData.groups.forEach(groups.escapeGroupData);
|
userData.groups.forEach(groups.escapeGroupData);
|
||||||
|
userData.title = '[[pages:account/groups, ' + userData.username + ']]';
|
||||||
res.render('account/groups', userData);
|
res.render('account/groups', userData);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -321,6 +322,8 @@ function getFromUserSet(tpl, set, method, type, req, res, next) {
|
|||||||
var pagination = require('../pagination');
|
var pagination = require('../pagination');
|
||||||
userData.pagination = pagination.create(page, pageCount);
|
userData.pagination = pagination.create(page, pageCount);
|
||||||
|
|
||||||
|
userData.title = '[[pages:' + tpl + ', ' + userData.username + ']]';
|
||||||
|
|
||||||
res.render(tpl, userData);
|
res.render(tpl, userData);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -377,7 +380,7 @@ accountsController.accountEdit = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userData.hasPassword = !!password;
|
userData.hasPassword = !!password;
|
||||||
|
userData.title = '[[pages:account/edit, ' + userData.username + ']]';
|
||||||
res.render('account/edit', userData);
|
res.render('account/edit', userData);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -514,6 +517,8 @@ accountsController.accountSettings = function(req, res, next) {
|
|||||||
|
|
||||||
userData.disableCustomUserSkins = parseInt(meta.config.disableCustomUserSkins, 10) === 1;
|
userData.disableCustomUserSkins = parseInt(meta.config.disableCustomUserSkins, 10) === 1;
|
||||||
|
|
||||||
|
userData.title = '[[pages:account/settings]]';
|
||||||
|
|
||||||
res.render('account/settings', userData);
|
res.render('account/settings', userData);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -563,7 +568,8 @@ accountsController.getNotifications = function(req, res, next) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
res.render('notifications', {
|
res.render('notifications', {
|
||||||
notifications: notifications
|
notifications: notifications,
|
||||||
|
title: '[[pages:notifications]]'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -603,7 +609,8 @@ accountsController.getChats = function(req, res, next) {
|
|||||||
chats: results.recentChats.users,
|
chats: results.recentChats.users,
|
||||||
nextStart: results.recentChats.nextStart,
|
nextStart: results.recentChats.nextStart,
|
||||||
contacts: results.contacts,
|
contacts: results.contacts,
|
||||||
allowed: true
|
allowed: true,
|
||||||
|
title: '[[pages:chats]]'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,7 +638,8 @@ accountsController.getChats = function(req, res, next) {
|
|||||||
contacts: results.contacts,
|
contacts: results.contacts,
|
||||||
meta: data.toUser,
|
meta: data.toUser,
|
||||||
messages: data.messages,
|
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.websocketAddress = nconf.get('socket.io:address') || '';
|
||||||
config.version = nconf.get('version');
|
config.version = nconf.get('version');
|
||||||
config.siteTitle = validator.escape(meta.config.title || meta.config.browserTitle || 'NodeBB');
|
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.showSiteTitle = parseInt(meta.config.showSiteTitle, 10) === 1;
|
||||||
config.postDelay = meta.config.postDelay;
|
config.postDelay = meta.config.postDelay;
|
||||||
config.minimumTitleLength = meta.config.minimumTitleLength;
|
config.minimumTitleLength = meta.config.minimumTitleLength;
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ categoriesController.list = function(req, res, next) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.title = '[[pages:categories]]';
|
||||||
|
|
||||||
plugins.fireHook('filter:categories.build', {req: req, res: res, templateData: data}, function(err, data) {
|
plugins.fireHook('filter:categories.build', {req: req, res: res, templateData: data}, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(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['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
|
||||||
data.rssFeedUrl = nconf.get('relative_path') + '/category/' + data.cid + '.rss';
|
data.rssFeedUrl = nconf.get('relative_path') + '/category/' + data.cid + '.rss';
|
||||||
data.pagination = pagination.create(data.currentPage, data.pageCount);
|
data.pagination = pagination.create(data.currentPage, data.pageCount);
|
||||||
|
data.title = data.name;
|
||||||
data.pagination.rel.forEach(function(rel) {
|
data.pagination.rel.forEach(function(rel) {
|
||||||
res.locals.linkTags.push(rel);
|
res.locals.linkTags.push(rel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ groupsController.list = function(req, res, next) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
data.title = '[[pages:groups]]';
|
||||||
res.render('groups/list', data);
|
res.render('groups/list', data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -97,6 +98,7 @@ groupsController.details = function(req, res, next) {
|
|||||||
return helpers.notFound(req, res);
|
return helpers.notFound(req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
results.title = '[[pages:group, ' + results.group.displayName + ']]';
|
||||||
res.render('groups/details', results);
|
res.render('groups/details', results);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ Controllers.reset = function(req, res, next) {
|
|||||||
valid: valid,
|
valid: valid,
|
||||||
displayExpiryNotice: req.session.passwordExpired,
|
displayExpiryNotice: req.session.passwordExpired,
|
||||||
code: req.params.code ? req.params.code : null,
|
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;
|
delete req.session.passwordExpired;
|
||||||
@@ -69,7 +70,8 @@ Controllers.reset = function(req, res, next) {
|
|||||||
} else {
|
} else {
|
||||||
res.render('reset', {
|
res.render('reset', {
|
||||||
code: req.params.code ? req.params.code : null,
|
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.allowLoginWith = '[[login:' + (meta.config.allowLoginWith || 'username-email') + ']]';
|
||||||
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:login]]'}]);
|
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:login]]'}]);
|
||||||
data.error = req.flash('error')[0];
|
data.error = req.flash('error')[0];
|
||||||
|
data.title = '[[pages:login]]';
|
||||||
|
|
||||||
res.render('login', data);
|
res.render('login', data);
|
||||||
};
|
};
|
||||||
@@ -128,6 +131,7 @@ Controllers.register = function(req, res, next) {
|
|||||||
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[register:register]]'}]);
|
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[register:register]]'}]);
|
||||||
data.regFormEntry = [];
|
data.regFormEntry = [];
|
||||||
data.error = req.flash('error')[0];
|
data.error = req.flash('error')[0];
|
||||||
|
data.title = '[[pages:register]]';
|
||||||
|
|
||||||
plugins.fireHook('filter:register.build', {req: req, res: res, templateData: data}, next);
|
plugins.fireHook('filter:register.build', {req: req, res: res, templateData: data}, next);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ popularController.get = function(req, res, next) {
|
|||||||
topics: topics,
|
topics: topics,
|
||||||
'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1,
|
'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1,
|
||||||
rssFeedUrl: nconf.get('relative_path') + '/popular/' + (req.params.term || 'daily') + '.rss',
|
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) {
|
if (!req.uid) {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ recentController.get = function(req, res, next) {
|
|||||||
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
|
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
|
||||||
data.rssFeedUrl = nconf.get('relative_path') + '/recent.rss';
|
data.rssFeedUrl = nconf.get('relative_path') + '/recent.rss';
|
||||||
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[recent:title]]'}]);
|
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) {
|
plugins.fireHook('filter:recent.build', {req: req, res: res, templateData: data}, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ tagsController.getTag = function(req, res, next) {
|
|||||||
topics: results.topics,
|
topics: results.topics,
|
||||||
tag: tag,
|
tag: tag,
|
||||||
nextStart: stop + 1,
|
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);
|
res.render('tag', data);
|
||||||
});
|
});
|
||||||
@@ -76,7 +77,8 @@ tagsController.getTags = function(req, res, next) {
|
|||||||
var data = {
|
var data = {
|
||||||
tags: tags,
|
tags: tags,
|
||||||
nextStart: 100,
|
nextStart: 100,
|
||||||
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]'}])
|
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]'}]),
|
||||||
|
title: '[[pages:tags]]'
|
||||||
};
|
};
|
||||||
res.render('tags', data);
|
res.render('tags', data);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ unreadController.get = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[unread:title]]'}]);
|
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[unread:title]]'}]);
|
||||||
|
data.title = '[[pages:unread]]';
|
||||||
|
|
||||||
res.render('unread', data);
|
res.render('unread', data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ usersController.getOnlineUsers = function(req, res, next) {
|
|||||||
loadmore_display: results.count > 50 ? 'block' : 'hide',
|
loadmore_display: results.count > 50 ? 'block' : 'hide',
|
||||||
users: results.users,
|
users: results.users,
|
||||||
anonymousUserCount: websockets.getOnlineAnonCount(),
|
anonymousUserCount: websockets.getOnlineAnonCount(),
|
||||||
defaultGravatar: user.createGravatarURLFromEmail('')
|
defaultGravatar: user.createGravatarURLFromEmail(''),
|
||||||
|
title: '[[pages:users/online]]'
|
||||||
};
|
};
|
||||||
|
|
||||||
render(req, res, userData, next);
|
render(req, res, userData, next);
|
||||||
@@ -57,18 +58,18 @@ usersController.getOnlineUsers = function(req, res, next) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
usersController.getUsersSortedByPosts = function(req, res, next) {
|
usersController.getUsersSortedByPosts = function(req, res, next) {
|
||||||
usersController.getUsers('users:postcount', 0, 49, req, res, next);
|
usersController.getUsers('users:postcount', '[[pages:users/sort-posts]]', 0, 49, req, res, next);
|
||||||
};
|
};
|
||||||
|
|
||||||
usersController.getUsersSortedByReputation = function(req, res, next) {
|
usersController.getUsersSortedByReputation = function(req, res, next) {
|
||||||
usersController.getUsers('users:reputation', 0, 49, req, res, next);
|
usersController.getUsers('users:reputation', '[[pages:users/sort-reputation]]', 0, 49, req, res, next);
|
||||||
};
|
};
|
||||||
|
|
||||||
usersController.getUsersSortedByJoinDate = function(req, res, next) {
|
usersController.getUsersSortedByJoinDate = function(req, res, next) {
|
||||||
usersController.getUsers('users:joindate', 0, 49, req, res, next);
|
usersController.getUsers('users:joindate', '[[pages:users/latest]]', 0, 49, req, res, next);
|
||||||
};
|
};
|
||||||
|
|
||||||
usersController.getUsers = function(set, start, stop, req, res, next) {
|
usersController.getUsers = function(set, title, start, stop, req, res, next) {
|
||||||
usersController.getUsersAndCount(set, req.uid, start, stop, function(err, data) {
|
usersController.getUsersAndCount(set, req.uid, start, stop, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
@@ -78,7 +79,8 @@ usersController.getUsers = function(set, start, stop, req, res, next) {
|
|||||||
search_display: 'hidden',
|
search_display: 'hidden',
|
||||||
loadmore_display: data.count > (stop - start + 1) ? 'block' : 'hide',
|
loadmore_display: data.count > (stop - start + 1) ? 'block' : 'hide',
|
||||||
users: data.users,
|
users: data.users,
|
||||||
pagination: pagination.create(1, pageCount)
|
pagination: pagination.create(1, pageCount),
|
||||||
|
title: title
|
||||||
};
|
};
|
||||||
userData['route_' + set] = true;
|
userData['route_' + set] = true;
|
||||||
render(req, res, userData, next);
|
render(req, res, userData, next);
|
||||||
@@ -119,7 +121,8 @@ usersController.getUsersForSearch = function(req, res, next) {
|
|||||||
var userData = {
|
var userData = {
|
||||||
search_display: 'block',
|
search_display: 'block',
|
||||||
loadmore_display: 'hidden',
|
loadmore_display: 'hidden',
|
||||||
users: data.users
|
users: data.users,
|
||||||
|
title: '[[pages:users/search]]'
|
||||||
};
|
};
|
||||||
|
|
||||||
render(req, res, userData, next);
|
render(req, res, userData, next);
|
||||||
@@ -195,7 +198,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/configs')(Meta);
|
||||||
require('./meta/themes')(Meta);
|
require('./meta/themes')(Meta);
|
||||||
require('./meta/title')(Meta);
|
|
||||||
require('./meta/js')(Meta);
|
require('./meta/js')(Meta);
|
||||||
require('./meta/css')(Meta);
|
require('./meta/css')(Meta);
|
||||||
require('./meta/sounds')(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 = {
|
var custom_header = {
|
||||||
'plugins': [],
|
'plugins': [],
|
||||||
'authentication': []
|
'authentication': []
|
||||||
@@ -92,7 +92,7 @@ middleware.renderHeader = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
res.locals.config = results.config;
|
res.locals.config = results.config;
|
||||||
|
|
||||||
var data = {
|
var templateValues = {
|
||||||
relative_path: nconf.get('relative_path'),
|
relative_path: nconf.get('relative_path'),
|
||||||
configJSON: JSON.stringify(results.config),
|
configJSON: JSON.stringify(results.config),
|
||||||
user: userData,
|
user: userData,
|
||||||
@@ -104,10 +104,10 @@ middleware.renderHeader = function(req, res, next) {
|
|||||||
env: process.env.NODE_ENV ? true : false,
|
env: process.env.NODE_ENV ? true : false,
|
||||||
};
|
};
|
||||||
|
|
||||||
data.template = {name: res.locals.template};
|
templateValues.template = {name: res.locals.template};
|
||||||
data.template[res.locals.template] = true;
|
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) {
|
middleware.pluginHooks = function(req, res, next) {
|
||||||
async.each(plugins.loadedHooks['filter:router.page'] || [], function(hookObj, next) {
|
async.each(plugins.loadedHooks['filter:router.page'] || [], function(hookObj, next) {
|
||||||
hookObj.method(req, res, next)
|
hookObj.method(req, res, next);
|
||||||
}, function(req, res) {
|
}, function(req, res) {
|
||||||
// If it got here, then none of the subscribed hooks did anything, or there were no hooks
|
// If it got here, then none of the subscribed hooks did anything, or there were no hooks
|
||||||
next();
|
next();
|
||||||
@@ -143,12 +143,12 @@ middleware.checkAccountPermissions = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
user.isAdministrator(req.uid, next);
|
user.isAdministrator(req.uid, next);
|
||||||
}
|
}
|
||||||
], function (err, allowed) {
|
], function (err, allowed) {
|
||||||
if (err || allowed) {
|
if (err || allowed) {
|
||||||
return next(err);
|
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 registrationType = meta.config.registrationType || 'normal';
|
||||||
var templateValues = {
|
var templateValues = {
|
||||||
bootswatchCSS: meta.config['theme:src'],
|
bootswatchCSS: meta.config['theme:src'],
|
||||||
@@ -237,23 +237,18 @@ middleware.renderHeader = function(req, res, callback) {
|
|||||||
templateValues.useCustomJS = parseInt(meta.config.useCustomJS, 10) === 1;
|
templateValues.useCustomJS = parseInt(meta.config.useCustomJS, 10) === 1;
|
||||||
next(null, templateValues.useCustomJS ? meta.config.customJS : '');
|
next(null, templateValues.useCustomJS ? meta.config.customJS : '');
|
||||||
},
|
},
|
||||||
title: function(next) {
|
settings: function(next) {
|
||||||
if (req.uid) {
|
if (req.uid) {
|
||||||
user.getSettings(req.uid, function(err, settings) {
|
user.getSettings(req.uid, next);
|
||||||
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);
|
|
||||||
});
|
|
||||||
} else {
|
} 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) {
|
isAdmin: function(next) {
|
||||||
user.isAdministrator(req.uid, 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) {
|
if (results.user && parseInt(results.user.banned, 10) === 1) {
|
||||||
req.logout();
|
req.logout();
|
||||||
res.redirect('/');
|
return res.redirect('/');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
results.user.isAdmin = results.isAdmin || false;
|
results.user.isAdmin = results.isAdmin || false;
|
||||||
results.user.uid = parseInt(results.user.uid, 10);
|
results.user.uid = parseInt(results.user.uid, 10);
|
||||||
results.user['email:confirmed'] = parseInt(results.user['email:confirmed'], 10) === 1;
|
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.browserTitle = results.title;
|
||||||
templateValues.navigation = results.navigation;
|
templateValues.navigation = results.navigation;
|
||||||
templateValues.metaTags = results.tags.meta;
|
templateValues.metaTags = results.tags.meta;
|
||||||
@@ -364,7 +362,7 @@ middleware.processRender = function(req, res, next) {
|
|||||||
|
|
||||||
if (res.locals.renderHeader || res.locals.renderAdminHeader) {
|
if (res.locals.renderHeader || res.locals.renderAdminHeader) {
|
||||||
var method = res.locals.renderHeader ? middleware.renderHeader : middleware.admin.renderHeader;
|
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) {
|
if (err) {
|
||||||
return fn(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 */
|
/* Rooms */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user