Simplify the logic to fallback to the FQN when no display name is available
This commit is contained in:
parent
15477875da
commit
5980c7b299
|
@ -370,6 +370,11 @@ impl User {
|
|||
pub fn to_json(&self, conn: &PgConnection) -> serde_json::Value {
|
||||
let mut json = serde_json::to_value(self).unwrap();
|
||||
json["fqn"] = serde_json::Value::String(self.get_fqn(conn));
|
||||
json["name"] = if self.display_name.len() > 0 {
|
||||
json!(self.display_name)
|
||||
} else {
|
||||
json!(self.get_fqn(conn))
|
||||
};
|
||||
json
|
||||
}
|
||||
|
||||
|
|
|
@ -11,12 +11,7 @@
|
|||
<p>
|
||||
{{ "{{ count }} authors in this blog: " | _n(singular="One author in this blog: ", count = n_authors) }}
|
||||
{% for author in authors %}
|
||||
{% if author.display_name %}
|
||||
{% set name = author.display_name %}
|
||||
{% else %}
|
||||
{% set name = author.username %}
|
||||
{% endif %}
|
||||
<a class="author" href="/@/{{ author.fqn }}">{{ name }}</a>{% if not loop.last %},{% endif %}
|
||||
<a class="author" href="/@/{{ author.fqn }}">{{ author.name }}</a>{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
<p>
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
{% macro post_card(article) %}
|
||||
{% if article.author.display_name %}
|
||||
{% set name = article.author.display_name %}
|
||||
{% else %}
|
||||
{% set name = article.author.username %}
|
||||
{% endif %}
|
||||
<div class="card">
|
||||
<h3><a href="{{ article.url }}">{{ article.post.title }}</a></h3>
|
||||
<main
|
||||
|
@ -14,7 +9,7 @@
|
|||
link_1='<a href="/@/',
|
||||
link_2=article.author.fqn,
|
||||
link_3='/">',
|
||||
name=name,
|
||||
name=article.author.name,
|
||||
link_4="</a>")
|
||||
}}
|
||||
⋅ {{ article.date | date(format="%B %e") }}
|
||||
|
@ -49,7 +44,7 @@
|
|||
{% macro comment(comm) %}
|
||||
<div class="comment" id="comment-{{ comm.id }}">
|
||||
<a class="author" href="{{ comm.author.ap_url }}">
|
||||
<span class="display-name">{{ comm.author.display_name | default(value=comm.author.username) }}</span>
|
||||
<span class="display-name">{{ comm.author.name }}</span>
|
||||
<small>@{{ comm.author.username }}</small>
|
||||
</a>
|
||||
<div class="text">{{ comm.content | safe }}</div>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<i class="fa fa-comment left-icon"></i>
|
||||
<main class="grow">
|
||||
<h3><a href="{{ notification.object.post.url }}#comment-{{ notification.object.id }}">
|
||||
{{ "{{ user }} commented your article." | _(user=notification.object.user.display_name | escape) }}
|
||||
{{ "{{ user }} commented your article." | _(user=notification.object.user.name | escape) }}
|
||||
</a></h3>
|
||||
<p><a href="{{ notification.object.post.url }}">{{ notification.object.post.post.title }}</a></p>
|
||||
</main>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<i class="fa fa-user-plus left-icon"></i>
|
||||
<main class="grow">
|
||||
<h3><a href="/@/{{ notification.object.follower.fqn }}/">
|
||||
{{ "{{ user }} is now following you." | _(user=notification.object.follower.display_name | escape) }}
|
||||
{{ "{{ user }} is now following you." | _(user=notification.object.follower.name | escape) }}
|
||||
</a></h3>
|
||||
</main>
|
||||
<p><small>{{ notification.creation_date | date(format="%B %e, %H:%m") }}</small></p>
|
||||
|
@ -33,7 +33,7 @@
|
|||
<i class="fa fa-heart left-icon"></i>
|
||||
<main class="grow">
|
||||
<h3>
|
||||
{{ "{{ user }} liked your article." | _(user=notification.object.user.display_name | escape) }}
|
||||
{{ "{{ user }} liked your article." | _(user=notification.object.user.name | escape) }}
|
||||
</h3>
|
||||
<p><a href="{{ notification.object.post.url }}">{{ notification.object.post.post.title }}</a></p>
|
||||
</main>
|
||||
|
@ -43,7 +43,7 @@
|
|||
<i class="fa fa-at left-icon"></i>
|
||||
<main class="grow">
|
||||
<h3><a href="{{ notification.object.url }}">
|
||||
{{ "{{ user }} mentioned you." | _(user=notification.object.user.display_name | escape) }}
|
||||
{{ "{{ user }} mentioned you." | _(user=notification.object.user.name | escape) }}
|
||||
</a></h3>
|
||||
</main>
|
||||
<p><small>{{ notification.creation_date | date(format="%B %e, %H:%m") }}</small></p>
|
||||
|
@ -52,7 +52,7 @@
|
|||
<i class="fa fa-retweet left-icon"></i>
|
||||
<main class="grow">
|
||||
<h3>
|
||||
{{ "{{ user }} reshared your article." | _(user=notification.object.user.display_name | escape) }}
|
||||
{{ "{{ user }} reshared your article." | _(user=notification.object.user.name | escape) }}
|
||||
</h3>
|
||||
<p><a href="{{ notification.object.post.url }}">{{ notification.object.post.post.title }}</a></p>
|
||||
</main>
|
||||
|
|
|
@ -12,18 +12,11 @@
|
|||
{% block content %}
|
||||
<h1 class="article">{{ post.title }}</h1>
|
||||
<p class="article-info">
|
||||
|
||||
{% if author.display_name %}
|
||||
{% set name = author.display_name %}
|
||||
{% else %}
|
||||
{% set name = author.username %}
|
||||
{% endif %}
|
||||
|
||||
<span class="author">{{ "Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}" | _(
|
||||
link_1='<a href="/@/',
|
||||
url=author.fqn,
|
||||
link_2='/">',
|
||||
name=name,
|
||||
name=author.name,
|
||||
link_3="</a>"
|
||||
)
|
||||
}}</a></span>
|
||||
|
|
|
@ -2,13 +2,7 @@
|
|||
{% import "macros" as macros %}
|
||||
|
||||
{% block title %}
|
||||
{% if user.display_name %}
|
||||
{% set name = user.display_name %}
|
||||
{% else %}
|
||||
{% set name = user.username %}
|
||||
{% endif %}
|
||||
|
||||
{{ "{{ name | escape }}'s followers" | _(name=name) }}
|
||||
{{ "{{ name | escape }}'s followers" | _(name=user.name) }}
|
||||
{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
|
@ -17,13 +11,8 @@
|
|||
<h2>{{ "Followers" | _ }}</h2>
|
||||
<div class="cards">
|
||||
{% for follower in followers %}
|
||||
{% if follower.display_name %}
|
||||
{% set follower_name = follower.display_name %}
|
||||
{% else %}
|
||||
{% set follower_name = follower.username %}
|
||||
{% endif %}
|
||||
<div class="card">
|
||||
<h3><a href="/@/{{ follower.fqn }}/">{{ follower_name }}</a> <small>@{{ follower.fqn }}</small></h3>
|
||||
<h3><a href="/@/{{ follower.fqn }}/">{{ follower.name }}</a> <small>@{{ follower.fqn }}</small></h3>
|
||||
<main><p>{{ follower.summary | safe }}</p></main>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="user">
|
||||
<h1>
|
||||
{{ name }}
|
||||
{{ user.name }}
|
||||
{% if user.is_admin %}
|
||||
<span class="badge">{{ "Admin" | _ }}</span>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in New Issue