From 5ccb313a6e461df4eda7fcf35123ca6e4e242567 Mon Sep 17 00:00:00 2001 From: David Lange Date: Fri, 30 Apr 2021 10:37:49 +0200 Subject: [PATCH 1/5] add team pictures to the focus area pages --- _layouts/focus-area.html | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/_layouts/focus-area.html b/_layouts/focus-area.html index 68c503827..60945da18 100644 --- a/_layouts/focus-area.html +++ b/_layouts/focus-area.html @@ -24,6 +24,45 @@ {% endif %} {% endfor %} +{% assign fa_team = "" | split: "," %} +{% for mypage in sorted %} +{% if mypage.pagetype == 'project' %} +{% if mypage.focus-area contains page.short_title %} +{% for person in mypage.team %} +{% if fa_team contains person %} +{% continue %} +{% endif %} +{% assign fa_team = fa_team | push: person %} +{% endfor %} +{% endif %} +{% endif %} +{% endfor %} +{% assign sorted_team = fa_team | sort %} +{% if fa_team.size > 0 %} +
+
+ {% for fa_person in fa_team %} + {% for person_hash in site.data.people %} + {% assign person = person_hash[1] %} + {% unless fa_person == person.shortname %} + {% continue %} + {% endunless %} +
+ Card image cap + {%- if person.website -%} + {{ person.name }} + {%- else -%} + {{ person.name }} + {%- endif -%} +
+ {% endfor %} + {% endfor %} +
+
+
+{% endif %} + + {% if doProjects ==1 %}

{{ page.short_title | upcase }} Projects


From 8d42f632900e757e01438e8faa66cb1ee65db8be Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 30 Apr 2021 08:39:07 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- _layouts/focus-area.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_layouts/focus-area.html b/_layouts/focus-area.html index 60945da18..f9af8c472 100644 --- a/_layouts/focus-area.html +++ b/_layouts/focus-area.html @@ -50,9 +50,9 @@
Card image cap {%- if person.website -%} - {{ person.name }} + {{ person.name }} {%- else -%} - {{ person.name }} + {{ person.name }} {%- endif -%}
{% endfor %} @@ -60,7 +60,7 @@

-{% endif %} +{% endif %} {% if doProjects ==1 %} From 49a0383a04cb8fc8135a266712f2584509563a90 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 May 2021 01:15:46 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- _layouts/focus-area.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_layouts/focus-area.html b/_layouts/focus-area.html index 8c0e8c2b5..453e43efb 100644 --- a/_layouts/focus-area.html +++ b/_layouts/focus-area.html @@ -15,7 +15,7 @@ {% assign page_focus_area = page.name | basename %} {% assign sorted = site.pages | smart_page_sort: "focus-area", page_focus_area %} - + {% assign fa_team = "" | split: "," %} {% for mypage in sorted %} {% for person in mypage.team %} From d446af8e4ed7cc7ade2af788132bc2d720e2416c Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 3 May 2021 21:46:22 -0400 Subject: [PATCH 4/5] refactor: move core logic to Ruby --- _layouts/focus-area.html | 28 +++++++--------------------- _plugins/smart_sort.rb | 8 ++++++++ 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/_layouts/focus-area.html b/_layouts/focus-area.html index 453e43efb..5ec91b69f 100644 --- a/_layouts/focus-area.html +++ b/_layouts/focus-area.html @@ -16,39 +16,25 @@ {% assign page_focus_area = page.name | basename %} {% assign sorted = site.pages | smart_page_sort: "focus-area", page_focus_area %} -{% assign fa_team = "" | split: "," %} -{% for mypage in sorted %} -{% for person in mypage.team %} -{% if fa_team contains person %} -{% continue %} -{% endif %} -{% assign fa_team = fa_team | push: person %} -{% endfor %} -{% endfor %} -{% assign sorted_team = fa_team | sort %} -{% if fa_team.size > 0 %} +{% assign fa_team = sorted | get_set: "team" | sort | key_to_value: site.data.people %} + +{% unless fa_team.empty %}
- {% for fa_person in fa_team %} - {% for person_hash in site.data.people %} - {% assign person = person_hash[1] %} - {% unless fa_person == person.shortname %} - {% continue %} - {% endunless %} + {% for person in fa_team %}
- Card image cap + Card image cap {%- if person.website -%} {{ person.name }} {%- else -%} {{ person.name }} {%- endif -%} -
- {% endfor %} +
{% endfor %}

-{% endif %} +{% endunless %} {% unless sorted.empty %}
diff --git a/_plugins/smart_sort.rb b/_plugins/smart_sort.rb index 2978479a9..0fe779c7b 100644 --- a/_plugins/smart_sort.rb +++ b/_plugins/smart_sort.rb @@ -7,6 +7,14 @@ def smart_page_sort(input, field, match) input.select { |p| p['pagetype'] == 'project' && p[field].include?(match) } .sort_by { |p| [p['position'] || 0, p['title'].downcase] } end + + def get_set(input, key) + input.flat_map { |p| p[key] || [] }.uniq + end + + def key_to_value(input, hash) + input.map { |k| hash.fetch(k, nil) }.compact + end end end From 9e020620092d7c7cad080167a3829161bf554473 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 3 May 2021 22:13:43 -0400 Subject: [PATCH 5/5] refactor: use find instead of manual loops --- _includes/list_project_team.html | 34 +++++++++++--------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/_includes/list_project_team.html b/_includes/list_project_team.html index 77a27093b..9c3088388 100644 --- a/_includes/list_project_team.html +++ b/_includes/list_project_team.html @@ -10,31 +10,21 @@

Team

{%- endif -%} {% for contact in include.team %} - {% assign written = false %} - {% if contact contains "](" %} + {% assign person = site.data.people | find: "shortname", contact %} + + {% if person %} + {%- if inline and person.e-mail -%} + {{ li }} {{person.name}} {{ eli }} + {%- elsif person.website -%} + {{ li }} {{ person.name }} {{ eli }} + {% else %} + {{ li }} {{person.name}} {{ eli }} + {% endif %} {% elsif contact contains "@" %} {{contact}} - {% assign written = true %} - {% else %} - {% for person_hash in site.data.people -%} - {% assign person = person_hash[1] -%} - {% if person.shortname == contact %} - {%- if inline and person.e-mail -%} - {{ li }} {{person.name}} {{ eli }} - {% assign written = true %} - {%- elsif person.website -%} - {{ li }} {{ person.name }} {{ eli }} - {% assign written = true %} - {% else %} - {{ li }} {{person.name}} {{ eli }} - {% assign written = true %} - {% endif %} - {% endif %} - {% endfor %} - {% endif %} - {% unless written %} + {{ else }} {{ li }} {{ contact | markdownify | remove: '

' | remove: '

' }} {{ eli }} - {% endunless %} + {% endif %} {% endfor %} {%- unless include.inline %}