SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 66dc1cae authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Alter displaying for citations

parent 9b1035f5
No related branches found
No related tags found
No related merge requests found
...@@ -2,15 +2,17 @@ ...@@ -2,15 +2,17 @@
{% load metacore_extras %} {% load metacore_extras %}
<div class="submission_title"> <div class="submission_title">
<!-- <h5 class="pb-0 subject_area">{{ submission.get_subject_area_display }}</h5> --> <h3 class="card-title mb-0 submisssion_title">{{ citable.title }}</h3>
<h3 class="card-title mb-0 submisssion_title"> <div class="author_list mb-0">by {{ citable.authors|join_authors_list:16 }}
{{ citable.title }} {% if citable.authors|length > 16 %}
</h3> &middot; <a href="javascript:;" data-toggle="toggle" data-target="#authors-{{ citable.id }}">See all authors</a>
<p class="mb-3 author_list">by {{ citable.authors|truncate_list:10 }}</p> <div style="display: none;" id="authors-{{ citable.id }}" class="py-2">{{ citable.authors|join_authors_list }}</div>
{% endif %}
</div>
</div> </div>
{% block card_footer %} {% block card_footer %}
<p class="text-muted mb-0"> <p class="text-muted mb-0 mt-3">
Cited {{ citable.crossref_ref_count|intcomma }} times (CrossRef) / {{ citable.times_cited|intcomma }} times (SciPost Meta) Cited {{ citable.crossref_ref_count|intcomma }} times (CrossRef) / {{ citable.times_cited|intcomma }} times (SciPost Meta)
&middot; doi: <a href="//doi.org/{{ citable.doi }}" target="_blank">{{ citable.doi }}</a> &middot; doi: <a href="//doi.org/{{ citable.doi }}" target="_blank">{{ citable.doi }}</a>
<br> <br>
......
...@@ -8,9 +8,10 @@ register = template.Library() ...@@ -8,9 +8,10 @@ register = template.Library()
@register.filter @register.filter
def truncate_list(authors, max_n): def join_authors_list(authors, max_n=None):
""" Returns author list, truncated to max_n authors when the list is longer """ """ Returns authors list as string, truncated to max_n authors when the list is longer."""
if max_n and max_n < len(authors): if max_n and max_n < len(authors):
return '; '.join(authors[:max_n]) + ' et al.' return ', '.join(authors[:max_n - 1]) + ' ... ' + authors[-1]
else: elif len(authors) > 1:
return '; '.join(authors) return ', '.join(authors[:-1]) + ' and ' + authors[-1]
return authors[0]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment