diff --git a/app/models/speaker.rb b/app/models/speaker.rb index a5ad77a96..9789eb552 100644 --- a/app/models/speaker.rb +++ b/app/models/speaker.rb @@ -124,12 +124,41 @@ def create_suggestion_from(params:, user: Current.user) super end + def avatar_url(...) + bsky_avatar_url(...) || github_avatar_url(...) || fallback_avatar_url(...) + end + + def avatar_rank + return 1 if bsky_avatar_url.present? + return 2 if github_avatar_url.present? + + 3 + end + + def custom_avatar? + bsky_avatar_url.present? || github_avatar_url.present? + end + + def bsky_avatar_url(...) + bsky_metadata.dig("avatar") + end + def github_avatar_url(size: 200) - return "" unless github.present? + return nil unless github.present? "https://github.com/#{github}.png?size=#{size}" end + def fallback_avatar_url(size: 200) + url_safe_initials = name.split(" ").map(&:first).join("+") + + "https://ui-avatars.com/api/?name=#{url_safe_initials}&size=#{size}&background=DC133C&color=fff" + end + + def fetch_bsky_metadata! + Speaker::FetchBskyMetadata.new.perform(speaker: self) + end + def broadcast_about broadcast_update_to self, target: dom_id(self, :about), partial: "speakers/about", locals: {speaker: self} end diff --git a/app/views/events/_featured.html.erb b/app/views/events/_featured.html.erb index d0d3afbad..118f17a43 100644 --- a/app/views/events/_featured.html.erb +++ b/app/views/events/_featured.html.erb @@ -21,14 +21,14 @@ <% shown_speakers = [] %> <% all_speakers = event.speakers.to_a %> - <% speakers_with_avatars = all_speakers.select { |speaker| speaker.github.present? } %> + <% speakers_with_avatars = all_speakers.select { |speaker| speaker.avatar_url.present? }.sort_by(&:avatar_rank) %> <% event.keynote_speakers.each do |keynote_speaker| %> <% shown_speakers << keynote_speaker %>
- +
<% end %> @@ -39,7 +39,7 @@
- +
<% end %> @@ -57,7 +57,7 @@
- +
<% end %> diff --git a/app/views/leaderboard/_speaker.html.erb b/app/views/leaderboard/_speaker.html.erb index 5e5a12c1d..f603fd34b 100644 --- a/app/views/leaderboard/_speaker.html.erb +++ b/app/views/leaderboard/_speaker.html.erb @@ -3,8 +3,8 @@ <%= link_to speaker_path(speaker), class: "link link-hover" do %>
- <% if speaker.github.present? %> - <%= image_tag speaker.github_avatar_url(size: 128), class: "rounded-full w-10 h-10", alt: "GitHub picture profile of #{speaker.name}", loading: :lazy %> + <% if speaker.custom_avatar? %> + <%= image_tag speaker.avatar_url(size: 128), class: "rounded-full w-10 h-10", alt: "GitHub picture profile of #{speaker.name}", loading: :lazy %> <% else %>
<% end %> diff --git a/app/views/speakers/_card.html.erb b/app/views/speakers/_card.html.erb index f29375dc8..b656a150f 100644 --- a/app/views/speakers/_card.html.erb +++ b/app/views/speakers/_card.html.erb @@ -1,7 +1,7 @@ <%= link_to speaker_path(speaker), class: "flex w-full relative bg-white" do %>
- <%= image_tag speaker.github_avatar_url(size: 250), + <%= image_tag speaker.avatar_url(size: 250), alt: "picture profile of #{speaker.name}", class: "w-40 lg:w-full shrink-0 h-full", loading: "lazy", diff --git a/app/views/speakers/_speaker.html.erb b/app/views/speakers/_speaker.html.erb index a0bb9428e..0ba1b578d 100644 --- a/app/views/speakers/_speaker.html.erb +++ b/app/views/speakers/_speaker.html.erb @@ -1,7 +1,7 @@ <%= link_to speaker_path(speaker), id: dom_id(speaker), class: "flex justify-between" do %>
<%= speaker.name %> - <%#= image_tag speaker.github_avatar_url(size: 64), class: "rounded-full h-8 w-8" if speaker.github_avatar_url.present? %> + <%#= image_tag speaker.avatar_url(size: 64), class: "rounded-full h-8 w-8" if speaker.avatar_url.present? %>
<%= ui_badge(speaker.talks_count, kind: :secondary, outline: true, size: :lg, class: "min-w-10") %> diff --git a/app/views/speakers/show.html.erb b/app/views/speakers/show.html.erb index f6066b3b1..25efac5d0 100644 --- a/app/views/speakers/show.html.erb +++ b/app/views/speakers/show.html.erb @@ -10,20 +10,19 @@ <% end %>
- <% if @speaker.github.present? %> -
- <%= image_tag @speaker.github_avatar_url(size: 200), - class: "rounded-full mb-4", - height: 200, - width: 200, - alt: "GitHub picture profile of #{@speaker.github}", - loading: :lazy %> +
+ <%= image_tag @speaker.avatar_url(size: 200), + class: "rounded-full mt-4", + height: 200, + width: 200, + alt: "GitHub picture profile of #{@speaker.github}", + loading: :lazy %> + + <% if @speaker.verified? %> +
Verified
+ <% end %> +
- <% if @speaker.verified? %> -
Verified
- <% end %> -
- <% end %> <%= render "speakers/about", speaker: @speaker %> <%= render "speakers/actions", speaker: @speaker %>
diff --git a/app/views/spotlight/speakers/_speaker.html.erb b/app/views/spotlight/speakers/_speaker.html.erb index d3f408463..a315793b0 100644 --- a/app/views/spotlight/speakers/_speaker.html.erb +++ b/app/views/spotlight/speakers/_speaker.html.erb @@ -2,7 +2,7 @@
- <%= speaker.name %> + <%= speaker.name %>
<%= speaker.name %> diff --git a/app/views/talks/_explore_event.html.erb b/app/views/talks/_explore_event.html.erb index 0b1ffb2dc..f98b97e39 100644 --- a/app/views/talks/_explore_event.html.erb +++ b/app/views/talks/_explore_event.html.erb @@ -12,7 +12,7 @@ <% speakers_with_avatars.each do |speaker| %>
- +
<% end %> diff --git a/app/views/talks/_speaker.html.erb b/app/views/talks/_speaker.html.erb index 36c50d6f3..ed4b7034a 100644 --- a/app/views/talks/_speaker.html.erb +++ b/app/views/talks/_speaker.html.erb @@ -2,8 +2,8 @@
- <% if speaker.github.present? %> - <%= image_tag speaker.github_avatar_url(size: 48) %> + <% if speaker.custom_avatar? %> + <%= image_tag speaker.avatar_url(size: 48) %> <% else %> <%= speaker.name.split(" ").map(&:first).join %> <% end %> @@ -22,6 +22,8 @@
<% if speaker.github.present? %> <%= "@#{speaker.github}" %> + <% elsif speaker.bsky.present? %> + <%= "@#{speaker.bsky}" %> <% else %> <%= pluralize(speaker.talks.count, "talk") %> <% end %> diff --git a/app/views/talks/_talk.html.erb b/app/views/talks/_talk.html.erb index c08ae5ddc..19d1015fd 100644 --- a/app/views/talks/_talk.html.erb +++ b/app/views/talks/_talk.html.erb @@ -90,8 +90,8 @@ <% talk.speakers.to_a.from(speaker_preview_count).each do |speaker| %>
<%= content_tag :div, class: "w-12 rounded-full bg-primary text-neutral-content" do %> - <% if speaker.github.present? %> - <%= image_tag speaker.github_avatar_url(size: 48) %> + <% if speaker.custom_avatar? %> + <%= image_tag speaker.avatar_url(size: 48) %> <% else %> <%= speaker.name.split(" ").map(&:first).join %> <% end %>