Merge pull request #1250 from bookwyrm-social/author-list

Limit authors displayed in status
This commit is contained in:
Mouse Reeve 2021-08-04 13:51:50 -06:00 committed by GitHub
commit cf53291d1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 3 deletions

View file

@ -1,9 +1,16 @@
{% spaceless %} {% spaceless %}
{% load i18n %}
{% load humanize %}
{% comment %} {% comment %}
@todo The author property needs to be an Organization or a Person. Well be using Thing which is the more generic ancestor. @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 @see https://schema.org/Author
{% endcomment %} {% 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 <a
href="{{ author.local_path }}" href="{{ author.local_path }}"
class="author" class="author"
@ -12,6 +19,14 @@
itemtype="https://schema.org/Thing" itemtype="https://schema.org/Thing"
><span ><span
itemprop="name" 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 %} {% endfor %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endspaceless %} {% endspaceless %}

View file

@ -1,8 +1,15 @@
{% load i18n %} {% load i18n %}
{% load utilities %} {% load utilities %}
{% spaceless %}
{% if book.authors %} {% 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 %} {% else %}
<a href="{{ book.local_path }}">{{ book|book_title }}</a> <a href="{{ book.local_path }}">{{ book|book_title }}</a>
{% endif %} {% endif %}
{% endspaceless %}