Skip to content

Commit

Permalink
documents: add a configuration for links on identifiers
Browse files Browse the repository at this point in the history
* Closes rero#711.

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Feb 16, 2022
1 parent 7eebf8e commit 729a185
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
10 changes: 10 additions & 0 deletions sonar/config_sonar.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,3 +574,13 @@

SONAR_APP_SWISSCOVERY_SEARCH_URL = 'https://swisscovery.slsp.ch/view/sru/41SLSP_NETWORK'
SONAR_APP_SWISSCOVERY_SEARCH_VERSION = '1.1'

# Link on document identifier
SONAR_APP_DOCUMENT_IDENTIFIER_LINK = {
'bf:Doi': {
'default': 'https://doi.org/_identifier_'
},
'bf:Local': {
'swisscovery': 'https://swisscovery.slsp.ch/permalink/41SLSP_NETWORK/1ufb5t2/alma_identifier_'
}
}
12 changes: 2 additions & 10 deletions sonar/modules/documents/templates/documents/record.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

{%- extends config.RECORDS_UI_BASE_TEMPLATE %}

{% from 'sonar/macros/macro.html' import thumbnail %}
{% from 'sonar/macros/macro.html' import thumbnail, identifier_link %}

{% set title = record.title[0] | title_format(current_i18n.language) %}
{% set description = record.abstracts[0].value if record.abstracts else None %}
Expand Down Expand Up @@ -253,15 +253,7 @@ <h5 class="d-inline">
<ul class="list-unstyled mb-0">
{% for identifier in record.identifiedBy %}
<li>
<span class="badge badge-secondary text-light mr-1">{{ _(identifier.type) }}</span>
{% if identifier.type == 'bf:Doi' %}
<a href="https://doi.org/{{ identifier.value }}" target="_blank">{{ identifier.value }}</a>
{% else %}
{{ identifier.value }}
{% endif %}
{% if identifier.source %}
<i class="text-muted ml-1">{{ identifier.source }}</i>
{% endif %}
{{ identifier_link(identifier) }}
</li>
{% endfor %}
</ul>
Expand Down
18 changes: 18 additions & 0 deletions sonar/theme/templates/sonar/macros/macro.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,21 @@
<img src="{{ image }}" class="img-fluid" alt="{{ label }}">
{% endif%}
{% endmacro %}

{% macro identifier_link(identifier) %}
<span class="badge badge-secondary text-light mr-1">{{ _(identifier.type) }}</span>
{% if identifier.type in config.SONAR_APP_DOCUMENT_IDENTIFIER_LINK %}
{% set source = 'default' if not identifier.source else identifier.source %}
{% if source in config.SONAR_APP_DOCUMENT_IDENTIFIER_LINK[identifier.type] %}
{% set link = config.SONAR_APP_DOCUMENT_IDENTIFIER_LINK[identifier.type][source] %}
<a href="{{ link.replace('_identifier_', identifier.value) }}" title="{{ _('External link to the source') }}" target="_blank">{{ identifier.value }}</a>
{% else %}
{{ identifier.value }}
{% endif %}
{% else %}
{{ identifier.value }}
{% endif %}
{% if identifier.source %}
<i class="text-muted ml-1">{{ identifier.source }}</i>
{% endif %}
{% endmacro %}

0 comments on commit 729a185

Please sign in to comment.