-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add creator roles and fix contributor linking
- Loading branch information
Showing
2 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
templates/semantic-ui/invenio_app_rdm/records/details/creatibutors.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{# | ||
Copyright (C) 2020 CERN. | ||
Copyright (C) 2020 Northwestern University. | ||
Copyright (C) 2021 TU Wien. | ||
|
||
Invenio RDM Records is free software; you can redistribute it and/or modify | ||
it under the terms of the MIT License; see LICENSE file for more details. | ||
#} | ||
|
||
{%- from "invenio_app_rdm/records/macros/creatibutors.html" import affiliations_accordion, show_creatibutors %} | ||
|
||
<div class="ui grid"> | ||
{% if record.ui.creators and record.ui.creators.creators %} | ||
<div class="row ui accordion affiliations"> | ||
<div class="sixteen wide mobile twelve wide tablet thirteen wide computer column mb-10"> | ||
<dl class="creatibutors" aria-label="{{ _('Creators list') }}"> | ||
<dt class="hidden">{{ _('Creators') }}</dt> | ||
{{ show_creatibutors(record.ui.creators.creators, show_affiliations=True, show_role=True) }} | ||
</dl> | ||
</div> | ||
|
||
{# Todo: get full list of all affiliations (both creators & contributors) e.g. | ||
record.ui.affiliation and merge to one accordion #} | ||
{% if record.ui.creators and record.ui.creators.affiliations %} | ||
{{ affiliations_accordion('creators', record.ui.creators.affiliations)}} | ||
{% endif %} | ||
|
||
</div> | ||
{% endif %} | ||
|
||
{% if record.ui.contributors and record.ui.contributors.contributors %} | ||
<div class="row ui accordion affiliations"> | ||
<div class="sixteen wide mobile twelve wide tablet thirteen wide computer column mb-10"> | ||
|
||
{%- for group in record.ui.contributors.contributors|groupby('role.title')%} | ||
<dl class="creatibutors" aria-label="{{ _('Contributors list') }}"> | ||
<dt class="text-muted">{{group.grouper}}{%- if group.list|length > 1 -%}s{%- endif -%}:</dt> | ||
{{ show_creatibutors(group.list, show_affiliations=True, type="contributors") }} | ||
</dl> | ||
{%- endfor %} | ||
</div> | ||
|
||
{% if record.ui.contributors and record.ui.contributors.affiliations %} | ||
{{ affiliations_accordion('contributors', record.ui.contributors.affiliations)}} | ||
{% endif %} | ||
|
||
</div> | ||
{% endif %} | ||
</div> |
102 changes: 102 additions & 0 deletions
102
templates/semantic-ui/invenio_app_rdm/records/macros/creatibutors.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{# | ||
Copyright (C) 2020 CERN. | ||
Copyright (C) 2020 Northwestern University. | ||
Copyright (C) 2021 Graz University of Technology. | ||
Copyright (C) 2021-2022 New York University. | ||
|
||
Invenio RDM Records is free software; you can redistribute it and/or modify | ||
it under the terms of the MIT License; see LICENSE file for more details. | ||
#} | ||
|
||
{% macro creatibutor_icon(creatibutor) %} | ||
{% set identifier_found = namespace(value=False) %} | ||
|
||
{% for scheme, identifier in creatibutor.person_or_org.identifiers|groupby("scheme") %} | ||
{%- if scheme == "orcid" %} | ||
{% set identifier_found.value = True %} | ||
<a class="no-text-decoration" href="{{ identifier[0]['identifier']|pid_url('orcid') }}" aria-label="{{ creatibutor.person_or_org.name }}'s ORCID {{ _('profile') }}" title="{{ creatibutor.person_or_org.name }}'s ORCID {{ _('profile') }}"> | ||
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/orcid.svg') }}" alt="ORCID icon"/> | ||
</a> | ||
{%- elif scheme == "ror" %} | ||
{% set identifier_found.value = True %} | ||
<a href="{{ identifier[0]['identifier']|pid_url('ror') }}" aria-label="{{ creatibutor.person_or_org.name }}'s ROR {{ _('profile') }}" title="{{ creatibutor.person_or_org.name }}'s ROR {{ _('profile') }}"> | ||
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/ror-icon.svg') }}" alt="ROR icon"/> | ||
</a> | ||
{%- elif scheme == "gnd" %} | ||
{% set identifier_found.value = True %} | ||
<a href="{{ identifier[0]['identifier']|pid_url('gnd') }}" aria-label="{{ creatibutor.person_or_org.name }}'s GND {{ _('profile') }}" title="{{ creatibutor.person_or_org.name }}'s GND {{ _('profile') }}"> | ||
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/gnd-icon.svg') }}" alt="GND icon"/> | ||
</a> | ||
{%- endif %} | ||
{% endfor %} | ||
|
||
{# if no identifiers: distinguish btw people and organizations #} | ||
{%- if not identifier_found.value and creatibutor.person_or_org.type == 'organizational'%} | ||
<i class="group icon"></i> | ||
{%- endif %} | ||
{% endmacro %} | ||
|
||
|
||
{% macro show_creatibutors(creatibutors, show_affiliations=False, type="creators", show_role=False) %} | ||
{% for creatibutor in creatibutors %} | ||
<dd class="creatibutor-wrap separated"> | ||
<a class="ui creatibutor-link" | ||
{% if show_affiliations and creatibutor.affiliations %} | ||
data-tooltip="{{ creatibutor.affiliations|join('; ', attribute='1') }}" | ||
{% endif %} | ||
href="{{url_for('invenio_search_ui.search', q='metadata.' + type + '.person_or_org.name:"' + creatibutor.person_or_org.name + '"')}}" | ||
> | ||
|
||
<span class="creatibutor-name"> | ||
{{- creatibutor.person_or_org.name -}} | ||
{% if show_role and creatibutor.role %} | ||
({{- creatibutor.role.title -}}) | ||
{%- endif -%} | ||
</span> | ||
{%- if creatibutor.affiliations -%} | ||
<sup class="font-tiny"> | ||
{%- for affiliation in creatibutor.affiliations -%} | ||
{{ affiliation[0] }}{{ ", " if not loop.last }} | ||
{%- endfor -%} | ||
</sup> | ||
{%- endif -%} | ||
</a> | ||
{{- creatibutor_icon(creatibutor) -}} | ||
</dd> | ||
{% endfor %} | ||
{%- endmacro %} | ||
|
||
|
||
{% macro affiliations_accordion(group, affiliations) %} | ||
<div class="ui sixteen wide tablet three wide computer column title right aligned bottom aligned"> | ||
<button class="ui affiliations-button trigger button mini mr-0" | ||
aria-controls="{{ group }}-affiliations" | ||
data-open-text="{{_('Show affiliations')}}" | ||
data-close-text="{{ _('Hide affiliations') }}" | ||
aria-expanded="false" | ||
> | ||
{{ _("Show affiliations") }} | ||
</button> | ||
</div> | ||
|
||
<section class="ui sixteen wide column content" id="{{ group }}-affiliations" aria-label="{{ _('Affiliations for') }} {{ group }}"> | ||
<ul> | ||
{% for affiliation in affiliations %} | ||
<li> | ||
{{ affiliation[0] }}. | ||
|
||
{% if affiliation[2] %} | ||
<a class="no-text-decoration" | ||
href="https://ror.org/{{affiliation[2]}}" | ||
aria-label="{{ affiliation[1] }}'s ROR {{ _('profile') }}" | ||
title="{{ affiliation[1] }}'s ROR {{ _('profile') }}" | ||
> | ||
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/ror-icon.svg') }}" alt="ROR icon"/> | ||
</a> | ||
{%- endif %} | ||
{{affiliation[1]}} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</section> | ||
{% endmacro %} |