add: anonymous username and anonymous avatar
This commit is contained in:
parent
a78ee0f8d2
commit
434f2ba00d
3 changed files with 53 additions and 3 deletions
|
@ -598,16 +598,49 @@ and user %}
|
||||||
{% endif %} {%- endmacro %} {% macro question(question, owner,
|
{% endif %} {%- endmacro %} {% macro question(question, owner,
|
||||||
show_community=true, secondary=false) -%}
|
show_community=true, secondary=false) -%}
|
||||||
<div class="card{% if secondary %} secondary{% endif %} flex gap-2">
|
<div class="card{% if secondary %} secondary{% endif %} flex gap-2">
|
||||||
|
{% if owner.id == 0 %}
|
||||||
|
<span>
|
||||||
|
{% if profile and profile.settings.anonymous_avatar_url %}
|
||||||
|
<img
|
||||||
|
src="/api/v1/util/proxy?url={{ profile.settings.anonymous_avatar_url }}"
|
||||||
|
alt="anonymous' avatar"
|
||||||
|
class="avatar shadow"
|
||||||
|
loading="lazy"
|
||||||
|
style="--size: 52px"
|
||||||
|
/>
|
||||||
|
{% else %} {{ components::avatar(username=owner.username,
|
||||||
|
selector_type="username", size="52px") }} {% endif %}
|
||||||
|
</span>
|
||||||
|
{% else %}
|
||||||
<a href="/@{{ owner.username }}">
|
<a href="/@{{ owner.username }}">
|
||||||
{{ components::avatar(username=owner.username, selector_type="username",
|
{{ components::avatar(username=owner.username, selector_type="username",
|
||||||
size="52px") }}
|
size="52px") }}
|
||||||
</a>
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<div class="flex items-center gap-2 flex-wrap">
|
<div class="flex items-center gap-2 flex-wrap">
|
||||||
<span class="name"
|
<!-- prettier-ignore -->
|
||||||
>{{ components::full_username(user=owner) }}</span
|
<span class="name">
|
||||||
|
{% if owner.id == 0 %}
|
||||||
|
{% if profile and profile.settings.anonymous_username %}
|
||||||
|
<span class="flex items-center gap-2">
|
||||||
|
<b>{{ profile.settings.anonymous_username }}</b>
|
||||||
|
<span
|
||||||
|
title="Anonymous user"
|
||||||
|
class="flex items-center"
|
||||||
|
style="color: var(--color-primary)"
|
||||||
>
|
>
|
||||||
|
{{ icon "drama" }}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
{% else %}
|
||||||
|
<b>anonymous</b>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{{ components::full_username(user=owner) }}
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
|
||||||
<span class="date">{{ question.created }}</span>
|
<span class="date">{{ question.created }}</span>
|
||||||
|
|
||||||
|
|
|
@ -799,6 +799,17 @@
|
||||||
settings.motivational_header,
|
settings.motivational_header,
|
||||||
"input",
|
"input",
|
||||||
],
|
],
|
||||||
|
[[], "Anonymous", "title"],
|
||||||
|
[
|
||||||
|
["anonymous_username", "Anonymous username"],
|
||||||
|
settings.anonymous_username,
|
||||||
|
"input",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
["anonymous_avatar_url", "Anonymous avatar URL"],
|
||||||
|
settings.anonymous_avatar_url,
|
||||||
|
"input",
|
||||||
|
],
|
||||||
],
|
],
|
||||||
settings,
|
settings,
|
||||||
);
|
);
|
||||||
|
|
|
@ -139,6 +139,12 @@ pub struct UserSettings {
|
||||||
/// If questions from anonymous users are allowed. Requires `enable_questions`.
|
/// If questions from anonymous users are allowed. Requires `enable_questions`.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub allow_anonymous_questions: bool,
|
pub allow_anonymous_questions: bool,
|
||||||
|
/// The username used for anonymous users.
|
||||||
|
#[serde(default)]
|
||||||
|
pub anonymous_username: String,
|
||||||
|
/// The URL of the avatar used for anonymous users.
|
||||||
|
#[serde(default)]
|
||||||
|
pub anonymous_avatar_url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for User {
|
impl Default for User {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue