mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 20:17:32 +02:00
Fixes #3852
Added meta data to user profile pages, and also added noEscape option to meta tag input. If set, validator escaping won't be run on that value.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
var nconf = require('nconf'),
|
||||
async = require('async'),
|
||||
S = require('string'),
|
||||
|
||||
user = require('../../user'),
|
||||
posts = require('../../posts'),
|
||||
@@ -80,6 +81,42 @@ profileController.get = function(req, res, callback) {
|
||||
userData.profileviews = 1;
|
||||
}
|
||||
|
||||
var plainAboutMe = S(userData.aboutme).decodeHTMLEntities().stripTags().s;
|
||||
|
||||
res.locals.metaTags = [
|
||||
{
|
||||
name: "title",
|
||||
content: userData.fullname || userData.username
|
||||
},
|
||||
{
|
||||
name: "description",
|
||||
content: plainAboutMe
|
||||
},
|
||||
{
|
||||
property: 'og:title',
|
||||
content: userData.fullname || userData.username
|
||||
},
|
||||
{
|
||||
property: 'og:description',
|
||||
content: plainAboutMe
|
||||
}
|
||||
];
|
||||
|
||||
if (userData.picture) {
|
||||
res.locals.metaTags.push(
|
||||
{
|
||||
property: 'og:image',
|
||||
content: userData.picture,
|
||||
noEscape: true
|
||||
},
|
||||
{
|
||||
property: "og:image:url",
|
||||
content: userData.picture,
|
||||
noEscape: true
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
plugins.fireHook('filter:user.account', {userData: userData, uid: req.uid}, next);
|
||||
}
|
||||
], function(err, results) {
|
||||
|
||||
@@ -203,15 +203,18 @@ topicsController.get = function(req, res, callback) {
|
||||
},
|
||||
{
|
||||
property: "og:url",
|
||||
content: nconf.get('url') + '/topic/' + topicData.slug + (req.params.post_index ? ('/' + req.params.post_index) : '')
|
||||
content: nconf.get('url') + '/topic/' + topicData.slug + (req.params.post_index ? ('/' + req.params.post_index) : ''),
|
||||
noEscape: true
|
||||
},
|
||||
{
|
||||
property: 'og:image',
|
||||
content: ogImageUrl
|
||||
content: ogImageUrl,
|
||||
noEscape: true
|
||||
},
|
||||
{
|
||||
property: "og:image:url",
|
||||
content: ogImageUrl
|
||||
content: ogImageUrl,
|
||||
noEscape: true
|
||||
},
|
||||
{
|
||||
property: "article:published_time",
|
||||
|
||||
@@ -32,10 +32,12 @@ module.exports = function(Meta) {
|
||||
content: Meta.config.keywords || ''
|
||||
}, {
|
||||
name: 'msapplication-badge',
|
||||
content: 'frequency=30; polling-uri=' + nconf.get('url') + '/sitemap.xml'
|
||||
content: 'frequency=30; polling-uri=' + nconf.get('url') + '/sitemap.xml',
|
||||
noEscape: true
|
||||
}, {
|
||||
name: 'msapplication-square150x150logo',
|
||||
content: Meta.config['brand:logo'] || ''
|
||||
content: Meta.config['brand:logo'] || '',
|
||||
noEscape: true
|
||||
}];
|
||||
plugins.fireHook('filter:meta.getMetaTags', defaultTags, next);
|
||||
},
|
||||
@@ -89,7 +91,10 @@ module.exports = function(Meta) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
tag.content = validator.escape(tag.content);
|
||||
if (!tag.noEscape) {
|
||||
tag.content = validator.escape(tag.content);
|
||||
}
|
||||
|
||||
return tag;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user