Skip to content

Commit b250c51

Browse files
committed
Merge branch 'master' of github.com:RocketChat/Rocket.Chat
2 parents 1dba6c1 + 94fbdf0 commit b250c51

File tree

11 files changed

+86
-42
lines changed

11 files changed

+86
-42
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ We are experimenting [transifex](https://www.transifex.com/organization/rocketch
121121

122122
### Community
123123

124-
Join the the converation at [Twitter](http://twitter.com/RocketChatApp), [Facebook](https://www.facebook.com/RocketChatApp) or [Google Plus](https://plus.google.com/+RocketChatApp)
124+
Join the the conversation at [Twitter](http://twitter.com/RocketChatApp), [Facebook](https://www.facebook.com/RocketChatApp) or [Google Plus](https://plus.google.com/+RocketChatApp)
125125

126126
### License
127127

client/stylesheets/base.less

+41-28
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,29 @@ a.github-fork {
671671
min-height: 20px;
672672
min-width: 20px;
673673
display: block;
674+
position: relative;
674675
background-color: transparent;
675676
background-size: cover;
676677
background-repeat: no-repeat;
677678
background-position: center;
678679
}
680+
681+
&[initials]:before {
682+
content: attr(initials);
683+
position: absolute;
684+
position: absolute;
685+
font-size: 22px;
686+
text-align: center;
687+
width: 100%;
688+
height: 100%;
689+
color: #FFF;
690+
display: flex;
691+
align-items: center;
692+
justify-content: center;
693+
font-family: Helvetica;
694+
text-transform: uppercase;
695+
font-weight: bold;
696+
}
679697
}
680698

681699
#rocket-chat {
@@ -1728,11 +1746,6 @@ a.github-fork {
17281746
display: block;
17291747
width: 40px;
17301748
height: 40px;
1731-
background-color: #FFF;
1732-
border-radius: 2px;
1733-
background-image: url(/images/no_picture.png);
1734-
background-size: 100% auto;
1735-
background-position: 50% 50%;
17361749
}
17371750
}
17381751

@@ -2063,13 +2076,13 @@ a.github-fork {
20632076

20642077
.user-image-status(@color) {
20652078
.avatar{
2066-
&:after, &:before {
2079+
&:after {
20672080
background-color: darken(@color, 5%);
20682081
}
20692082
}
20702083
}
20712084

2072-
@user-image-square: 30px;
2085+
@user-image-square: 20px;
20732086
.user-image {
20742087
margin: 4px;
20752088
height: @user-image-square;
@@ -2079,29 +2092,34 @@ a.github-fork {
20792092
font-size: 12px;
20802093
position: relative;
20812094
display: inline-table;
2095+
.avatar {
2096+
&:before {
2097+
font-size: 10px;
2098+
}
2099+
}
20822100
&:hover,
20832101
&.selected {
20842102
.avatar{
20852103
&:after {
20862104
.transform(scaleX(1))
20872105
}
2088-
.status-offline & {
2089-
&:after, &:before {
2106+
.status-offline {
2107+
&:after {
20902108
background-color: @status-offline;
20912109
}
20922110
}
2093-
.status-online & {
2094-
&:after, &:before {
2111+
.status-online {
2112+
&:after {
20952113
background-color: @status-online;
20962114
}
20972115
}
2098-
.status-away & {
2099-
&:after, &:before {
2116+
.status-away {
2117+
&:after {
21002118
background-color: @status-away;
21012119
}
21022120
}
2103-
.status-busy & {
2104-
&:after, &:before {
2121+
.status-busy {
2122+
&:after {
21052123
background-color: @status-busy;
21062124
}
21072125
}
@@ -2112,22 +2130,14 @@ a.github-fork {
21122130
}
21132131
.avatar {
21142132
overflow: visible;
2115-
&:after, &:before {
2133+
&:after {
21162134
content: " ";
2117-
width: 100%;
2118-
height: 2px;
2135+
height: 100%;
2136+
width: 3px;
21192137
position: absolute;
21202138
z-index: 1;
2121-
left: 0px;
2122-
}
2123-
&:after{
2124-
bottom: -4px;
2125-
.transform(scaleX(0));
2126-
.transform-origin(50%, 50%);
2127-
.transition(transform .15s ease-out .02s);
2128-
}
2129-
&:before{
2130-
bottom: -3px;
2139+
left: -7px;
2140+
bottom: 0px;
21312141
}
21322142
.avatar-initials {
21332143
line-height: @user-image-square;
@@ -2755,6 +2765,9 @@ a.github-fork {
27552765
cursor: pointer;
27562766
}
27572767
}
2768+
.avatar:before {
2769+
font-size: 44px;
2770+
}
27582771
}
27592772

27602773
@media all and(max-width: 1100px) {

client/views/app/sideNav/userStatus.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="info status-{{status}}">
55
{{#if username}}
66
<div class="thumb" data-status='{{visualStatus}}'>
7-
{{> avatar userId=_id}}
7+
{{> avatar username=username}}
88
</div>
99
<div class="data">
1010
<div class="wrp">

client/views/avatar/avatar.coffee

+22-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
1+
colors = ['#F44336','#E91E63','#9C27B0','#673AB7','#3F51B5','#2196F3','#03A9F4','#00BCD4','#009688','#4CAF50','#8BC34A','#CDDC39','#FFC107','#FF9800','#FF5722','#795548','#9E9E9E','#607D8B']
12
Template.avatar.helpers
2-
dimensions: ->
3-
return {
4-
width: 40
5-
height: 40
6-
}
3+
initials: ->
4+
username = this.username or ''
5+
username = username.replace(/[^A-Za-z0-9]/g, '.').replace(/\.+/g, '.').replace(/(^\.)|(\.$)/g, '')
6+
usernameParts = username.split('.')
7+
if usernameParts.length > 1
8+
return _.first(usernameParts)[0] + _.last(usernameParts)[0]
9+
10+
return username.replace(/[^A-Za-z0-9]/g, '').substr(0, 2)
11+
12+
color: ->
13+
username = this.username or ''
14+
position = username.length % colors.length
15+
return colors[position]
716

817
imageUrl: ->
18+
if this.preventImage?
19+
return
20+
921
username = this.username
1022
random = Session.get('AvatarRandom')
1123
if not username? and this.userId?
1224
username = Meteor.users.findOne(this.userId)?.username
13-
url = "#{Meteor.absoluteUrl()}avatar/#{username}.jpg?_dc=#{random}"
14-
return url
25+
26+
if not username?
27+
return
28+
29+
return "background-image:url(#{Meteor.absoluteUrl()}avatar/#{username}.jpg?_dc=#{random});"

client/views/avatar/avatar.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template name="avatar">
2-
<div class="avatar">
3-
<div class="avatar-image" style="background-image:url({{imageUrl}});">
2+
<div class="avatar" initials="{{initials}}" style="background-color:{{color}}">
3+
<div class="avatar-image" style="{{imageUrl}}">
44
</div>
55
</div>
66
</template>

client/views/avatar/avatarPrompt.coffee

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Template.avatarPrompt.helpers
2020
upload: ->
2121
return Template.instance().upload.get()
2222

23+
username: ->
24+
return Meteor.user()?.username
25+
2326

2427
Template.avatarPrompt.events
2528
'click .select-service': (e) ->

client/views/avatar/avatarPrompt.html

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ <h2>{{_ "avatar.Select_an_avatar"}}</h2>
2727
<div class='field'>
2828
<div class="avatar-suggestions">
2929
{{#if suggestions.ready}}
30+
<div class="avatar-suggestion-item">
31+
{{> avatar username=username preventImage='true'}}
32+
{{#with service='initials'}}
33+
<button type="button" class="button primary select-service">{{_ "avatar.Use_initials_avatar" }}</button>
34+
{{/with}}
35+
</div>
36+
3037
{{> avatarSuggestion suggestions.avatars.gravatar}}
3138
{{> avatarSuggestion suggestions.avatars.facebook}}
3239
{{> avatarSuggestion suggestions.avatars.google}}

client/views/login/social.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template name="social">
22
<div class="social">
3-
<h4>{{_ "footer.Join_the_Community"}}</h4>
43
{{#if withParagraph}}
4+
<h4>{{_ "footer.Join_the_Community"}}</h4>
55
<p>{{_ "footer.Follow_social_profiles"}}</p>
66
{{/if}}
77
<nav>

i18n/en.i18n.json

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
},
160160
"avatar": {
161161
"Use_service_avatar": "Use %s avatar",
162+
"Use_initials_avatar": "Use your username initials",
162163
"Login_with": "Login with %s",
163164
"Select_an_avatar": "Select an avatar",
164165
"Use_uploaded_avatar": "Use uploaded avatar",

i18n/pt.i18n.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@
155155
"Not_found_or_not_allowed": "Não encontrado ou não permitido"
156156
},
157157
"avatar": {
158-
"Use_service_avatar": "Use o avatar de %s",
158+
"Use_service_avatar": "Use o avatar do %s",
159+
"Use_initials_avatar": "Use as iniciais do seu nome de usuário",
159160
"Login_with": "Login com %s",
160161
"Select_an_avatar": "Selecione um avatar",
161162
"Use_uploaded_avatar": "Use o avatar de upload",

server/methods/setAvatarFromService.coffee

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
Meteor.methods
2-
setAvatarFromService: (dataURI, service) ->
2+
setAvatarFromService: (dataURI, contentType, service) ->
33
if not Meteor.userId()
44
throw new Meteor.Error 203, '[methods] typingStatus -> Usuário não logado'
55

66
user = Meteor.user()
77

8+
if service is 'initials'
9+
Meteor.users.update {_id: user._id}, {$set: {avatarOrigin: service}}
10+
return
11+
812
{image, contentType} = RocketFile.dataURIParse dataURI
913

1014
rs = RocketFile.bufferToStream new Buffer(image, 'base64')

0 commit comments

Comments
 (0)