Add a few (ugly) badges to the user page
This commit is contained in:
parent
ea08718c23
commit
aefa31b84e
@ -23,6 +23,8 @@ fn me(user: User) -> Redirect {
|
||||
fn details(name: String, conn: DbConn, account: Option<User>) -> Template {
|
||||
let user = User::find_by_fqn(&*conn, name).unwrap();
|
||||
let recents = Post::get_recents_for_author(&*conn, &user, 5);
|
||||
let user_id = user.id.clone();
|
||||
|
||||
Template::render("users/details", json!({
|
||||
"user": serde_json::to_value(user).unwrap(),
|
||||
"account": account,
|
||||
@ -33,7 +35,8 @@ fn details(name: String, conn: DbConn, account: Option<User>) -> Template {
|
||||
"url": p.compute_id(&*conn),
|
||||
"date": p.creation_date.timestamp()
|
||||
})
|
||||
}).collect::<Vec<serde_json::Value>>()
|
||||
}).collect::<Vec<serde_json::Value>>(),
|
||||
"is_self": account.map(|a| a.id == user_id).unwrap_or(false)
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -91,3 +91,13 @@ textarea {
|
||||
min-height: 200px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.badge {
|
||||
font-size: 12pt;
|
||||
background: white;
|
||||
color: #7a28cb;
|
||||
border: 1px solid #7a28cb;
|
||||
border-radius: 3px;
|
||||
padding: 5px 10px;
|
||||
margin: 0px 10px;
|
||||
}
|
||||
|
@ -5,17 +5,33 @@
|
||||
{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ user.display_name }}</h1>
|
||||
<div>
|
||||
{{ user.summary | safe }}
|
||||
</div>
|
||||
|
||||
<h2>Latest articles</h2>
|
||||
{% for article in recents %}
|
||||
<div>
|
||||
<h3><a href="{{ article.url }}">{{ article.post.title }}</a></h3>
|
||||
<p>{{ article.post.content | escape | truncate(length=200) }}…</p>
|
||||
<p>By {{ article.author.display_name }} ⋅ {{ article.date | date(format="%B %e") }}</p>
|
||||
<h1>
|
||||
{{ user.display_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 %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div>
|
||||
{{ user.summary | safe }}
|
||||
</div>
|
||||
|
||||
<h2>Latest articles</h2>
|
||||
{% for article in recents %}
|
||||
<div>
|
||||
<h3><a href="{{ article.url }}">{{ article.post.title }}</a></h3>
|
||||
<p>{{ article.post.content | escape | truncate(length=200) }}…</p>
|
||||
<p>By {{ article.author.display_name }} ⋅ {{ article.date | date(format="%B %e") }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock content %}
|
||||
|
Loading…
Reference in New Issue
Block a user