mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
Merge pull request #454 from bengott/avatar-tweaks
Update to use bengott:avatar package for user avatars
This commit is contained in:
commit
29495788e8
12 changed files with 21 additions and 78 deletions
|
@ -37,6 +37,11 @@ sacha:spin@2.0.4
|
|||
sacha:juice
|
||||
chuangbo:marked@0.3.3
|
||||
percolatestudio:synced-cron@0.1.1
|
||||
npm-container
|
||||
matb33:collection-hooks
|
||||
djedi:sanitize-html
|
||||
rajit:bootstrap3-datepicker
|
||||
bengott:avatar
|
||||
|
||||
# Telescope Packages
|
||||
|
||||
|
@ -57,12 +62,6 @@ telescope-email
|
|||
telescope-update-prompt
|
||||
telescope-notifications
|
||||
telescope-kadira
|
||||
|
||||
|
||||
npm-container
|
||||
matb33:collection-hooks
|
||||
djedi:sanitize-html
|
||||
rajit:bootstrap3-datepicker
|
||||
telescope-update-prompt
|
||||
telescope-notifications
|
||||
telescope-kadira
|
||||
|
@ -70,5 +69,4 @@ telescope-kadira
|
|||
# Accounts Templates
|
||||
service-configuration
|
||||
accounts-ui
|
||||
splendido:accounts-templates-unstyled
|
||||
|
||||
splendido:accounts-templates-unstyled
|
|
@ -12,6 +12,7 @@ application-configuration@1.0.2
|
|||
autoupdate@1.1.1
|
||||
backbone@1.0.0
|
||||
base64@1.0.0
|
||||
bengott:avatar@0.1.0
|
||||
binary-heap@1.0.0
|
||||
blaze-tools@1.0.0
|
||||
blaze@2.0.1
|
||||
|
@ -41,6 +42,8 @@ iron:core@0.3.4
|
|||
iron:dynamic-template@0.4.1
|
||||
iron:layout@0.4.1
|
||||
iron:router@0.9.3
|
||||
jparker:crypto-core@0.1.0
|
||||
jparker:crypto-md5@0.1.1
|
||||
jquery@1.0.0
|
||||
json@1.0.0
|
||||
less@1.0.9
|
||||
|
@ -93,6 +96,7 @@ splendido:accounts-templates-core@0.9.7
|
|||
splendido:accounts-templates-unstyled@0.9.7
|
||||
srp@1.0.0
|
||||
standard-app-packages@1.0.2
|
||||
stylus@1.0.4
|
||||
telescope-api@0.0.0
|
||||
telescope-base@0.0.0
|
||||
telescope-daily@0.0.0
|
||||
|
|
|
@ -40,3 +40,7 @@ Statuses={
|
|||
approved: 2,
|
||||
rejected: 3
|
||||
};
|
||||
|
||||
Avatar.options = {
|
||||
emailHashProperty: 'email_hash'
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<span>{{i18n "downvote"}}</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="user-avatar">{{>avatar userId=userId class=""}}</div>
|
||||
<div class="user-avatar">{{>avatar userId=userId cssClass="avatar circle"}}</div>
|
||||
<div class="comment-main">
|
||||
<div class="comment-meta">
|
||||
<a class="comment-username" href="{{profileUrl}}">{{authorName}}</a>
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
<template name="avatar">
|
||||
<img class="{{cssClass}}" src="{{url}}"/>
|
||||
</template>
|
|
@ -1,19 +0,0 @@
|
|||
Template[getTemplate('avatar')].helpers({
|
||||
url: function () {
|
||||
if (this.user) {
|
||||
return getAvatarUrl(this.user);
|
||||
}
|
||||
else if (this.userId) {
|
||||
var user = Meteor.users.findOne(this.userId);
|
||||
if (user) {
|
||||
return getAvatarUrl(user);
|
||||
}
|
||||
}
|
||||
},
|
||||
cssClass: function () {
|
||||
if (this.class) {
|
||||
return this.class;
|
||||
}
|
||||
return 'user-avatar';
|
||||
}
|
||||
});
|
|
@ -19,9 +19,10 @@ Template[getTemplate('postContent')].helpers({
|
|||
return moment(time).format("MMMM Do, h:mm:ss a");
|
||||
},
|
||||
userAvatar: function(){
|
||||
// THIS FUNCTION IS DEPRECATED -- package bengott:avatar is used instead.
|
||||
var author = Meteor.users.findOne(this.userId, {reactive: false});
|
||||
if(!!author)
|
||||
return getAvatarUrl(author);
|
||||
return getAvatarUrl(author); // ALSO DEPRECATED
|
||||
},
|
||||
inactiveClass: function(){
|
||||
return (isAdmin(Meteor.user()) && this.inactive) ? i18n.t('inactive') : "";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template name="user_item">
|
||||
<tr class="user">
|
||||
<td>{{>avatar user=this}}</td>
|
||||
<td>{{>avatar user=this cssClass="avatar circle"}}</td>
|
||||
<td>
|
||||
<a href="{{getProfileUrl}}">{{displayName}}</a>
|
||||
<br/>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="user-profile grid grid-module">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2">{{>avatar user=this}}</td>
|
||||
<td colspan="2">{{>avatar user=this cssClass="avatar large circle"}}</td>
|
||||
</tr>
|
||||
{{#if isAdmin}}
|
||||
<tr>
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
// super, super simple
|
||||
Gravatar = {
|
||||
getGravatar: function(user, options) {
|
||||
var options = options || {};
|
||||
|
||||
var protocol = options.secure ? 'https' : 'http';
|
||||
delete options.secure;
|
||||
var hash = !!user.email_hash ? user.email_hash : ''; // if hash not available, just pass empty string
|
||||
var url = protocol + '://www.gravatar.com/avatar/' + hash;
|
||||
|
||||
function retinizeSize(size) {
|
||||
// return the optimal image size for retina display or zoomed in view.
|
||||
size = size ? size : 80; // Default size to 80.
|
||||
return window.devicePixelRatio ? Math.ceil(size * Math.max(1, window.devicePixelRatio)) : size; // If devicePixelRation Available, check for retina
|
||||
}
|
||||
options.s = retinizeSize(options.s);
|
||||
|
||||
var params = _.map(options, function(val, key) { return key + "=" + val;}).join('&');
|
||||
if (params !== '')
|
||||
url += '?' + params;
|
||||
|
||||
return url;
|
||||
}
|
||||
};
|
22
lib/users.js
22
lib/users.js
|
@ -72,15 +72,6 @@ getGitHubName = function(user){
|
|||
getTwitterNameById = function(userId){
|
||||
return getTwitterName(Meteor.users.findOne(userId));
|
||||
};
|
||||
getSignupMethod = function(user){
|
||||
if(user.services && user.services.twitter){
|
||||
return 'twitter';
|
||||
}else if(user.services && user.services.facebook){
|
||||
return 'facebook';
|
||||
}else{
|
||||
return 'regular';
|
||||
}
|
||||
};
|
||||
getEmail = function(user){
|
||||
if(user.profile && user.profile.email){
|
||||
return user.profile.email;
|
||||
|
@ -93,17 +84,8 @@ getEmailHash = function(user){
|
|||
return CryptoJS.MD5(getEmail(user).trim().toLowerCase()).toString()
|
||||
};
|
||||
getAvatarUrl = function(user) {
|
||||
if (getSignupMethod(user) === 'twitter') {
|
||||
return user.services.twitter.profile_image_url.replace('_normal.', '_200x200.'); // use larger image (200x200 is smallest custom option)
|
||||
}
|
||||
if (getSignupMethod(user) === 'facebook') {
|
||||
return 'http://graph.facebook.com/'+user.services.facebook.id+'/picture?type=large'; // use larger image (~200x200)
|
||||
}
|
||||
return Gravatar.getGravatar(user, {
|
||||
d: 'http://demo.telesc.pe/img/default_avatar.png',
|
||||
s: 80,
|
||||
secure: location.protocol === 'https:'
|
||||
});
|
||||
console.log('FUNCTION getAvatarUrl() IS DEPRECATED -- package bengott:avatar is used instead.')
|
||||
return Avatar.getUrl(user);
|
||||
};
|
||||
getCurrentUserEmail = function(){
|
||||
return Meteor.user() ? getEmail(Meteor.user()) : '';
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.5 KiB |
Loading…
Add table
Reference in a new issue