Skip to content

Commit c133715

Browse files
committed
fix icons not being jazzy
1 parent a9e1e60 commit c133715

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ gem "countries"
9797
# Markdown parsing
9898
gem "redcarpet"
9999

100+
gem "ruby_identicon"
101+
100102
# Feature flags
101103
gem "flipper"
102104
gem "flipper-active_record"

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ GEM
126126
chartkick (5.2.0)
127127
childprocess (5.1.0)
128128
logger (~> 1.5)
129+
chunky_png (1.4.0)
129130
concurrent-ruby (1.3.5)
130131
connection_pool (2.5.3)
131132
countries (8.0.2)
@@ -438,6 +439,8 @@ GEM
438439
rubocop-performance (>= 1.24)
439440
rubocop-rails (>= 2.30)
440441
ruby-progressbar (1.13.0)
442+
ruby_identicon (0.0.6)
443+
chunky_png (~> 1.4.0)
441444
rubyzip (2.4.1)
442445
safely_block (0.5.0)
443446
sanitize (7.0.0)
@@ -589,6 +592,7 @@ DEPENDENCIES
589592
rails (~> 8.0.2)
590593
redcarpet
591594
rubocop-rails-omakase
595+
ruby_identicon
592596
selenium-webdriver
593597
sentry-rails
594598
sentry-ruby

app/models/user.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,16 @@ def self.from_github_token(code, redirect_uri, current_user)
430430
def avatar_url
431431
return self.slack_avatar_url if self.slack_avatar_url.present?
432432
return self.github_avatar_url if self.github_avatar_url.present?
433-
initials = self.email_addresses&.first&.email[0..1]&.upcase
434-
hashed_initials = Digest::SHA256.hexdigest(initials)[0..5]
435-
"https://i2.wp.com/ui-avatars.com/api/#{initials}/48/#{hashed_initials}/fff?ssl=1" if initials.present?
433+
434+
email = self.email_addresses&.first&.email
435+
if email.present?
436+
initials = email[0..1]&.upcase
437+
hashed_initials = Digest::SHA256.hexdigest(initials)[0..5]
438+
return "https://i2.wp.com/ui-avatars.com/api/#{initials}/48/#{hashed_initials}/fff?ssl=1"
439+
end
440+
441+
base64_identicon = RubyIdenticon.create_base64(id.to_s)
442+
"data:image/png;base64,#{base64_identicon}"
436443
end
437444

438445
def display_name

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def matches?(request)
107107
post "my/settings/migrate_heartbeats", to: "users#migrate_heartbeats", as: :my_settings_migrate_heartbeats
108108

109109
namespace :my do
110-
resources :project_repo_mappings, param: :project_name, only: [ :edit, :update ], constraints: { project_name: /[^\/]+/ }
110+
resources :project_repo_mappings, param: :project_name, only: [ :edit, :update ], constraints: { project_name: /[^\/]+/ }
111111
resource :mailing_address, only: [ :show, :edit ]
112112
get "mailroom", to: "mailroom#index"
113113
end

0 commit comments

Comments
 (0)