www-from-model/page_templates/instrument.md.j2
Stephan Heunis 91720317ca
All checks were successful
Deploy on webserver / Build site and deploy on success (push) Successful in 1m12s
Introduce term page template generalizations
Along the same lines as 478015 which introduced a generalization for the taxonomy list page,
this commit generalizes the term page template, so that we can remove all duplicates for
taxonomy-specific layout templates.

Several new partials are introduced that are now used in a term page heading and info section,
specifically for the date, identifiers, links, licenses, and related terms such as persons or
topics. These same partials are also worked into the existing 'taxonomy-list-vertical-item'
partial to remove further redundant code. As part of these changes, new icons were added. Also
content has to be updated to change 'date_created' to 'date' in order to streamline its handling
in the single generalized template. The associated jinja templates were also updated with this
change.

The term page layout can be customized in the same taxonomy's '_index.md' page front matter as
is done for the taxonomy list page customization. Newly introduced options are all sub-properties
of the new 'term' property under 'params':

- 'person_display': When a list of persons are rendered for a given term, what should those
  people be called? This is a string value that defaults to 'Contributors'.
- 'depiction_type': The type of depiction that should be rendered for the given term page (and
  in 'taxonomy-list-vertical-item'), if such a file exists in the term bundle. This expects a
  string that will be matched against image files in the term bundle, and will default to 'depiction'.
  This option is necessary because the depiction registration workflow saves depiction files with
  names representing their types, e.g. 'portrait', 'logo', etc.
- 'show_relations': In which format should term relations be displayed at the bottom of the term page,
  if at all. The default is to display no relations (explicitly: 'none'). Other options include
  'expandable', which will show list of expandable taxonomy groups, each group containing all terms of
  that taxonomy that relate to the current term; and 'congo', which will render the Congo-theme default
  list of related terms.

Here are two example configurations for the term options:

'content/persons/_index.md':
---
title: Persons
params:
  term:
    depiction_type: portrait # portrait | logo | depiction (default)
    show_relations: expandable # expandable | congo | none (default)
---

'content/publications/_index.md':
---
title: Publications
params:
  term:
    person_display: Authors # defaults to 'Contributors'
---

Finally, new config is added to several taxonomy index pages to perform these customizations for terms:
- persons: should render the 'portrait' depiction type and show expandable relations
- publications: display persons as 'Authors'
- instruments: should render the 'logo' depiction type
2026-05-31 23:56:10 +02:00

80 lines
2.6 KiB
Django/Jinja

{% extends "page.md.j2" %}
{%- set doi = (
__rec.identifiers
| selectattr('schema_type', 'equalto', 'dlthings:DOI')
| list
| first
) if __rec.identifiers is defined and __rec.identifiers is sequence else none -%}
{%- set generation = (
__rec.generated_by
| selectattr('at_time')
| list
| first
) if __rec.generated_by is defined and __rec.generated_by is sequence else none -%}
{%- set source_code = (
__rec.attributes
| selectattr('predicate', 'equalto', 'obo:APOLLO_SV_00000488')
| list
| first
) if __rec.attributes is defined and __rec.attributes is sequence else none -%}
{%- set documentation = (
__rec.attributes
| selectattr('predicate', 'equalto', 'obo:NGBO_6000416')
| list
| first
) if __rec.attributes is defined and __rec.attributes is sequence else none -%}
{%- set authors = [] -%}
{%- for auth in __rec.attributed_to -%}
{%- set _ = authors.append({
"pid": auth.object.pid | default(none),
"given_name": auth.object.given_name | default(none),
"family_name": auth.object.family_name | default(none)
}) if auth.object is defined and auth.object.schema_type == 'xyzri:XYZPerson' -%}
{%- endfor -%}
{%- set rules = [] -%}
{%- for r in __rec.rules -%}
{%- set _ = rules.append({
"pid": r.pid | default(none),
"label": r.display_label | default(none),
"url": r.pid | replace("spdxlic:","https://spdx.org/licenses/") | default(none),
}) -%}
{%- endfor -%}
{%- set topics = [] -%}
{%- for top in __rec.about -%}
{%- set _ = topics.append({
"pid": top.pid | default(none),
"display_label": top.display_label | default(none)
}) -%}
{%- endfor -%}
{%- set instrument = {
"pid": __rec.pid | default(none),
"doi": doi.notation | default(none) if doi else none,
"date": generation.at_time | default(none) if generation else none,
"source_code_url": source_code.value | default(none) if source_code else none,
"documentation_url": documentation.value | default(none) if documentation else none,
"title": __rec.name | default(none),
"description": __rec.description | default(none),
"kind": __rec.kind.display_label | default(none) if __rec.kind else none,
"author": authors | default(none),
"topic": topics | default(none),
"license": rules | default(none)
} -%}
{% block frontmatter -%}
title: {{ instrument.title | toyaml | replace('...\n','') | trim }}
{{ taxonomy_terms('persons', 'xyzri:XYZPerson', attributed_to) -}}
{{ taxonomy_terms('topics', 'xyzri:XYZTopic', about, typeattr='schema_type', pidattr='pid') -}}
{% endblock -%}
{% block frontmatter_params %}
{{ instrument | toyaml | indent(2) | trim }}
{% endblock -%}