Skip to content

Commit aed307a

Browse files
show gravatar display name and bitcoin adress
1 parent eb1734c commit aed307a

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
// Place all the styles related to the Users controller here.
22
// They will automatically be included in application.css.
33
// You can use Sass (SCSS) here: http://sass-lang.com/
4+
5+
6+
.from-gravatar{
7+
display: block;
8+
margin-bottom: 15px;
9+
cursor: pointer;
10+
font-style: italic;
11+
margin-top: -12px;
12+
padding-left: 14px;
13+
}

app/models/user.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ def balance
2424
tips.decided.unpaid.sum(:amount)
2525
end
2626

27+
def gravatar_bitcoin
28+
gravatar.get_value :currency, :bitcoin
29+
end
30+
31+
def gravatar_display_name
32+
gravatar.get_value :displayName
33+
end
34+
2735
def display_name
2836
attributes['display_name'].presence || name.presence || nickname.presence || email
2937
end
@@ -63,6 +71,10 @@ def ready_for_withdrawal?
6371

6472
private
6573

74+
def gravatar
75+
@gravatar ||= Gravatar::new(email)
76+
end
77+
6678
def set_login_token!
6779
loop do
6880
self.login_token = SecureRandom.urlsafe_base64

app/views/users/show.html.haml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
= btc_human @user.balance
66
%p
77
%small= raw t('.threshold', threshold: btc_human(CONFIG["min_payout"]))
8-
8+
99
- if @user_tips.count > 0
1010
%p
1111
%strong Last Tips
@@ -21,7 +21,13 @@
2121
%p= @user.email
2222
= twitter_bootstrap_form_for @user do |f|
2323
= f.text_field :bitcoin_address, placeholder: t('.bitcoin_address_placeholder')
24+
- if @user.gravatar_bitcoin.present?
25+
%span.from-gravatar{data:{for: 'user[bitcoin_address]', value: @user.gravatar_bitcoin }}
26+
= "#{t('.use_from_gravatar')}: #{@user.gravatar_bitcoin}"
2427
= f.text_field :display_name
28+
- if @user.gravatar_display_name.present?
29+
%span.from-gravatar{data:{for: 'user[display_name]', value: @user.gravatar_display_name }}
30+
= "#{t('.use_from_gravatar')}: #{@user.gravatar_display_name}"
2531
- if f.object.bitcoin_address.blank?
2632
= f.check_box :unsubscribed, t('.notify'), { checked: !f.object.unsubscribed? }, '0', '1'
2733
%br

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ en:
176176
submit_user: Update user info
177177
change_password: Change your password
178178
submit_password: Change my password
179+
use_from_gravatar: Use from your gravatar profile
179180
withdrawals:
180181
index:
181182
title: Last Withdrawals

config/locales/nl.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ nl:
176176
submit_user: Gegevens opslaan
177177
change_password: Wijzig wachtwoord
178178
submit_password: Wijzig mijn wachtwoord
179+
use_from_gravatar: Gebruik van je gravatar profiel
179180
withdrawals:
180181
index:
181182
title: Laatste terugroepingen

0 commit comments

Comments
 (0)