From df0fcb886d19a756986ddd97bc9810d1317e1ed1 Mon Sep 17 00:00:00 2001 From: Stephen Burgess Date: Tue, 12 Jun 2018 07:17:02 -0500 Subject: [PATCH] feat(UI): Fallback to username where ever display name is shown --- templates/macros.html.tera | 7 ++++++- templates/posts/details.html.tera | 6 +++--- templates/users/details.html.tera | 8 ++++++-- templates/users/followers.html.tera | 17 ++++++++++++++--- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/templates/macros.html.tera b/templates/macros.html.tera index 4943265..900f96c 100644 --- a/templates/macros.html.tera +++ b/templates/macros.html.tera @@ -1,7 +1,12 @@ {% macro post_card(article) %} +{% if article.author.display_name %} + {% set name = article.author.display_name %} +{% else %} + {% set name = article.author.username %} +{% endif %}

{{ article.post.title }}

{{ article.post.content | striptags | truncate(length=200) }}

-

By {{ article.author.display_name }} ⋅ {{ article.date | date(format="%B %e") }}

+

By {{ name }} ⋅ {{ article.date | date(format="%B %e") }}

{% endmacro post_card %} diff --git a/templates/posts/details.html.tera b/templates/posts/details.html.tera index 1935da0..13e3e5a 100644 --- a/templates/posts/details.html.tera +++ b/templates/posts/details.html.tera @@ -55,12 +55,12 @@
{% for comment in comments %} {% if comment.author.display_name %} - {% set commentAuthorName = comment.author.display_name %} + {% set comment_author_name = comment.author.display_name %} {% else %} - {% set commentAuthorName = comment.author.username %} + {% set comment_author_name = comment.author.username %} {% endif %}
- {{ name }} + {{ comment_author_name }}
{{ comment.content | safe }}
Respond
diff --git a/templates/users/details.html.tera b/templates/users/details.html.tera index d225a30..1eb6325 100644 --- a/templates/users/details.html.tera +++ b/templates/users/details.html.tera @@ -2,13 +2,17 @@ {% import "macros" as macros %} {% block title %} -{{ user.display_name }} +{% if author.display_name %} + {% set name = author.display_name %} +{% else %} + {% set name = user.username %} +{% endif %} {% endblock title %} {% block content %}

- {{ user.display_name }} + {{ name }} {% if user.is_admin %} Admin {% endif %} diff --git a/templates/users/followers.html.tera b/templates/users/followers.html.tera index 5d6a956..9b0bdf2 100644 --- a/templates/users/followers.html.tera +++ b/templates/users/followers.html.tera @@ -1,13 +1,19 @@ {% extends "base" %} {% block title %} -{{ user.display_name }}'s Followers +{% if user.display_name %} + {% set name = user.display_name %} +{% else %} + {% set name = user.username %} +{% endif %} + +{{ name }}'s Followers {% endblock title %} {% block content %}

- {{ user.display_name }} + {{ name }} {% if user.is_admin %} Admin {% endif %} @@ -21,8 +27,13 @@

Followers

{% for follower in followers %} + {% if follower.display_name %} + {% set follower_name = follower.display_name %} + {% else %} + {% set follower_name = follower.username %} + {% endif %}
-

{{ follower.display_name }} — @{{ follower.fqn }}

+

{{ follower_name }} — @{{ follower.fqn }}

{{ follower.summary | safe }}

{% endfor %}