*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit f6398c7c authored by Moser, Maximilian's avatar Moser, Maximilian
Browse files

Use managed PIDs as primary source for DOIs

* use DOIs defined in the metadata only as a fallback if the record has
  no managed PIDs
parent 5d31541c
No related branches found
No related tags found
1 merge request!8Refactoring/Modernization
......@@ -18,7 +18,7 @@
{%- set metadata = record.metadata %}
{%- block tuw_metadata %}
{%- set schemaorg_metadata = tuw_create_schemaorg_metadata(metadata) %}
{%- set schemaorg_metadata = tuw_create_schemaorg_metadata(record) %}
{%- if schemaorg_metadata %}
<script type="application/ld+json" nonce="{{ csp_nonce() }}">
{{ schemaorg_metadata|safe }}
......
......@@ -28,7 +28,14 @@
<div class="one column row">
<div class="column left aligned">
<p class="text-muted font-small">
{%- set doi = metadata.identifiers|tuw_doi_identifier -%}
{%- set doi = None -%}
{%- if record and record.pids and record.pids.doi -%}
{%- set doi = record.pids.doi.identifier -%}
{%- endif -%}
{%- if not doi -%}
{%- set doi = metadata.identifiers|tuw_doi_identifier -%}
{%- endif -%}
{%- if doi -%}
DOI: <a href="https://doi.org/{{ doi }}">{{ doi }}</a>
{%- else -%}
......
......@@ -126,11 +126,17 @@ def create_blueprint(app):
return text
@blueprint.app_template_global("tuw_create_schemaorg_metadata")
def tuw_create_schemaorg_metadata(record_metadata):
def tuw_create_schemaorg_metadata(record):
"""Create schema.org metadata to include in a <script> tag."""
doi = tuw_doi_identifier(record_metadata.get("identifiers"))
metadata = None
# get the DOI from the managed PIDs, or from the metadata as fallback
rec_pids = record.get("pids", {})
if "doi" in rec_pids:
doi = rec_pids["doi"].get("identifier")
else:
doi = tuw_doi_identifier(record.metadata.get("identifiers"))
if doi is not None:
doi_url = (
doi if doi.startswith("https://") else ("https://doi.org/%s" % doi)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment