From 9ad360a30c44bd600a52b493f090bc6e2cc18f14 Mon Sep 17 00:00:00 2001
From: Rodrigo Nascimento <rodrigoknascimento@gmail.com>
Date: Sun, 31 May 2015 22:43:30 -0300
Subject: [PATCH] Get avatar using username

---
 client/stylesheets/base.less      |  5 +++++
 client/views/avatar/avatar.coffee | 13 +++++++++++++
 client/views/avatar/avatar.html   |  6 ++++++
 3 files changed, 24 insertions(+)
 create mode 100644 client/views/avatar/avatar.coffee
 create mode 100644 client/views/avatar/avatar.html

diff --git a/client/stylesheets/base.less b/client/stylesheets/base.less
index a01fef8d9b0..df4ce0d6786 100644
--- a/client/stylesheets/base.less
+++ b/client/stylesheets/base.less
@@ -663,7 +663,12 @@ a.github-fork {
 	height: 100%;
 	width: 100%;
 	overflow: hidden;
+	position: relative;
 	.avatar-image {
+		height: 100%;
+		width: 100%;
+		min-height: 40px;
+		min-width: 40px;
 		display: block;
 		background-color: transparent;
 		background-size: cover;
diff --git a/client/views/avatar/avatar.coffee b/client/views/avatar/avatar.coffee
new file mode 100644
index 00000000000..fbdfd105e19
--- /dev/null
+++ b/client/views/avatar/avatar.coffee
@@ -0,0 +1,13 @@
+Template.avatar.helpers
+	dimensions: ->
+		return {
+			width: 40
+			height: 40
+		}
+
+	imageUrl: ->
+		username = this.username
+		if not username? and this.userId?
+			username = Meteor.users.findOne(this.userId)?.username
+		url = "#{Meteor.absoluteUrl()}/avatar/#{username}"
+		return url
\ No newline at end of file
diff --git a/client/views/avatar/avatar.html b/client/views/avatar/avatar.html
new file mode 100644
index 00000000000..cd1e1da0f2c
--- /dev/null
+++ b/client/views/avatar/avatar.html
@@ -0,0 +1,6 @@
+<template name="avatar">
+	<div class="avatar">
+		<img class="avatar-image" src="/images/pixel.png" style="background-image:url({{imageUrl}});" alt="avatar" />
+		<span class="avatar-initials" style="{{initialsCss}}">{{initialsText}}</span>
+	</div>
+</template>
\ No newline at end of file
-- 
GitLab