diff --git a/public/less/admin/manage/users.less b/public/less/admin/manage/users.less
index 6c7d367a1a..6ad08afcfb 100644
--- a/public/less/admin/manage/users.less
+++ b/public/less/admin/manage/users.less
@@ -17,9 +17,11 @@
max-width: 125px;
min-width: 125px;
- img {
+ img, .user-icon {
width:80px;
height:80px;
+ line-height: 80px;
+ font-size: 4rem;
}
a {
diff --git a/public/less/generics.less b/public/less/generics.less
index f9ef30469a..643f9bc20e 100644
--- a/public/less/generics.less
+++ b/public/less/generics.less
@@ -29,10 +29,13 @@
background: #eee;
}
- img {
+ img, .user-icon {
float: left;
- max-width: 36px;
- padding-right: 1rem;
+ height: 36px;
+ width: 36px;
+ margin-right: 1rem;
+ line-height: 36px;
+ font-size: 1.8rem;
}
span {
@@ -41,3 +44,17 @@
}
}
}
+
+.user-icon {
+ display: inline-block;
+ text-align: center;
+ color: @gray-lighter;
+ font-weight: normal;
+
+ &:before {
+ content: '';
+ display: inline-block;
+ height: 100%;
+ vertical-align: middle;
+ }
+}
\ No newline at end of file
diff --git a/public/src/app.js b/public/src/app.js
index 77b58014ed..2114c6b627 100644
--- a/public/src/app.js
+++ b/public/src/app.js
@@ -138,7 +138,9 @@ app.cacheBuster = null;
username: app.user.username,
userslug: app.user.userslug,
picture: app.user.picture,
- status: app.user.status
+ status: app.user.status,
+ 'icon:bgColor': app.user['icon:bgColor'],
+ 'icon:text': app.user['icon:text']
}, function(err) {
if (err) {
app.alertError(err.message);
@@ -158,7 +160,7 @@ app.cacheBuster = null;
}
app.createUserTooltips = function() {
- $('img[title].teaser-pic,img[title].user-img').each(function() {
+ $('img[title].teaser-pic,img[title].user-img,div.user-icon').each(function() {
$(this).tooltip({
placement: 'top',
title: $(this).attr('title')
diff --git a/public/src/client/topic/browsing.js b/public/src/client/topic/browsing.js
index b80d93d323..2a4f8d791e 100644
--- a/public/src/client/topic/browsing.js
+++ b/public/src/client/topic/browsing.js
@@ -71,8 +71,9 @@ define('forum/topic/browsing', function() {
if (!user.userslug) {
return;
}
+ console.log(user);
var browsingList = $('[component="topic/browsing/list"]');
- var userEl = createUserIcon(user.uid, user.picture, user.userslug, user.username);
+ var userEl = createUserIcon(user.uid, user.picture, user.userslug, user.username, user['icon:bgColor'], user['icon:text']);
var isSelf = parseInt(user.uid, 10) === parseInt(app.user.uid, 10);
if (isSelf) {
browsingList.prepend(userEl);
@@ -85,9 +86,14 @@ define('forum/topic/browsing', function() {
});
}
- function createUserIcon(uid, picture, userslug, username) {
+ function createUserIcon(uid, picture, userslug, username, iconBg, iconText) {
if (!$('[component="topic/browsing/list"]').find('[data-uid="' + uid + '"]').length) {
- return $('

');
+ console.log(iconBg, iconText);
+ var imgOrIcon = picture ?
+ '
' :
+ '' + iconText + '
';
+
+ return $('');
}
}
diff --git a/public/src/modules/helpers.js b/public/src/modules/helpers.js
index 2700aab137..490dad55e4 100644
--- a/public/src/modules/helpers.js
+++ b/public/src/modules/helpers.js
@@ -161,6 +161,14 @@
return locale.replace('_', '-');
};
+ helpers.renderTopicImage = function(topicObj) {
+ if (topicObj.thumb) {
+ return '
';
+ } else {
+ return '
';
+ }
+ };
+
exports.register = function() {
var templates;
diff --git a/src/groups/membership.js b/src/groups/membership.js
index 663b3d7b14..a5b7b558c0 100644
--- a/src/groups/membership.js
+++ b/src/groups/membership.js
@@ -240,7 +240,7 @@ module.exports = function(Groups) {
return next(err);
}
- user.getUsersFields(uids, ['uid', 'username', 'picture', 'userslug'], next);
+ user.getUsersFields(uids, ['uid', 'username', 'picture', 'userslug', 'icon:bgColor', 'icon:text'], next);
});
}, callback);
};
diff --git a/src/middleware/middleware.js b/src/middleware/middleware.js
index 6049970468..45b948437d 100644
--- a/src/middleware/middleware.js
+++ b/src/middleware/middleware.js
@@ -244,7 +244,7 @@ middleware.renderHeader = function(req, res, data, callback) {
},
user: function(next) {
if (req.uid) {
- user.getUserFields(req.uid, ['username', 'userslug', 'email', 'picture', 'status', 'email:confirmed', 'banned'], next);
+ user.getUserFields(req.uid, ['username', 'userslug', 'email', 'picture', 'status', 'email:confirmed', 'banned', 'icon:bgColor', 'icon:text'], next);
} else {
next(null, {
username: '[[global:guest]]',
diff --git a/src/posts/summary.js b/src/posts/summary.js
index eaa1f5b2ef..7fadb0c6d3 100644
--- a/src/posts/summary.js
+++ b/src/posts/summary.js
@@ -46,7 +46,7 @@ module.exports = function(Posts) {
async.parallel({
users: function(next) {
- user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture'], next);
+ user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'icon:bgColor', 'icon:text'], next);
},
topicsAndCategories: function(next) {
getTopicAndCategories(topicKeys, next);
diff --git a/src/posts/user.js b/src/posts/user.js
index 8b40d8bd73..4badf60650 100644
--- a/src/posts/user.js
+++ b/src/posts/user.js
@@ -20,7 +20,7 @@ module.exports = function(Posts) {
user.getMultipleUserSettings(uids, next);
},
userData: function(next) {
- user.getUsersFields(uids, ['uid', 'username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status'], next);
+ user.getUsersFields(uids, ['uid', 'username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status', 'icon:bgColor', 'icon:text'], next);
},
online: function(next) {
require('../socket.io').isUsersOnline(uids, next);
@@ -55,7 +55,7 @@ module.exports = function(Posts) {
userData.reputation = userData.reputation || 0;
userData.postcount = userData.postcount || 0;
userData.banned = parseInt(userData.banned, 10) === 1;
- userData.picture = userData.picture || user.createGravatarURLFromEmail('');
+ userData.picture = userData.picture || '';
async.parallel({
signature: function(next) {
diff --git a/src/socket.io/index.js b/src/socket.io/index.js
index ba1acc5408..b0075c99d2 100644
--- a/src/socket.io/index.js
+++ b/src/socket.io/index.js
@@ -281,7 +281,7 @@ Sockets.getUsersInRoom = function (uid, roomName, start, stop, callback) {
if (!uids.length) {
return callback(null, {users: [], total: 0 , room: roomName});
}
- user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'status'], function(err, users) {
+ user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'status', 'icon:bgColor', 'icon:text'], function(err, users) {
if (err) {
return callback(err);
}
diff --git a/src/socket.io/meta.js b/src/socket.io/meta.js
index 7134af36c7..0381569472 100644
--- a/src/socket.io/meta.js
+++ b/src/socket.io/meta.js
@@ -1,7 +1,6 @@
'use strict';
var nconf = require('nconf'),
- gravatar = require('gravatar'),
winston = require('winston'),
validator = require('validator'),
diff --git a/src/socket.io/user/picture.js b/src/socket.io/user/picture.js
index cc424f2b74..f7c4d61739 100644
--- a/src/socket.io/user/picture.js
+++ b/src/socket.io/user/picture.js
@@ -18,12 +18,12 @@ module.exports = function(SocketUser) {
var type = data.type;
- if (type === 'gravatar') {
- type = 'gravatarpicture';
+ if (type === 'default') {
+ type = null;
} else if (type === 'uploaded') {
type = 'uploadedpicture';
} else {
- return callback(new Error('[[error:invalid-image-type, ' + ['gravatar', 'uploadedpicture'].join(', ') + ']]'));
+ return callback(new Error('[[error:invalid-image-type, ' + ['default', 'uploadedpicture'].join(', ') + ']]'));
}
async.waterfall([
@@ -31,6 +31,9 @@ module.exports = function(SocketUser) {
SocketUser.isAdminOrSelf(socket, data.uid, next);
},
function (next) {
+ if (!type) {
+ next(null, '');
+ }
user.getUserField(data.uid, type, next);
},
function (picture, next) {
diff --git a/src/topics.js b/src/topics.js
index c18314a03d..c0129b41cb 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -124,7 +124,7 @@ var async = require('async'),
async.parallel({
users: function(next) {
- user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture'], next);
+ user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'icon:bgColor', 'icon:text'], next);
},
categories: function(next) {
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'bgColor', 'color', 'disabled'], next);
diff --git a/src/user.js b/src/user.js
index e9555b6d5e..5f8a5c4d6c 100644
--- a/src/user.js
+++ b/src/user.js
@@ -36,6 +36,7 @@ var async = require('async'),
require('./user/picture')(User);
require('./user/approval')(User);
require('./user/invite')(User);
+ require('./user/icon')(User);
User.updateLastOnlineTime = function(uid, callback) {
callback = callback || function() {};
@@ -93,7 +94,7 @@ var async = require('async'),
};
User.getUsers = function(uids, uid, callback) {
- var fields = ['uid', 'username', 'userslug', 'picture', 'status', 'banned', 'joindate', 'postcount', 'reputation', 'email:confirmed'];
+ var fields = ['uid', 'username', 'userslug', 'picture', 'icon:bgColor', 'icon:text', 'status', 'banned', 'joindate', 'postcount', 'reputation', 'email:confirmed'];
plugins.fireHook('filter:users.addFields', {fields: fields}, function(err, data) {
if (err) {
return callback(err);
diff --git a/src/user/create.js b/src/user/create.js
index ed04c2cd75..e761885ead 100644
--- a/src/user/create.js
+++ b/src/user/create.js
@@ -24,7 +24,6 @@ module.exports = function(User) {
if (err) {
return callback(err);
}
- var gravatar = User.createGravatarURLFromEmail(data.email);
var timestamp = data.timestamp || Date.now();
var userData = {
@@ -32,8 +31,7 @@ module.exports = function(User) {
'userslug': data.userslug,
'email': data.email,
'joindate': timestamp,
- 'picture': gravatar,
- 'gravatarpicture': gravatar,
+ 'picture': '',
'fullname': '',
'location': '',
'birthday': '',
@@ -128,7 +126,8 @@ module.exports = function(User) {
async.apply(User.reset.updateExpiry, userData.uid)
], next);
});
- }
+ },
+ async.apply(User.icon.generate, userData.uid)
], next);
},
function(results, next) {
diff --git a/src/user/data.js b/src/user/data.js
index 6ada002bfa..e32be24f6e 100644
--- a/src/user/data.js
+++ b/src/user/data.js
@@ -44,7 +44,6 @@ module.exports = function(User) {
if (fields.indexOf('picture') !== -1) {
addField('email');
- addField('gravatarpicture');
addField('uploadedpicture');
}
@@ -102,15 +101,11 @@ module.exports = function(User) {
user.uid = 0;
user.username = '[[global:guest]]';
user.userslug = '';
- user.picture = User.createGravatarURLFromEmail('');
+ user.picture = '';
}
- if (user.picture) {
- if (user.picture === user.uploadedpicture) {
- user.picture = user.uploadedpicture = user.picture.startsWith('http') ? user.picture : nconf.get('relative_path') + user.picture;
- } else {
- user.picture = User.createGravatarURLFromEmail(user.email);
- }
+ if (user.picture && user.picture === user.uploadedpicture) {
+ user.picture = user.uploadedpicture = user.picture.startsWith('http') ? user.picture : nconf.get('relative_path') + user.picture;
}
for(var i=0; i
+
+
+ {group.members.icon:text}
+
{group.members.username}
diff --git a/src/views/admin/manage/users.tpl b/src/views/admin/manage/users.tpl
index 275e1d6255..708f9c13fa 100644
--- a/src/views/admin/manage/users.tpl
+++ b/src/views/admin/manage/users.tpl
@@ -51,7 +51,11 @@
+

+
+
{users.icon:text}
+
diff --git a/tests/user.js b/tests/user.js
index 82659ada90..8fb0ab6ada 100644
--- a/tests/user.js
+++ b/tests/user.js
@@ -282,6 +282,23 @@ describe('User', function() {
});
});
+ describe('User.icon.generate()', function() {
+ it('should add icon text and bgColor fields to user hash', function(done) {
+ var backgrounds = ['#AB4642', '#DC9656', '#A1B56C', '#7CAFC2', '#BA8BAF', '#A16946'];
+
+ User.icon.generate(1, function(err) {
+ assert.ifError(err);
+
+ User.getUserFields(1, ['icon:text', 'icon:bgColor'], function(err, fields) {
+ assert.strictEquals('J', fields[0]);
+ assert(backgrounds.indexOf(fields[1]) !== -1);
+
+ done();
+ });
+ });
+ });
+ });
+
after(function() {
db.flushdb();
});