Limit authors displayed in status

This commit is contained in:
Mouse Reeve 2021-08-04 12:36:54 -07:00
parent a13db6adc3
commit a679a46bca
2 changed files with 25 additions and 3 deletions

View file

@ -1,9 +1,16 @@
{% spaceless %}
{% load i18n %}
{% load humanize %}
{% comment %}
@todo The author property needs to be an Organization or a Person. Well be using Thing which is the more generic ancestor.
@see https://schema.org/Author
{% endcomment %}
{% for author in book.authors.all %}
{% firstof limit None as limit %}
{% with subtraction_value='-'|add:limit %}
{% with remainder_count=book.authors.count|add:subtraction_value %}
{% with remainder_count_display=remainder_count|intcomma %}
{% for author in book.authors.all|slice:limit %}
<a
href="{{ author.local_path }}"
class="author"
@ -12,6 +19,14 @@
itemtype="https://schema.org/Thing"
><span
itemprop="name"
>{{ author.name }}<span></a>{% if not forloop.last %}, {% endif %}
>{{ author.name }}<span></a>{% if not forloop.last %}, {% elif remainder_count > 0 %}, {% blocktrans trimmed count counter=remainder_count %}
and {{ remainder_count_display }} other
{% plural %}
and {{ remainder_count_display }} others
{% endblocktrans %}{% endif %}
{% endfor %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endspaceless %}

View file

@ -1,8 +1,15 @@
{% load i18n %}
{% load utilities %}
{% spaceless %}
{% if book.authors %}
{% blocktrans with path=book.local_path title=book|book_title %}<a href="{{ path }}">{{ title }}</a> by {% endblocktrans %}{% include 'snippets/authors.html' with book=book %}
{% blocktrans trimmed with path=book.local_path title=book|book_title %}
<a href="{{ path }}">{{ title }}</a> by
{% endblocktrans %}
{% include 'snippets/authors.html' with book=book limit=3 %}
{% else %}
<a href="{{ book.local_path }}">{{ book|book_title }}</a>
{% endif %}
{% endspaceless %}