v1.18.x
barisusakli 8 years ago
parent b91b41dfa3
commit 33e8ecc1f4

@ -29,7 +29,7 @@
"maximumAboutMeLength": 1000, "maximumAboutMeLength": 1000,
"maximumProfileImageSize": 256, "maximumProfileImageSize": 256,
"maximumCoverImageSize": 2048, "maximumCoverImageSize": 2048,
"profileImageDimension": 128, "profileImageDimension": 200,
"requireEmailConfirmation": 0, "requireEmailConfirmation": 0,
"allowProfileImageUploads": 1, "allowProfileImageUploads": 1,
"teaserPost": "last-reply", "teaserPost": "last-reply",

@ -26,7 +26,7 @@ editController.get = function (req, res, callback) {
userData.maximumProfileImageSize = parseInt(meta.config.maximumProfileImageSize, 10); userData.maximumProfileImageSize = parseInt(meta.config.maximumProfileImageSize, 10);
userData.allowProfileImageUploads = parseInt(meta.config.allowProfileImageUploads, 10) === 1; userData.allowProfileImageUploads = parseInt(meta.config.allowProfileImageUploads, 10) === 1;
userData.allowAccountDelete = parseInt(meta.config.allowAccountDelete, 10) === 1; userData.allowAccountDelete = parseInt(meta.config.allowAccountDelete, 10) === 1;
userData.profileImageDimension = parseInt(meta.config.profileImageDimension, 10) || 128; userData.profileImageDimension = parseInt(meta.config.profileImageDimension, 10) || 200;
userData.groups = userData.groups.filter(function (group) { userData.groups = userData.groups.filter(function (group) {
return group && group.userTitleEnabled && !groups.isPrivilegeGroup(group.name) && group.name !== 'registered-users'; return group && group.userTitleEnabled && !groups.isPrivilegeGroup(group.name) && group.name !== 'registered-users';

@ -21,17 +21,6 @@ categoriesController.list = function (req, res, next) {
content: 'website', content: 'website',
}]; }];
var ogImage = meta.config['og:image'] || meta.config['brand:logo'] || '';
if (ogImage) {
if (!ogImage.startsWith('http')) {
ogImage = nconf.get('url') + ogImage;
}
res.locals.metaTags.push({
property: 'og:image',
content: ogImage,
});
}
var categoryData; var categoryData;
async.waterfall([ async.waterfall([
function (next) { function (next) {

@ -1,8 +1,6 @@
'use strict'; 'use strict';
var async = require('async'); var async = require('async');
var nconf = require('nconf');
var validator = require('validator'); var validator = require('validator');
var user = require('../user'); var user = require('../user');
@ -63,10 +61,6 @@ tagsController.getTag = function (req, res, next) {
property: 'og:title', property: 'og:title',
content: tag, content: tag,
}, },
{
property: 'og:url',
content: nconf.get('url') + '/tags/' + tag,
},
]; ];
templateData.topics = topics; templateData.topics = topics;

@ -206,11 +206,6 @@ topicsController.get = function (req, res, callback) {
property: 'og:type', property: 'og:type',
content: 'article', content: 'article',
}, },
{
property: 'og:url',
content: nconf.get('url') + '/topic/' + topicData.slug + (req.params.post_index ? ('/' + req.params.post_index) : ''),
noEscape: true,
},
{ {
property: 'og:image', property: 'og:image',
content: ogImageUrl, content: ogImageUrl,

@ -9,7 +9,7 @@ var plugins = require('../plugins');
module.exports = function (Meta) { module.exports = function (Meta) {
Meta.tags = {}; Meta.tags = {};
Meta.tags.parse = function (meta, link, callback) { Meta.tags.parse = function (req, meta, link, callback) {
async.parallel({ async.parallel({
tags: function (next) { tags: function (next) {
var defaultTags = [{ var defaultTags = [{
@ -120,7 +120,23 @@ module.exports = function (Meta) {
return tag; return tag;
}); });
addDescription(meta); addIfNotExists(meta, 'property', 'og:title', Meta.config.title || 'NodeBB');
var ogUrl = nconf.get('url') + req.path;
addIfNotExists(meta, 'property', 'og:url', ogUrl);
addIfNotExists(meta, 'name', 'description', Meta.config.description);
addIfNotExists(meta, 'property', 'og:description', Meta.config.description);
var ogImage = Meta.config['og:image'] || Meta.config['brand:logo'] || '';
if (ogImage && !ogImage.startsWith('http')) {
ogImage = nconf.get('url') + ogImage;
}
addIfNotExists(meta, 'property', 'og:image', ogImage);
if (ogImage) {
addIfNotExists(meta, 'property', 'og:image:width', 200);
addIfNotExists(meta, 'property', 'og:image:height', 200);
}
link = results.links.concat(link || []); link = results.links.concat(link || []);
@ -131,19 +147,20 @@ module.exports = function (Meta) {
}); });
}; };
function addDescription(meta) { function addIfNotExists(meta, keyName, tagName, value) {
var hasDescription = false; var exists = false;
meta.forEach(function (tag) { meta.forEach(function (tag) {
if (tag.name === 'description') { if (tag[keyName] === tagName) {
hasDescription = true; exists = true;
} }
}); });
if (!hasDescription && Meta.config.description) { if (!exists && value) {
meta.push({ var data = {
name: 'description', content: validator.escape(String(value)),
content: validator.escape(String(Meta.config.description)), };
}); data[keyName] = tagName;
meta.push(data);
} }
} }
}; };

@ -97,7 +97,7 @@ module.exports = function (middleware) {
db.get('uid:' + req.uid + ':confirm:email:sent', next); db.get('uid:' + req.uid + ':confirm:email:sent', next);
}, },
navigation: async.apply(navigation.get), navigation: async.apply(navigation.get),
tags: async.apply(meta.tags.parse, res.locals.metaTags, res.locals.linkTags), tags: async.apply(meta.tags.parse, req, res.locals.metaTags, res.locals.linkTags),
banned: async.apply(user.isBanned, req.uid), banned: async.apply(user.isBanned, req.uid),
banReason: async.apply(user.getBannedReason, req.uid), banReason: async.apply(user.getBannedReason, req.uid),
}, next); }, next);

@ -154,7 +154,7 @@ module.exports = function (User) {
function (path, next) { function (path, next) {
picture.path = path; picture.path = path;
var imageDimension = parseInt(meta.config.profileImageDimension, 10) || 128; var imageDimension = parseInt(meta.config.profileImageDimension, 10) || 200;
image.resizeImage({ image.resizeImage({
path: picture.path, path: picture.path,
extension: extension, extension: extension,

@ -91,7 +91,7 @@
<div class="form-group"> <div class="form-group">
<label for="profileImageDimension">[[admin/settings/uploads:profile-image-dimension]]</label> <label for="profileImageDimension">[[admin/settings/uploads:profile-image-dimension]]</label>
<input id="profileImageDimension" type="text" class="form-control" data-field="profileImageDimension" placeholder="128" /> <input id="profileImageDimension" type="text" class="form-control" data-field="profileImageDimension" placeholder="200" />
<p class="help-block"> <p class="help-block">
[[admin/settings/uploads:profile-image-dimension-help]] [[admin/settings/uploads:profile-image-dimension-help]]
</p> </p>

Loading…
Cancel
Save