{% extends "base.html" %}
{% import "_macros.html" as m %}
{# `cv` is the three non-media jobs: a record, not portfolio tiles. #}
{% set shown = articles | rejectattr('category.name', 'equalto', 'cv') | list %}
{% set disciplines = shown | map(attribute='category.name') | unique | sort | list %}
{# Engagements, biggest first. A four-year relationship like ClipAward — nine
entries spanning design, projection, animation and organisation — is the
thing this portfolio has that a flat grid cannot show. Grouping is the
default view; the sort buttons fall back to a flat grid. #}
{% set names = [] %}
{% for a in shown if a.metadata.get('project') and a.metadata.get('project') not in names %}
{% if names.append(a.metadata.get('project')) %}{% endif %}
{% endfor %}
{% set groups = [] %}
{% for n in names %}
{% set members = shown | selectattr('metadata.project', 'equalto', n) | list %}
{% if groups.append({'name': n, 'members': members, 'n': members|length,
'first': members | map(attribute='date.year') | min}) %}{% endif %}
{% endfor %}
{# biggest engagement first, then earliest — Articles are not orderable, so
sort on the counts rather than on the member lists #}
{% set groups = groups | sort(attribute='first') | sort(attribute='n', reverse=true) %}
{% set loose = shown | rejectattr('metadata.project') | list %}
{% block content %}