ability to select a default gravatar image (default, identicon,
mystery-man, monsterid, wavatar, retro) or upload a custom image to use
as default gravatar image
v1.18.x
barisusakli 11 years ago
parent 066b1c0d64
commit c9551abc5d

@ -61,21 +61,7 @@ define(['uploader', 'sounds'], function(uploader, sounds) {
}
});
$('#uploadLogoBtn').on('click', function() {
uploader.open(RELATIVE_PATH + '/admin/uploadlogo', {}, 0, function(image) {
$('#logoUrl').val(image);
});
uploader.hideAlerts();
});
$('#uploadFaviconBtn').on('click', function() {
uploader.open(RELATIVE_PATH + '/admin/uploadfavicon', {}, 0, function(icon) {
$('#faviconUrl').val(icon);
});
uploader.hideAlerts();
});
handleUploads();
$('#settings-tab a').click(function (e) {
e.preventDefault();
@ -88,6 +74,19 @@ define(['uploader', 'sounds'], function(uploader, sounds) {
}
};
function handleUploads() {
$('#content input[data-action="upload"]').each(function() {
var uploadBtn = $(this);
uploadBtn.on('click', function() {
uploader.open(uploadBtn.attr('data-route'), {}, 0, function(image) {
$('#' + uploadBtn.attr('data-target')).val(image);
});
uploader.hideAlerts();
});
});
}
Settings.remove = function(key) {
socket.emit('admin.config.remove', key);
};

@ -87,7 +87,20 @@ uploadsController.uploadLogo = function(req, res, next) {
if (validateUpload(res, req, allowedTypes)) {
var filename = 'site-logo' + path.extname(req.files.userPhoto.name);
uploadsController.uploadImage(filename, req, res);
}
}
};
uploadsController.uploadGravatarDefault = function(req, res, next) {
var allowedTypes = ['image/png', 'image/jpeg', 'image/pjpeg', 'image/jpg', 'image/gif'],
er;
if (validateUpload(res, req, allowedTypes)) {
var filename = 'gravatar-default' + path.extname(req.files.userPhoto.name);
uploadsController.uploadImage(filename, req, res);
}
};
module.exports = uploadsController;

@ -237,7 +237,7 @@ var db = require('./database'),
reputation: userData.reputation || 0,
postcount: userData.postcount || 0,
banned: parseInt(userData.banned, 10) === 1,
picture: userData.picture || gravatar.url('', {}, true)
picture: userData.picture || user.createGravatarURLFromEmail('')
};
for (var info in customUserInfo) {

@ -57,6 +57,7 @@ function apiRoutes(app, middleware, controllers) {
app.post('/admin/category/uploadpicture', middleware.authenticate, controllers.admin.uploads.uploadCategoryPicture);
app.post('/admin/uploadfavicon', middleware.authenticate, controllers.admin.uploads.uploadFavicon);
app.post('/admin/uploadlogo', middleware.authenticate, controllers.admin.uploads.uploadLogo);
app.post('/admin/uploadgravatardefault', middleware.authenticate, controllers.admin.uploads.uploadGravatarDefault);
}
function miscRoutes(app, middleware, controllers) {

@ -67,9 +67,7 @@ SocketMeta.updateHeader = function(socket, data, callback) {
uid: 0,
username: '[[global:guest]]',
email: '',
picture: gravatar.url('', {
s: '24'
}, true),
picture: user.createGravatarURLFromEmail(''),
config: {
allowGuestSearching: meta.config.allowGuestSearching
}

@ -210,15 +210,15 @@ var bcrypt = require('bcryptjs'),
};
User.createGravatarURLFromEmail = function(email) {
var options = {
size: '128',
default: 'identicon',
default: meta.config.customGravatarDefaultImage || meta.config.defaultGravatarImage || '',
rating: 'pg'
};
if (!email) {
email = '';
options.forcedefault = 'y';
}
return gravatar.url(email, options, true);
@ -294,7 +294,7 @@ var bcrypt = require('bcryptjs'),
callback(null, {
username: data.username || '[[global:guest]]',
userslug: data.userslug || '',
picture: data.picture || gravatar.url('', {}, true)
picture: data.picture || User.createGravatarURLFromEmail('')
});
});
};

Loading…
Cancel
Save