De-duplicate some parts of the users templates

This commit is contained in:
Bat 2018-06-17 18:48:22 +01:00
parent aa0ce32ec1
commit 0b9515645c
4 changed files with 36 additions and 57 deletions

View file

@ -129,7 +129,8 @@ fn followers(name: String, conn: DbConn, account: Option<User>) -> Template {
json json
}).collect::<Vec<serde_json::Value>>(), }).collect::<Vec<serde_json::Value>>(),
"account": account, "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()
})) }))
} }

View file

@ -12,38 +12,7 @@
{% endblock title %} {% endblock title %}
{% block content %} {% block content %}
<div> {% include "users/header" %}
<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>
<div> <div>
{{ user.summary | safe }} {{ user.summary | safe }}

View file

@ -11,30 +11,7 @@
{% endblock title %} {% endblock title %}
{% block content %} {% block content %}
<div> {% include "users/header" %}
<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>
<h2>{{ "Followers" | _ }}</h2> <h2>{{ "Followers" | _ }}</h2>
<div class="cards"> <div class="cards">

View 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>