From 2b81ad86dbf08563b2d6179b0147d0853b4ef1a3 Mon Sep 17 00:00:00 2001 From: pixeldesu Date: Sun, 30 Nov 2014 14:31:38 +0100 Subject: [PATCH] added gravatar support --- app/helpers/application_helper.rb | 4 ++++ app/views/shared/_answerbox.html.haml | 2 +- app/views/user/show.html.haml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7557456d..5159635e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -49,4 +49,8 @@ module ApplicationHelper def privileged?(user) (current_user && (current_user == user || current_user.admin?)) ? true : false end + + def gravatar_url(user) + "//www.gravatar.com/avatar/#{Digest::MD5.hexdigest(user.email)}" + end end diff --git a/app/views/shared/_answerbox.html.haml b/app/views/shared/_answerbox.html.haml index d0c8497c..41a5c203 100644 --- a/app/views/shared/_answerbox.html.haml +++ b/app/views/shared/_answerbox.html.haml @@ -2,7 +2,7 @@ .panel-heading .media %a.pull-left{href: '#'} - %img.img-rounded.img-answerbox + %img.img-rounded.img-answerbox{src: gravatar_url(a.question.user)} .media-body %h6.text-muted.media-heading.answerbox-question-user= user_screen_name a.question.user, a.question.author_is_anonymous %p.answerbox-question-text= a.question.content diff --git a/app/views/user/show.html.haml b/app/views/user/show.html.haml index aaf9223f..9d86446c 100644 --- a/app/views/user/show.html.haml +++ b/app/views/user/show.html.haml @@ -4,7 +4,7 @@ .panel-body .row .col-md-12.col-xs-12.col-sm-9 - %img.img-rounded.img-profile + %img.img-rounded.img-profile{src: gravatar_url(@user)} - if @user.display_name.blank? %h1= @user.screen_name - else