Skip to content

Commit f05f896

Browse files
committed
Fix JS avatar fallback not happening in some cases
Add the "avatar" class where needed (no CSS). Remove unused user-img-results. Fix indents in kitsune/community/jinja2/community/index.html Remove an unused import in kitsune/kitsune/messages/jinja2/messages/outbox.html
1 parent b405965 commit f05f896

File tree

9 files changed

+39
-37
lines changed

9 files changed

+39
-37
lines changed

kitsune/community/jinja2/community/index.html

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -93,33 +93,33 @@ <h2 class="sumo-page-subheading">{{ _('Top Contributors') }}</h2>
9393
</div>
9494

9595

96-
{# Product Filter #}
97-
<div class="mzp-c-menu-list selector">
98-
<p class="mzp-c-menu-list-title has-icon text-body-md" data-has-dropdown>
99-
{% if not product %}
100-
{{ _('Filter by Product') }}
101-
{% else %}
102-
{{ pgettext('DB: products.Product.title', product.title) }}
103-
{% endif %}
104-
</p>
105-
<ul class="mzp-c-menu-list-list">
106-
{% set base_url = url('community.home') %}
107-
{% if locale %}
108-
{% set base_url = base_url|urlparams(locale=locale) %}
109-
{% endif %}
110-
<li class="mzp-c-menu-list-item {% if not product %}is-selected{% endif %}">
111-
<a href="{{ base_url }}">
112-
{{ _('All products') }}
113-
</a>
114-
</li>
115-
{% for p in products %}
116-
<li class="mzp-c-menu-list-item {% if p == product %}is-selected{% endif %}">
117-
<a href="{{ base_url|urlparams(product=p.slug) }}">
118-
<span>{{ pgettext('DB: products.Product.title', p.title) }}</span>
96+
{# Product Filter #}
97+
<div class="mzp-c-menu-list selector">
98+
<p class="mzp-c-menu-list-title has-icon text-body-md" data-has-dropdown>
99+
{% if not product %}
100+
{{ _('Filter by Product') }}
101+
{% else %}
102+
{{ pgettext('DB: products.Product.title', product.title) }}
103+
{% endif %}
104+
</p>
105+
<ul class="mzp-c-menu-list-list">
106+
{% set base_url = url('community.home') %}
107+
{% if locale %}
108+
{% set base_url = base_url|urlparams(locale=locale) %}
109+
{% endif %}
110+
<li class="mzp-c-menu-list-item {% if not product %}is-selected{% endif %}">
111+
<a href="{{ base_url }}">
112+
{{ _('All products') }}
119113
</a>
120114
</li>
121-
{% endfor %}
122-
</ul>
115+
{% for p in products %}
116+
<li class="mzp-c-menu-list-item {% if p == product %}is-selected{% endif %}">
117+
<a href="{{ base_url|urlparams(product=p.slug) }}">
118+
<span>{{ pgettext('DB: products.Product.title', p.title) }}</span>
119+
</a>
120+
</li>
121+
{% endfor %}
122+
</ul>
123123
</div>
124124
</div>
125125

@@ -157,7 +157,7 @@ <h2 class="sumo-page-subheading">{{ _('Localization') }}</h2>
157157
<li>
158158
{% set tooltip = _('{user} - {num} contributions in last 90 days')|f(user=result['user']['display_name'], num=result['count']) %}
159159
<a rel="nofollow" href="{{ url('users.profile', result['user']['id']) }}" title="{{ tooltip }}">
160-
<img src="{{ result['user']['avatar'] }}" alt="{{ tooltip }}" />
160+
<img class="avatar" src="{{ result['user']['avatar'] }}" alt="{{ tooltip }}" />
161161
</a>
162162
</li>
163163
{% endfor %}

kitsune/community/jinja2/community/search.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h1 class="sumo-page-heading">{{ _('Find your fellow contributors') }}</h1>
3131
{% for result in results %}
3232
<section class="card elevation-01 results-user">
3333
{% if result['avatar'] %}
34-
<img src="{{ result['avatar']['url'] }}" alt="" class="user-img-results card--img" />
34+
<img src="{{ result['avatar']['url'] }}" alt="" class="avatar card--img" />
3535
{% endif %}
3636
<div class="card--details user-details">
3737
<h2 class="card--title">{{ result['name'] }}</h2>

kitsune/community/jinja2/community/top_contributors.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ <h1 class="sumo-page-heading">{{ title }}</h1>
106106
{% for result in results %}
107107
<div class="card elevation-01 results-user">
108108
{% if result['user']['avatar'] %}
109-
<img src="{{ result['user']['avatar'] }}" alt="" class="user-img-results card--img" />
109+
<img src="{{ result['user']['avatar'] }}" alt="" class="avatar card--img" />
110110
{% endif %}
111111
<span class="numbered">{{ loop.index + ((page - 1) * page_size) }}</span>
112112
<div class="card--details user-details">

kitsune/kbadge/jinja2/badger/award_detail.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ <h2>{{ _('Award details') }}</h2>
4040
<dt>{{ _('Awarded to:') }}</dt>
4141
<dd class="awarded_to">
4242
<a rel="nofollow" href="{{ profile_url(award.user) }}">
43-
<img src="{{ profile_avatar(award.user) }}" alt="" title="{{ display_name(award.user) }}">
43+
<img class="avatar" src="{{ profile_avatar(award.user) }}" alt="" title="{{ display_name(award.user) }}">
4444
<br>{{ award.user }}
4545
</a>
4646
</dd>
@@ -54,7 +54,7 @@ <h2>{{ _('Award details') }}</h2>
5454
<dt>{{ _('Awarded by:') }}</dt>
5555
<dd>
5656
<a rel="nofollow" href="{{ profile_url(award.creator) }}">
57-
<img src="{{ profile_avatar(award.creator) }}" alt="" title="{{ award.creator }}">
57+
<img class="avatar" src="{{ profile_avatar(award.creator) }}" alt="" title="{{ award.creator }}">
5858
{{ award.creator }}
5959
</a>
6060
</dd>

kitsune/kbadge/jinja2/badger/awards_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h2>{{ _('Recently awarded badges') }}</h2>
3030
</div>
3131
<div class="award">
3232
{{ _('awarded to') }}
33-
<br><img src="{{ profile_avatar(award.user) }}" alt="" title="{{ award.user }}">
33+
<br><img class="avatar" src="{{ profile_avatar(award.user) }}" alt="" title="{{ award.user }}">
3434
<br>{{ award.user }}
3535
</div>
3636
<div class="meta">

kitsune/kbadge/jinja2/badger/badge_detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h2 class="sumo-page-subheading">{{ _('Recent awardees') }}</h2>
3838
<ul class="awardees">
3939
{% for award in award_list %}
4040
<li>
41-
<a href="{{ award.get_absolute_url() }}"><img src="{{ profile_avatar(award.user) }}" alt="" title="{{ award.user }}"></a>
41+
<a href="{{ award.get_absolute_url() }}"><img class="avatar" src="{{ profile_avatar(award.user) }}" alt="" title="{{ award.user }}"></a>
4242
</li>
4343
{% endfor %}
4444
</ul>

kitsune/messages/jinja2/messages/outbox.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "messages/base.html" %}
2-
{% from "messages/includes/macros.html" import avatar_link, display_user %}
2+
{% from "messages/includes/macros.html" import display_user %}
33
{% set title = _('Sent Messages') %}
44
{% set crumbs = [(url('messages.inbox'), _('Messages')),
55
(None, title)] %}

kitsune/sumo/static/sumo/js/messages.autocomplete.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ import { safeString, safeInterpolate } from "sumo/js/main";
6464
hintText: 'Search for a user or group. Group mail requires Staff group membership.',
6565
placeholder: 'Type a user or group name',
6666
resultsFormatter: function(item) {
67+
// The "avatar" class is applied to avatars for the JS-level fallback in profile-avatars.js
6768
if ((item.display_name) && (item.type === 'user')) {
68-
return safeInterpolate('<li class="%(type)s"><img src="%(type_icon)s" alt="icon for %(type)s"><img src="%(avatar)s"/><div class="name_search">%(display_name)s [%(name)s]</div></li>', item, true);
69+
return safeInterpolate('<li class="%(type)s"><img src="%(type_icon)s" alt="icon for %(type)s"><img src="%(avatar)s" class="avatar"/><div class="name_search">%(display_name)s [%(name)s]</div></li>', item, true);
6970
}
70-
return safeInterpolate('<li class="%(type)s"><img src="%(type_icon)s" alt="icon for %(type)s"><img src="%(avatar)s"/><div class="name_search">%(name)s</div></li>', item, true);
71+
return safeInterpolate('<li class="%(type)s"><img src="%(type_icon)s" alt="icon for %(type)s"><img src="%(avatar)s" class="avatar"/><div class="name_search">%(name)s</div></li>', item, true);
7172
}
7273
});
7374
});

kitsune/sumo/static/sumo/js/users.autocomplete.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ import { safeString, safeInterpolate } from "sumo/js/main";
4242
preventDuplicates: true,
4343
resultsFormatter: function(item) {
4444
var term = $('#token-input-id_to').val();
45+
// The "avatar" class is applied to avatars for the JS-level fallback in profile-avatars.js
4546
if (item.display_name) {
46-
return safeInterpolate('<li><img src="%(avatar)s"/><div class="name_search">%(display_name)s [%(username)s]</div></li>', item, true);
47+
return safeInterpolate('<li><img src="%(avatar)s" class="avatar"/><div class="name_search">%(display_name)s [%(username)s]</div></li>', item, true);
4748
}
48-
return safeInterpolate('<li><img src="%(avatar)s"/><div class="name_search">%(username)s</div></li>', item, true);
49+
return safeInterpolate('<li><img src="%(avatar)s" class="avatar"/><div class="name_search">%(username)s</div></li>', item, true);
4950
},
5051
onAdd: function (item) {
5152
$(this).closest('.single').closest('form').submit();

0 commit comments

Comments
 (0)