Skip to content

Commit

Permalink
creatibutors: added config for identifiers scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
0einstein0 authored and slint committed Nov 27, 2024
1 parent ab81bd4 commit 61f87db
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 34 deletions.
19 changes: 19 additions & 0 deletions invenio_app_rdm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,25 @@ def github_link_render(record):
APP_RDM_ADMIN_EMAIL_RECIPIENT = "[email protected]"
"""Admin e-mail"""

APP_RDM_IDENTIFIER_SCHEMES_UI = {
"orcid": {
"url_prefix": "http://orcid.org/",
"icon": "images/orcid.svg",
"label": "ORCID",
},
"ror": {
"url_prefix": "https://ror.org/",
"icon": "images/ror-icon.svg",
"label": "ROR",
},
"gnd": {
"url_prefix": "http://d-nb.info/gnd/",
"icon": "images/gnd-icon.svg",
"label": "GND",
},
}
"""Identifier Schemes UI config"""

# Invenio-Communities
# ===================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,33 @@
{% 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 config.APP_RDM_IDENTIFIER_SCHEMES_UI %}
{% for scheme, details in config.APP_RDM_IDENTIFIER_SCHEMES_UI.items() %}
{% for identifier in creatibutor.person_or_org.identifiers|selectattr("scheme", "equalto", scheme) %}
{% set identifier_found.value = True %}
<a href="{{ identifier.identifier|pid_url(scheme) }}"
aria-label="{{ creatibutor.person_or_org.name }}'s {{ details.label }} {{ _('profile') }}"
title="{{ creatibutor.person_or_org.name }}'s {{ details.label }} {{ _('profile') }}">
<img class="ml-5 inline-id-icon"
src="{{ url_for('static', filename=details.icon) }}"
alt="{{ details.label }} icon"/>
</a>
{% endfor %}
{% endfor %}
{% endif %}

{# 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 %}
{# Fallback for missing identifiers #}
{% if not identifier_found.value %}
{% if creatibutor.person_or_org.type == 'organizational' %}
<i class="group icon"></i>
{% else %}
<i class="user icon"></i>
{% endif %}
{% endif %}
{% endmacro %}



{% macro show_creatibutors(creatibutors, show_affiliations=False, type="creators", show_role=False) %}
{% for creatibutor in creatibutors %}
<li class="creatibutor-wrap separated">
Expand Down Expand Up @@ -81,22 +82,32 @@

<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] %}
{% for affiliation in affiliations %}
<li>
{{ affiliation[0] }}.

{% if affiliation[2] %}
{% set scheme, identifier = (affiliation[2].split(':', 1) if ':' in affiliation[2] else ('ror', affiliation[2])) %}
{% set scheme_config = config.APP_RDM_IDENTIFIER_SCHEMES_UI.get(scheme) %}

{% if scheme_config %}
<a class="no-text-decoration"
href="https://ror.org/{{affiliation[2]}}"
aria-label="{{ affiliation[1] }}'s ROR {{ _('profile') }}"
title="{{ affiliation[1] }}'s ROR {{ _('profile') }}"
href="{{ scheme_config.url_prefix + identifier }}"
aria-label="{{ affiliation[1] }}'s {{ scheme_config.label }} {{ _('profile') }}"
title="{{ affiliation[1] }}'s {{ scheme_config.label }} {{ _('profile') }}"
>
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/ror-icon.svg') }}" alt="ROR icon"/>
<img class="ml-5 inline-id-icon"
src="{{ url_for('static', filename=scheme_config.icon) }}"
alt="{{ scheme_config.label }} icon"
/>
</a>
{%- endif %}
{{affiliation[1]}}
</li>
{% endif %}
{% endif %}

{{ affiliation[1] }}
</li>
{% endfor %}

</ul>
</section>
{% endmacro %}

0 comments on commit 61f87db

Please sign in to comment.