Merge pull request #50 from stephenburgess8/master

Fallback to username if no display name is available
This commit is contained in:
Baptiste Gelez 2018-06-12 18:33:10 +01:00 committed by GitHub
commit 2f07ee92e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 8 deletions

View file

@ -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 %}
<div class="card">
<h3><a href="{{ article.url }}">{{ article.post.title }}</a></h3>
<main><p>{{ article.post.content | striptags | truncate(length=200) }}</p></main>
<p>By <a href="/@/{{ article.author.fqn }}/">{{ article.author.display_name }}</a> ⋅ {{ article.date | date(format="%B %e") }}</p>
<p>By <a href="/@/{{ article.author.fqn }}/">{{ name }}</a> ⋅ {{ article.date | date(format="%B %e") }}</p>
</div>
{% endmacro post_card %}

View file

@ -8,9 +8,15 @@
<a href="../">{{ blog.title }}</a>
{% endblock header %}
{% if author.display_name %}
{% set name = author.display_name %}
{% else %}
{% set name = author.username %}
{% endif %}
{% block content %}
<p>
<b>Written by <a href="/@/{{ author.fqn }}/">{{ author.display_name }}</a></b>
<b>Written by <a href="/@/{{ author.fqn }}/">{{ name }}</a></b>
&mdash;
<span>{{ date | date(format="%B %e, %Y") }}</span>
</p>
@ -49,8 +55,13 @@
<h2>Comments</h2>
<div class="list">
{% for comment in comments %}
{% if comment.author.display_name %}
{% set comment_author_name = comment.author.display_name %}
{% else %}
{% set comment_author_name = comment.author.username %}
{% endif %}
<div class="card" id="comment-{{ comment.id }}">
<b>{{ comment.author.display_name }}</b>
<b>{{ comment_author_name }}</b>
<div>{{ comment.content | safe }}</div>
<a href="comment?responding_to={{ comment.id }}">Respond</a>
</div>

View file

@ -1,14 +1,20 @@
{% extends "base" %}
{% import "macros" as macros %}
{% if user.display_name %}
{% set name = user.display_name %}
{% else %}
{% set name = user.username %}
{% endif %}
{% block title %}
{{ user.display_name }}
{{ name }}
{% endblock title %}
{% block content %}
<div>
<h1>
{{ user.display_name }}
{{ name }}
{% if user.is_admin %}
<span class="badge">Admin</span>
{% endif %}

View file

@ -1,13 +1,19 @@
{% extends "base" %}
{% if user.display_name %}
{% set name = user.display_name %}
{% else %}
{% set name = user.username %}
{% endif %}
{% block title %}
{{ user.display_name }}'s Followers
{{ name }}'s Followers
{% endblock title %}
{% block content %}
<div>
<h1>
{{ user.display_name }}
{{ name }}
{% if user.is_admin %}
<span class="badge">Admin</span>
{% endif %}
@ -21,8 +27,13 @@
<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.ap_url }}/">{{ follower.display_name }}</a> &mdash; @{{ follower.fqn }}</h3>
<h3><a href="{{ follower.ap_url }}/">{{ follower_name }}</a> &mdash; @{{ follower.fqn }}</h3>
<main><p>{{ follower.summary | safe }}</p></main>
</div>
{% endfor %}