Add a link to user profile in comments

And move back {% if %} inside of {% block %}, so they get interpreted.
This commit is contained in:
Bat 2018-06-12 21:14:49 +01:00
parent 4c3e63ec16
commit 4185ba230e
4 changed files with 16 additions and 11 deletions

View File

@ -36,7 +36,12 @@ fn details(blog: String, slug: String, conn: DbConn, user: Option<User>) -> Temp
json!({ json!({
"id": c.id, "id": c.id,
"content": c.content, "content": c.content,
"author": c.get_author(&*conn) "author": ({
let author = &c.get_author(&*conn);
let mut json = serde_json::to_value(author).unwrap();
json["fqn"] = serde_json::Value::String(author.get_fqn(&*conn));
json
})
}) })
}).collect::<Vec<serde_json::Value>>(), }).collect::<Vec<serde_json::Value>>(),
"n_likes": post.get_likes(&*conn).len(), "n_likes": post.get_likes(&*conn).len(),

View File

@ -8,13 +8,13 @@
<a href="../">{{ blog.title }}</a> <a href="../">{{ blog.title }}</a>
{% endblock header %} {% endblock header %}
{% block content %}
{% if author.display_name %} {% if author.display_name %}
{% set name = author.display_name %} {% set name = author.display_name %}
{% else %} {% else %}
{% set name = author.username %} {% set name = author.username %}
{% endif %} {% endif %}
{% block content %}
<p> <p>
<b>Written by <a href="/@/{{ author.fqn }}/">{{ name }}</a></b> <b>Written by <a href="/@/{{ author.fqn }}/">{{ name }}</a></b>
&mdash; &mdash;
@ -61,7 +61,7 @@
{% set comment_author_name = comment.author.username %} {% set comment_author_name = comment.author.username %}
{% endif %} {% endif %}
<div class="card" id="comment-{{ comment.id }}"> <div class="card" id="comment-{{ comment.id }}">
<b>{{ comment_author_name }}</b> <a href="/@/{{ comment.author.fqn }}/"><b>{{ comment_author_name }}</b></a>
<div>{{ comment.content | safe }}</div> <div>{{ comment.content | safe }}</div>
<a href="comment?responding_to={{ comment.id }}">Respond</a> <a href="comment?responding_to={{ comment.id }}">Respond</a>
</div> </div>

View File

@ -1,13 +1,13 @@
{% extends "base" %} {% extends "base" %}
{% import "macros" as macros %} {% import "macros" as macros %}
{% block title %}
{% if user.display_name %} {% if user.display_name %}
{% set name = user.display_name %} {% set name = user.display_name %}
{% else %} {% else %}
{% set name = user.username %} {% set name = user.username %}
{% endif %} {% endif %}
{% block title %}
{{ name }} {{ name }}
{% endblock title %} {% endblock title %}
@ -30,7 +30,7 @@
</div> </div>
<div> <div>
<a href="followers">{{ n_followers }} follower{{ n_followers | pluralize }}</a> <a href="followers/">{{ n_followers }} follower{{ n_followers | pluralize }}</a>
</div> </div>
<div> <div>

View File

@ -1,12 +1,12 @@
{% extends "base" %} {% extends "base" %}
{% block title %}
{% if user.display_name %} {% if user.display_name %}
{% set name = user.display_name %} {% set name = user.display_name %}
{% else %} {% else %}
{% set name = user.username %} {% set name = user.username %}
{% endif %} {% endif %}
{% block title %}
{{ name }}'s Followers {{ name }}'s Followers
{% endblock title %} {% endblock title %}