Skip to content

Commit 7356e51

Browse files
committed
creatibutors: added config for identifiers scheme
1 parent f96a443 commit 7356e51

File tree

3 files changed

+66
-36
lines changed

3 files changed

+66
-36
lines changed

invenio_app_rdm/config.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,25 @@ def github_link_render(record):
994994
APP_RDM_ADMIN_EMAIL_RECIPIENT = "[email protected]"
995995
"""Admin e-mail"""
996996

997+
APP_RDM_IDENTIFIER_SCHEMES_UI = {
998+
"orcid": {
999+
"url_prefix": "http://orcid.org/",
1000+
"icon": "images/orcid.svg",
1001+
"label": "ORCID",
1002+
},
1003+
"ror": {
1004+
"url_prefix": "https://ror.org/",
1005+
"icon": "images/ror-icon.svg",
1006+
"label": "ROR",
1007+
},
1008+
"gnd": {
1009+
"url_prefix": "http://d-nb.info/gnd/",
1010+
"icon": "images/gnd-icon.svg",
1011+
"label": "GND",
1012+
},
1013+
}
1014+
"""Identifier Schemes UI config"""
1015+
9971016
# Invenio-Communities
9981017
# ===================
9991018

invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/creatibutors.html

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,33 @@
1111
{% macro creatibutor_icon(creatibutor) %}
1212
{% set identifier_found = namespace(value=False) %}
1313

14-
{% for scheme, identifier in creatibutor.person_or_org.identifiers|groupby("scheme") %}
15-
{%- if scheme == "orcid" %}
16-
{% set identifier_found.value = True %}
17-
<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') }}">
18-
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/orcid.svg') }}" alt="ORCID icon"/>
19-
</a>
20-
{%- elif scheme == "ror" %}
21-
{% set identifier_found.value = True %}
22-
<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') }}">
23-
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/ror-icon.svg') }}" alt="ROR icon"/>
24-
</a>
25-
{%- elif scheme == "gnd" %}
26-
{% set identifier_found.value = True %}
27-
<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') }}">
28-
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/gnd-icon.svg') }}" alt="GND icon"/>
29-
</a>
30-
{%- endif %}
31-
{% endfor %}
14+
{% if config.APP_RDM_IDENTIFIER_SCHEMES_UI %}
15+
{% for scheme, details in config.APP_RDM_IDENTIFIER_SCHEMES_UI.items() %}
16+
{% for identifier in creatibutor.person_or_org.identifiers|selectattr("scheme", "equalto", scheme) %}
17+
{% set identifier_found.value = True %}
18+
<a href="{{ identifier.identifier|pid_url(scheme) }}"
19+
aria-label="{{ creatibutor.person_or_org.name }}'s {{ details.label }} {{ _('profile') }}"
20+
title="{{ creatibutor.person_or_org.name }}'s {{ details.label }} {{ _('profile') }}">
21+
<img class="ml-5 inline-id-icon"
22+
src="{{ url_for('static', filename=details.icon) }}"
23+
alt="{{ details.label }} icon"/>
24+
</a>
25+
{% endfor %}
26+
{% endfor %}
27+
{% endif %}
3228

33-
{# if no identifiers: distinguish btw people and organizations #}
34-
{%- if not identifier_found.value and creatibutor.person_or_org.type == 'organizational'%}
35-
<i class="group icon"></i>
36-
{%- endif %}
29+
{# Fallback for missing identifiers #}
30+
{% if not identifier_found.value %}
31+
{% if creatibutor.person_or_org.type == 'organizational' %}
32+
<i class="group icon"></i>
33+
{% else %}
34+
<i class="user icon"></i>
35+
{% endif %}
36+
{% endif %}
3737
{% endmacro %}
3838

3939

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

8283
<section class="ui sixteen wide column content" id="{{ group }}-affiliations" aria-label="{{ _('Affiliations for') }} {{ group }}">
8384
<ul>
84-
{% for affiliation in affiliations %}
85-
<li>
86-
{{ affiliation[0] }}.
87-
88-
{% if affiliation[2] %}
85+
{% for affiliation in affiliations %}
86+
<li>
87+
{{ affiliation[0] }}.
88+
89+
{% if affiliation[2] %}
90+
{% set scheme, identifier = (affiliation[2].split(':', 1) if ':' in affiliation[2] else ('ror', affiliation[2])) %}
91+
{% set scheme_config = config.APP_RDM_IDENTIFIER_SCHEMES_UI.get(scheme) %}
92+
93+
{% if scheme_config %}
8994
<a class="no-text-decoration"
90-
href="https://ror.org/{{affiliation[2]}}"
91-
aria-label="{{ affiliation[1] }}'s ROR {{ _('profile') }}"
92-
title="{{ affiliation[1] }}'s ROR {{ _('profile') }}"
95+
href="{{ scheme_config.url_prefix + identifier }}"
96+
aria-label="{{ affiliation[1] }}'s {{ scheme_config.label }} {{ _('profile') }}"
97+
title="{{ affiliation[1] }}'s {{ scheme_config.label }} {{ _('profile') }}"
9398
>
94-
<img class="ml-5 inline-id-icon" src="{{ url_for('static', filename='images/ror-icon.svg') }}" alt="ROR icon"/>
99+
<img class="ml-5 inline-id-icon"
100+
src="{{ url_for('static', filename=scheme_config.icon) }}"
101+
alt="{{ scheme_config.label }} icon"
102+
/>
95103
</a>
96-
{%- endif %}
97-
{{affiliation[1]}}
98-
</li>
104+
{% endif %}
105+
{% endif %}
106+
107+
{{ affiliation[1] }}
108+
</li>
99109
{% endfor %}
110+
100111
</ul>
101112
</section>
102113
{% endmacro %}

invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/header.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ <h1 class="ui medium header" aria-label="{{ _('Your dashboard') }}">{{ current_u
2323
</div>
2424
</div>
2525
{% if active_dashboard_menu_item == "uploads" %}
26-
<a class="ui tiny button positive left labeled icon m-0" href={{ url_for("deposit_create") }}>
26+
<a class="ui tiny button positive left labeled icon m-0" href={{ url_for("invenio_app_rdm_records.deposit_create") }}>
2727
<i class="upload icon" aria-hidden="true"></i>
2828
{{ _('New upload') }}
2929
</a>
3030
{% endif %}
3131

3232
{% if active_dashboard_menu_item == "communities" %}
33-
<a class="ui tiny button positive left labeled icon m-0" href={{ url_for("communities_new") }}>
33+
<a class="ui tiny button positive left labeled icon m-0" href={{ url_for("invenio_communities.communities_new") }}>
3434
<i class="plus icon" aria-hidden="true"></i>
3535
{{ _('New community') }}
3636
</a>

0 commit comments

Comments
 (0)