From 991f219bdc634f5108ac8641b1e3b3626432572b Mon Sep 17 00:00:00 2001 From: Stephan Heunis Date: Mon, 2 Mar 2026 13:57:30 +0100 Subject: [PATCH] Add a workflow that registers depictions as portraits The workflow does the following: - Get all persons for which pages are generated (i.e. associated with the main project) - Get all depictions of type 'Portrait' - keep depictions that are 'about' any of the pids of the relevant persons - keep depictions that have distributions - keep distributions that have characterized_by with predicate==dcat:downloadUrl - extract the url (i.e. object) - register the file in the www-from-model dataset using git annex addurl The depiction is added as 'portrait.' alongside the '_index.md' page of the person page being generated. This is done so that 'qri render-record' and the associated jinja template can take care, separately, of rendering a portrait if a 'portrait.' image file is available. --- .../workflows/register_person_depictions.yaml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .forgejo/workflows/register_person_depictions.yaml diff --git a/.forgejo/workflows/register_person_depictions.yaml b/.forgejo/workflows/register_person_depictions.yaml new file mode 100644 index 0000000..8d4e115 --- /dev/null +++ b/.forgejo/workflows/register_person_depictions.yaml @@ -0,0 +1,65 @@ +name: Register person depictions + +on: + schedule: + - cron: '0 3 * * 1-5' + workflow_dispatch: + +env: + POOLAPI: https://pool.psychoinformatics.de/api + +jobs: + register_depictions: + runs-on: debian-latest + if: ${{ forgejo.repository == 'www/www-from-model' }} + outputs: + committed: ${{ steps.commit.outputs.committed }} + + steps: + - name: Checkout + uses: https://hub.datalad.org/forgejo/datalad-clone-action@v1 + with: + recursive: true + get_content: . + - name: Prepare environment + uses: ./.forgejo/actions/prep-metadata-query + - name: Process metadata + run: | + # Get all persons for which pages are generated: + # Get all depictions of type Portrait and inline distributions + # filter on whether the associated pid is of a person for which a page is generated + # operate on depictions that have distributions + # operate on distributions that have characterized_by, which in turn has: predicate == "dcat:downloadUrl" + # grab the associated object value; + # also grab extension and person pid reference + # feed [curie-ref, ext, url] into XARGS to call git annex addurl + dtc read-pages ${POOLAPI}/public/records/p/XYZDepiction \ + | qri filter-links-pid \ + --link kind xyzrins:depiction-types/e9a34f7d-d05e-4591-bb45-f8a0c499e07b \ + --api-url ${POOLAPI} --collection public \ + | qri inline-records --api-url ${POOLAPI} -c public -p distributions \ + | jq -r \ + --slurpfile pids <( + dtc read-pages ${POOLAPI}/public/records/p/XYZPerson \ + | qri filter-linked-pid --api-url ${POOLAPI} public xyzrins:. associated_with \ + | jq '.pid' + ) ' + ($pids | map({(.):1}) | add) as $pidmap + | select(any(.about[]?; $pidmap[.])) + | .about[] as $person + | select($pidmap[$person]) + | .distributions[]?.characterized_by[]? + | select(.predicate=="dcat:downloadUrl") + | .object as $url + | [ + ($person|sub("^xyzrins:";"")), + ($url|capture("\\.(?[^./?]+)$").e), + $url + ] + | @tsv + ' \ + | while IFS=$'\t' read -r curie ext url; do + git annex addurl --file="content/${curie}/portrait.${ext}" "$url" + done + - name: Deposit changes + uses: ./.forgejo/actions/deposit-changes \ No newline at end of file -- 2.52.0