www-from-model/page_templates/dataset.md.j2
Stephan Heunis 804b7800bd
All checks were successful
Deploy on webserver / Build site and deploy on success (push) Successful in 3m29s
Update dataset generation workflow and template to show distributions
To demo the new distriubution/filetree functionality, the workflow is updated to
inline characterized_by statements, which is filtered in the updated jinja template.
The filtering retains objects where the predicate is 'dcat:distribution' and then
does a bit more wrangling to get distributions into the generated index page.

For the demo, DataDownload documents are added in json.gz format to the studyforrest
phase 2 dataset. The workflow was run locally to update the dataset index page, and
that change is part of this commit.
2026-06-16 22:59:06 +02:00

100 lines
3.3 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 dists = (
__rec.characterized_by
| selectattr('predicate', 'equalto', 'dcat:distribution')
| list
) if __rec.characterized_by is defined and __rec.characterized_by is sequence else [] -%}
{%- set distributions = [] -%}
{%- for d in dists -%}
{%- set commit = d.object.pid | replace("dldi:","") | replace("/datalad/commit","") | default(none) -%}
{%- set _ = distributions.append({
"pid": d.object.pid | default(none),
"display_label": d.object.display_label | default(commit),
"commit": commit,
}) -%}
{%- endfor -%}
{%- set dataset = {
"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.title | 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)
} -%}
{%- if distributions -%}
{%- set _ = dataset.update({"distributions": distributions}) -%}
{%- endif -%}
{% block frontmatter -%}
title: {{ dataset.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 %}
{{ dataset | toyaml | indent(2) | trim }}
{% endblock -%}