Skip to content

Commit 706fb8f

Browse files
Merge pull request #2148 from basecamp/revert-avatar-change
Revert avatar change
2 parents 2058743 + e2292a1 commit 706fb8f

13 files changed

Lines changed: 44 additions & 91 deletions

File tree

app/assets/stylesheets/avatars.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
max-inline-size: 100%;
2323
object-fit: cover;
2424
}
25-
26-
span[data-creator-id] {
27-
display: grid;
28-
place-items: center;
29-
}
3025
}
3126

3227
.avatar__form {

app/controllers/my/avatars_controller.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

app/controllers/users/avatars_controller.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@ class Users::AvatarsController < ApplicationController
55
before_action :ensure_permission_to_administer_user, only: :destroy
66

77
def show
8-
expires_in 30.minutes, public: true, stale_while_revalidate: 1.week
9-
108
if @user.system?
119
redirect_to view_context.image_path("system_user.png")
1210
elsif @user.avatar.attached?
1311
redirect_to rails_blob_url(@user.avatar_thumbnail, disposition: "inline")
14-
else
12+
elsif stale? @user, cache_control: cache_control
1513
render_initials
1614
end
1715
end
1816

1917
def destroy
2018
@user.avatar.destroy
21-
@user.touch
2219
redirect_to @user
2320
end
2421

@@ -31,6 +28,14 @@ def ensure_permission_to_administer_user
3128
head :forbidden unless Current.user.can_change?(@user)
3229
end
3330

31+
def cache_control
32+
if @user == Current.user
33+
{}
34+
else
35+
{ max_age: 30.minutes, stale_while_revalidate: 1.week }
36+
end
37+
end
38+
3439
def render_initials
3540
render formats: :svg
3641
end

app/helpers/avatars_helper.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ def avatar_preview_tag(user, hidden_for_screen_reader: false, **options)
4242
end
4343

4444
def avatar_image_tag(user, **options)
45-
tag.span data: { creator_id: user.id } do
46-
safe_join [
47-
image_tag(my_avatar_url(script_name: user.account.slug), aria: { hidden: "true" }, size: 48, title: user.name, data: { only_visible_to_you: true }, **options),
48-
image_tag(user_avatar_url(user, script_name: user.account.slug), aria: { hidden: "true" }, size: 48, title: user.name, data: { only_visible_to_others: true }, **options)
49-
]
50-
end
45+
image_tag user_avatar_url(user, script_name: user.account.slug), aria: { hidden: "true" }, size: 48, title: user.name, **options
5146
end
5247
end

app/views/cards/comments/_comment.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<% cache comment do %>
2+
<%# Helper Dependency Updated: avatar_image_tag 2025-12-15 %>
23
<%= turbo_frame_tag comment, :container do %>
34
<%# Cache bump 2025-12-14: action text attachment rendering changed for lightbox -%>
45
<div id="<%= dom_id(comment) %>" data-creator-id="<%= comment.creator_id %>" class="comment flex align-start full-width <%= "comment--system" if comment.creator.system? %>">

app/views/events/_event.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<% cache event do %>
2+
<%# Helper Dependency Updated: avatar_image_tag 2025-12-15 %>
23
<% if lookup_context.exists?("events/event/eventable/_#{event.action}") %>
34
<%= render "events/event/eventable/#{event.action}", event: event %>
45
<% else %>

app/views/my/avatars/show.svg.erb

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/views/notifications/_notification.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<% cache notification do %>
2+
<%# Helper Dependency Updated: avatar_image_tag 2025-12-15 %>
23
<%= notification_tag notification do %>
34
<%= render "notifications/notification/header", notification: notification do %>
45
<%= notification_toggle_read_button(notification, url: card_reading_path(notification.card)) %>

app/views/users/_initials.svg.erb

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
<%= render "users/initials", user: @user %>
1+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
2+
viewBox="0 0 512 512" class="avatar" aria-hidden="true">
3+
<defs>
4+
<clipPath id="porthole">
5+
<circle cx="50%" cy="50%" r="50%" />
6+
</clipPath>
7+
</defs>
8+
9+
<g>
10+
<rect width="100%" height="100%" rx="50" fill="<%= avatar_background_color(@user) %>" />
11+
12+
<text x="50%" y="50%" fill="#FFFFFF"
13+
text-anchor="middle" dy="0.35em"
14+
<%=raw 'textLength="85%" lengthAdjust="spacingAndGlyphs"' if @user.initials.size >= 3 %>
15+
font-family="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif"
16+
font-size="230"
17+
font-weight="800"
18+
letter-spacing="-5">
19+
<%= @user.initials %>
20+
</text>
21+
</g>
22+
</svg>

0 commit comments

Comments
 (0)