mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-25 21:11:01 +00:00
De-duplicate some parts of the users templates
This commit is contained in:
parent
aa0ce32ec1
commit
0b9515645c
4 changed files with 36 additions and 57 deletions
|
@ -129,7 +129,8 @@ fn followers(name: String, conn: DbConn, account: Option<User>) -> Template {
|
|||
json
|
||||
}).collect::<Vec<serde_json::Value>>(),
|
||||
"account": account,
|
||||
"is_self": account.map(|a| a.id == user_id).unwrap_or(false)
|
||||
"is_self": account.map(|a| a.id == user_id).unwrap_or(false),
|
||||
"n_followers": user.get_followers(&*conn).len()
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
@ -12,38 +12,7 @@
|
|||
{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h1>
|
||||
{{ name }}
|
||||
{% if user.is_admin %}
|
||||
<span class="badge">{{ "Admin" | _ }}</span>
|
||||
{% endif %}
|
||||
|
||||
{% if is_self %}
|
||||
<span class="badge">{{ "It is you" | _ }}</span>
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
||||
{% if is_self %}
|
||||
<a href="edit" class="button inline-block">{{ "Edit your profile" | _ }}</a>
|
||||
{% endif %}
|
||||
|
||||
{% if is_remote %}
|
||||
<a class="inline-block button" href="{{ user.ap_url }}">{{ "Open on {{ instance_url }}" | _(instance_url=instance_url) }}</a>
|
||||
{% endif %}
|
||||
|
||||
{% if not is_self and account %}
|
||||
{% if follows %}
|
||||
<a href="follow/" class="inline-block button">{{ "Follow" | _ }}</a>
|
||||
{% else %}
|
||||
<a href="follow/" class="inline-block button">{{ "Unfollow" | _ }}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a href="followers/">{{ "{{ count }} followers" | _n(singular="One follower", count=n_followers) }}</a>
|
||||
</div>
|
||||
{% include "users/header" %}
|
||||
|
||||
<div>
|
||||
{{ user.summary | safe }}
|
||||
|
|
|
@ -11,30 +11,7 @@
|
|||
{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h1>
|
||||
{{ name }}
|
||||
{% if user.is_admin %}
|
||||
<span class="badge">{{ "Admin" | _ }}</span>
|
||||
{% endif %}
|
||||
|
||||
{% if is_self %}
|
||||
<span class="badge">{{ "It is you" | _ }}</span>
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
||||
{% if is_remote %}
|
||||
<a class="inline-block button" href="{{ user.ap_url }}">{{ "Open on {{ instance_url }}" | _(instance_url=instance_url) }}</a>
|
||||
{% endif %}
|
||||
|
||||
{% if (not is_self) and account %}
|
||||
{% if follows %}
|
||||
<a href="../follow/" class="inline-block button">{{ "Follow" | _ }}</a>
|
||||
{% else %}
|
||||
<a href="../follow/" class="inline-block button">{{ "Unfollow" | _ }}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% include "users/header" %}
|
||||
|
||||
<h2>{{ "Followers" | _ }}</h2>
|
||||
<div class="cards">
|
||||
|
|
32
templates/users/header.tera
Normal file
32
templates/users/header.tera
Normal file
|
@ -0,0 +1,32 @@
|
|||
<div>
|
||||
<h1>
|
||||
{{ name }}
|
||||
{% if user.is_admin %}
|
||||
<span class="badge">{{ "Admin" | _ }}</span>
|
||||
{% endif %}
|
||||
|
||||
{% if is_self %}
|
||||
<span class="badge">{{ "It is you" | _ }}</span>
|
||||
{% endif %}
|
||||
</h1>
|
||||
|
||||
{% if is_self %}
|
||||
<a href="edit" class="button inline-block">{{ "Edit your profile" | _ }}</a>
|
||||
{% endif %}
|
||||
|
||||
{% if is_remote %}
|
||||
<a class="inline-block button" href="{{ user.ap_url }}">{{ "Open on {{ instance_url }}" | _(instance_url=instance_url) }}</a>
|
||||
{% endif %}
|
||||
|
||||
{% if not is_self and account %}
|
||||
{% if follows %}
|
||||
<a href="follow/" class="inline-block button">{{ "Follow" | _ }}</a>
|
||||
{% else %}
|
||||
<a href="follow/" class="inline-block button">{{ "Unfollow" | _ }}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a href="followers/">{{ "{{ count }} followers" | _n(singular="One follower", count=n_followers) }}</a>
|
||||
</div>
|
Loading…
Reference in a new issue