Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix commas in author list #770

Merged
merged 9 commits into from
Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ scholar:
# Filter out certain bibtex entry keywords used internally from the bib output
filtered_bibtex_keywords: [abbr, abstract, arxiv, bibtex_show, html, pdf, selected, supp, blog, code, poster, slides, website, preview]

# Maximum number of authors to be shown, other authors will be visible on hover, leave blank to show all authors
max_author_limit: 3
# Maximum number of authors to be shown for each publication (more authors are visible on click)
max_author_limit: 3 # leave blank to always show all authors
more_authors_animation_delay: 10 # more authors are revealed on click using animation; smaller delay means faster animation


# -----------------------------------------------------------------------------
# Responsive WebP Images
Expand Down
80 changes: 31 additions & 49 deletions _layouts/bib.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,76 +29,58 @@
<div class="author">
{% assign author_array_size = entry.author_array | size %}

{% assign author_array_limit = author_array_size %}
{%- if site.max_author_limit and author_array_size > site.max_author_limit %}
{% assign author_array_limit = site.max_author_limit %}
{% else %}
{% assign author_array_limit = author_array_size %}
{% endif %}

{%- for author in entry.author_array limit: author_array_limit -%}
{%- assign author_is_self = false -%}
{%- if author.last == site.scholar.last_name %}
{%- assign author_last_name = author.last | remove: "¶" | remove: "&" | remove: "*" | remove: "†" | remove: "^" -%}
{%- if author_last_name == site.scholar.last_name -%}
{%- if site.scholar.first_name contains author.first -%}
{%- assign author_is_self = true -%}
{%- endif -%}
{%- endif -%}
{%- assign coauthor_url = nil -%}
{%- if site.data.coauthors[author.last] -%}
{%- for coauthor in site.data.coauthors[author.last] -%}
{%- if site.data.coauthors[author_last_name] -%}
{%- for coauthor in site.data.coauthors[author_last_name] -%}
{%- if coauthor.firstname contains author.first -%}
{%- assign coauthor_url = coauthor.url -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}

{%- if forloop.length == 1 -%}
{%- if author_is_self %}
<em>{{author.last}}, {{author.first}}</em>
{%- else -%}
{{author.last}}, {{author.first}}
{%- endif -%}
{%- if forloop.length > 1 -%}
{%- if forloop.first == false -%},&nbsp;{%- endif -%}
{%- if forloop.last and author_array_limit == author_array_size -%}and&nbsp;{%- endif -%}
{%- endif -%}
{%- if author_is_self -%}
<em>{{author.first}} {{author.last}}</em>
{%- else -%}
{%- unless forloop.last -%}
{% if author_is_self %}
<em>{{author.last}}, {{author.first}}</em>,&nbsp;
{%- else -%}
{% if coauthor_url -%}
<a href="{{coauthor_url}}">{{author.last}}, {{author.first}}</a>,&nbsp;
{%- else -%}
{{author.last}}, {{author.first}},&nbsp;
{%- endif -%}
{%- endif -%}
{%- if coauthor_url -%}
<a href="{{coauthor_url}}">{{author.first}} {{author.last}}</a>
{%- else -%}
{%- if author_array_limit == author_array_size %} and {% endif %}
{% if author_is_self -%}
<em>{{author.last}}, {{author.first}}</em>
{% else -%}
{%- if coauthor_url -%}
<a href="{{coauthor_url}}">{{author.last}}, {{author.first}}</a>
{% else -%}
{{author.last}}, {{author.first}}
{%- endif -%}
{%- endif -%}
{%- endunless -%}
{{author.first}} {{author.last}}
{%- endif -%}
{%- endif -%}
{%- endfor %}

{% assign more_authors = author_array_size | minus: author_array_limit %}

{%- if more_authors > 0 %}
{% assign more_authors_hide = more_authors | append: " more author" %}
{% if more_authors > 1 %}
{% assign more_authors_hide = more_authors_hide | append: "s" %}
{% endif %}
{% assign more_authors_show = '' %}
{%- endfor -%}
{%- assign more_authors = author_array_size | minus: author_array_limit -%}

{%- assign more_authors_hide = more_authors | append: " more author" -%}
{%- if more_authors > 0 -%}
{%- if more_authors > 1 -%}
{%- assign more_authors_hide = more_authors_hide | append: "s" -%}
{%- endif -%}
{%- assign more_authors_show = '' -%}
{%- for author in entry.author_array offset: author_array_limit -%}
{% assign more_authors_show = more_authors_show | append: author.last | append: ", " | append: author.first %}
{% unless forloop.last %}
{% assign more_authors_show = more_authors_show | append: ",&nbsp;" %}
{% endunless %}
{%- assign more_authors_show = more_authors_show | append: author.first | append: " " | append: author.last -%}
{%- unless forloop.last -%}
{%- assign more_authors_show = more_authors_show | append: ", " -%}
{%- endunless -%}
{%- endfor -%}
and
, and
<span
class="more-authors"
title="click to view {{more_authors_hide}}"
Expand All @@ -112,10 +94,10 @@
if (++cursorPosition == more_authors_text.length){
clearInterval(textAdder);
}
}, 15);
}, '{{site.more_authors_animation_delay}}');
"
>{{more_authors_hide}}</span>
{% endif %}
{%- endif -%}

</div>

Expand Down