-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathuser_inline.html.twig
More file actions
52 lines (46 loc) · 2.83 KB
/
Copy pathuser_inline.html.twig
File metadata and controls
52 lines (46 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<a href="{{ path('user_overview', {username: user.username}) }}"
data-action="mouseover->mentions#user_popup mouseout->mentions#user_popup_out"
data-mentions-username-param="{{ user.username }}"
class="user-inline"
title="{{ user.username|username(true) }}">
{% if user.avatar and showAvatar %}
<img class="image-inline"width="30" height="30" loading="lazy"
src="{{ user.avatar.filePath ? (asset(user.avatar.filePath) | imagine_filter('avatar_thumb')) : user.avatar.sourceUrl }}"
alt="{{ user.username ~' '~ 'avatar'|trans|lower }}">
{% elseif showAvatar %}
{% set numericDigits = {
'a': 15, 'b': 85, 'c': 42, 'd': 93, 'e': 27, 'f': 68, 'g': 11, 'h': 76, 'i': 33, 'j': 99, 'k': 54, 'l': 3, 'm': 60, 'n': 17, 'o': 81, 'p': 9,
'q': 102, 'r': 48, 's': 21, 't': 72, 'u': 39, 'v': 6, 'w': 87, 'x': 30, 'y': 63, 'z': 12, 'A': 24, 'B': 90, 'C': 51, 'D': 105, 'E': 18, 'F': 66,
'G': 0, 'H': 78, 'I': 45, 'J': 96, 'K': 57, 'L': 9, 'M': 69, 'N': 14, 'O': 84, 'P': 3, 'Q': 108, 'R': 36, 'S': 15, 'T': 75, 'U': 42, 'V': 12,
'W': 93, 'X': 27, 'Y': 60, 'Z': 21, '0': 111, '1': 6, '2': 45, '3': 90, '4': 24, '5': 78, '6': 33, '7': 99, '8': 18, '9': 57, '_': 126, '-': 63 } %}
{% set validChars = '' %}
{% for char in user.username|split('') %}
{% if char in numericDigits|keys %}
{% set validChars = validChars ~ char %}
{% endif %}
{% endfor %}
{% set validChars = validChars ~ "012345" %}
{% set chars = validChars|slice(0, 6) %}
{% set sum = 0 %}
{% for char in chars|split('') %}
{% set sum = sum + numericDigits[char] %}
{% endfor %}
{% set hueRotation = (sum % 360) %}
{% set saturation = 0.4 + (sum % 60) / 100 %} {# Range: 0.4 to 1.0 #}
{% if app.user is defined and app.user is not same as null and app.user is same as user %}
{% set noAvatar = "you can set your avatar in your profile" %}
{% else %}
{% set noAvatar = user.username ~ " has no avatar" %}
{% endif %}
<img class="image-inline"
width="30" height="30" loading="lazy" src="/default_avatar.png" title="{{ noAvatar }}" alt="{{ noAvatar }}" style="filter: saturate({{ saturation }}) hue-rotate({{ hueRotation }}deg) contrast(0.9999);">
{% endif %}
{{ user.apPreferredUsername ?? user.username|username -}}
{%- if fullName is defined and fullName is same as true -%}
@{{- user.username|apDomain -}}
{%- endif -%}
{% if user.isNew() %}
{% set days = constant('App\\Entity\\User::NEW_FOR_DAYS') %}
<i class="fa-solid fa-leaf new-user-icon" title="{{ 'new_user_description'|trans({ '%days%': days }) }}" aria-description="{{ 'new_user_description'|trans({ '%days%': days }) }}"></i>
{% endif %}
</a>