From 28925fa79557c9991361e86dd939f19df1f31843 Mon Sep 17 00:00:00 2001 From: Tom Morrell Date: Thu, 26 Sep 2024 22:18:15 +0000 Subject: [PATCH] Switch heading to funder on landing page --- .../records/macros/detail.html | 303 ++++++++++++++++++ 1 file changed, 303 insertions(+) create mode 100644 templates/semantic-ui/invenio_app_rdm/records/macros/detail.html diff --git a/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html b/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html new file mode 100644 index 0000000..2c1886a --- /dev/null +++ b/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html @@ -0,0 +1,303 @@ +{# + Copyright (C) 2020-2024 CERN. + Copyright (C) 2024 Northwestern 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 show_detail(title, value) %} +
{{ title }}
+
{{ value }}
+{%- endmacro %} + + +{% macro show_title_detail(title, language, value) %} +
+ {{ title }} + + {{ '(' + language + ')' if language }} + +
+
+ {{ value }} +
+{%- endmacro %} + + +{% macro show_sanitized_detail(title, value) %} +
{{ title }}
+
+ {{ value | sanitize_html()| safe }} +
+{%- endmacro %} + + +{% macro list_string_values(field, values) %} + {% for value in values %} + {% set search_url = field | custom_fields_search(value) %} + {% if search_url %} + {{ value }} {{ ", " if not loop.last }} + {% else %} + {{ value }}{{ ", " if not loop.last }} + {% endif %} + {% endfor %} +{% endmacro %} + + +{% macro show_add_titles(add_titles) %} + {% for add_title in add_titles %} + {% if add_title.lang %} + {{ show_title_detail(add_title.type.title_l10n, add_title.lang.title_l10n, add_title.title) }} + {% else %} + {{ show_title_detail(add_title.type.title_l10n,None, add_title.title) }} + {% endif %} + {% endfor %} +{% endmacro %} + + +{% macro show_add_descriptions(add_descriptions) %} + {% for add_description in add_descriptions %} +
+

{{ add_description.type.title_l10n }} {{ '(' + add_description.lang.title_l10n + ')' if add_description.lang }} +

+ + {% if add_description.type.id == "notes" %} +
+ {{ add_description.description | sanitize_html() | safe }} +
+ {% else %} + {{ add_description.description | sanitize_html() | safe }} + {% endif %} +
+ {% endfor %} +{% endmacro %} + + +{% macro show_dates(dates) %} + {% for date in dates %} +
{{ date.type.title_l10n }}
+
+
{{ date.date }}
+
{{ date.description }}
+
+ {% endfor %} +{% endmacro %} + + +{% macro show_funding(funding) %} + {% for fund in funding %} + {{ _show_funding_item(fund, loop.index0) }} + {% endfor %} +{% endmacro %} + + +{% macro _show_funding_item(item, index) %} +
{{ item.funder.name if item.funder }}
+ {%- if item.award -%} + + {%- if item.award.title_l10n -%} +
+ + {% if item.award.acronym %} + {{ item.award.acronym }} – + {% endif %} + + {{ item.award.title_l10n }} + + + {%- if item.award.number -%} + + {{ item.award.number }} + + {%- endif -%} + + {%- if item.award.identifiers -%} + {% for identifier in item.award.identifiers if 'url' == identifier.scheme %} + + + + {%- endfor -%} + {%- endif -%} +
+ {%- endif -%} + {%- endif -%} +{% endmacro %} + + +{% macro show_references(references) %} + +{% endmacro %} + + +{% macro _identifiers_for_group(related_identifiers) %} + {% for identifier in related_identifiers %} +
+ {% if identifier.resource_type is defined %} + {{ identifier.resource_type.title_l10n }}: + {% endif %} + + {% set url = identifier.identifier|pid_url %} + {% if url %} + + {{ identifier.identifier }} + + {% else %} + {{ identifier.identifier }} + {% endif %} + + {{ ' (' + identifier.scheme | get_scheme_label + ')' }} +
+ {% endfor %} +{% endmacro %} + + +{% macro show_related_identifiers(related_identifiers) %} +
+ {%- for group in related_identifiers | groupby('relation_type.title_l10n') %} +
{{ group.grouper }}
+ {{ _identifiers_for_group(group.list) }} + {%- endfor %} +
+{% endmacro %} + + +{% macro show_alternate_identifiers(identifiers) %} + {% for alt_id in identifiers %} +
{{ alt_id.scheme | get_scheme_label }}
+
+ {% set url = alt_id.identifier|pid_url(scheme=alt_id.scheme) %} + {% if url %} + + {{ alt_id.identifier }} + + {% else %} + {{ alt_id.identifier }} + {% endif %} +
+ {% endfor %} +{% endmacro %} + + +{% macro list_languages(languages) %} + {% for lang in languages %} + {{ lang.title_l10n }}{{ ", " if not loop.last }} + {% endfor %} +{% endmacro %} + +{% macro list_vocabulary_values(field, values, field_cfg) %} + {% if values.title_l10n is defined %} + {% set search_url = field | custom_fields_search(values.title_l10n, field_cfg) %} + {% if search_url %} + {{ values.title_l10n | safe }} + {% else %} + {{ values.title_l10n }} + {% endif %} + {% else %} + {% for value in values %} + {{ value.title_l10n }}{{ ", " if not loop.last }} + {% endfor %} + {% endif %} +{% endmacro %} + + +{% macro list_float_values(field, values) %} + {% for value in values %} + {% set search_url = field | custom_fields_search(value) %} + {% if search_url %} + {{ "%0.2f" | format(value) }}{{ " , " if not loop.last }} + {% else %} + {{ "%0.2f" | format(value) }}{{ ", " if not loop.last }} + {% endif %} + {% endfor %} +{% endmacro %} + + +{% macro show_section_custom_fields(custom_fields, section_fields) %} + {% for field_cfg in section_fields %} + {% set field_value = custom_fields.get(field_cfg.field) %} + {% if field_value %} + {% if field_cfg.template %} + {% include field_cfg.template %} + {% else %} +
+ {{ field_cfg.props.label }} + {% set namespace_url = field_cfg.display_url if field_cfg.display_url is defined else field_cfg.field | namespace_url %} + {% if namespace_url %} + + + + {% endif %} +
+ {% if field_value is string %} +
+ {% set search_url = (field_value | pid_url) if field_cfg.props.is_identifier else (field_cfg.field | custom_fields_search(field_value | safe)) %} + {% if search_url %} + {{ field_value | safe }} + {% else %} + {{ field_value | safe }} + {% endif %} +
+ {% elif field_value is boolean %} +
+ {% if field_value %} + {{ field_cfg.props.trueLabel }} + {% else %} + {{ field_cfg.props.falseLabel }} + {% endif %} +
+ {% elif field_cfg.is_vocabulary %} +
{{ list_vocabulary_values(field_cfg.field, field_value, field_cfg) }}
+ {% elif field_value is iterable and field_value|length > 0 and field_value[0] is string %} +
{{ list_string_values(field_cfg.field, field_value) }}
+ {% elif field_value is iterable and field_value|length > 0 and field_value[0] is number %} +
{{ list_float_values(field_cfg.field, field_value) }}
+ {% else %} +
{{ field_value }}
+ {% endif %} + {% endif %} + {% endif %} + {% endfor %} +{% endmacro %} + + +{% macro show_detail_conference(conference) %} +
+ {%- if conference.url %} + {{ conference.title }} {{ "("+conference.acronym+")" if conference.acronym else "" }} + + {%- else %} + {{ conference.title }} + {{ "("+conference.acronym+")" if conference.acronym else "" }} + {%- endif %} + {%- if conference.place %}, {{ conference.place }} {%- endif %} + {%- if conference.dates %}, {{ conference.dates }} {%- endif %} + {% if conference.session %}(Session + {{ conference.session }}{% if conference.session_part %}, Part + {{ conference.session_part }}{%- endif %}){%- endif %} +
+ {%- if conference.url and not conference.title %} +
{{ _('Conference website') }}
+ {%- endif %} +{% endmacro %}