From 0fb81f8914fae29a0676f3193ea255929bb99120 Mon Sep 17 00:00:00 2001 From: bedroesb Date: Fri, 2 Aug 2024 13:05:54 +0200 Subject: [PATCH 1/2] more robust handling of nat tools --- _includes/resource-table-all.html | 51 +++++++++++++++++++------------ 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/_includes/resource-table-all.html b/_includes/resource-table-all.html index 881c0929..6828f6e0 100644 --- a/_includes/resource-table-all.html +++ b/_includes/resource-table-all.html @@ -4,7 +4,21 @@ {%- assign tools = site.data.tool_and_resource_list | add_related_pages | sort_natural: "name" %} {%- endif %} {%- assign country_pages = site.pages | where_exp: "item", "item.search_exclude != true" | where_exp:"item","item.national_resources != nil" %} -{%- unless tools.size == 0 or tools == nil %} +{%- unless country_pages.size == 0 %} +{%- assign tool_matches_total = 0 %} +{%- assign query = "related_pages." | append: page.type %} +{%- for country_page in country_pages %} +{%- if include.tag %} +{%- assign tool_matches = country_page.national_resources | where_exp:"resource","resource.related_pages != nil" | where: query, include.tag %} +{%- unless tool_matches.size == 0 %} +{%- assign tool_matches_total = tool_matches_total | plus: tool_matches.size %} +{%- endunless %} +{%- else %} +{%- assign tool_matches_total = tool_matches_total | plus: country_page.national_resources.size %} +{%- endif %} +{%- endfor %} +{%- endunless %} +{%- unless tools.size == 0 and tool_matches_total.size == 0 %} {%- if include.tag %} Skip tool table {%- if site.theme_variables.headings.resource-table-all-collapse %} @@ -17,6 +31,7 @@
{%- endif %} {%- endif %} +{%- unless tools.size == 0 %}
@@ -36,14 +51,9 @@ {%- for tool in tools %} {%- assign instances_tool = 0 %} - {%- assign total_county_tools = 0 %} {%- assign query = "related_pages." | append: page.type %} {%- for country_page in country_pages %} {%- assign instance_matches = country_page.national_resources | where: "instance_of", tool.id | where_exp:"resource","resource.related_pages != nil" | where: query, include.tag %} - {%- assign tool_matches = country_page.national_resources | where_exp:"resource","resource.related_pages != nil" | where: query, include.tag %} - {%- unless tool_matches.size == 0 %} - {%- assign total_county_tools = total_county_tools | plus: tool_matches.size %} - {%- endunless %} {%- unless instance_matches.size == 0 %} {%- assign instances_tool = instances_tool | plus: instance_matches.size %} {%- endunless %} @@ -54,7 +64,7 @@ {%- endif %} {%- endfor %} +{%- if tool_matches_total == 0 or include.tag %}
{{tool.name}}{{tool.description}} - {%- if tool.instance_of or tool.how_to_access or instances_tool != 0 and total_county_tools != 0 and include.tag != nil %} + {%- if tool.instance_of or tool.how_to_access or instances_tool != 0 != 0 and include.tag != nil %} {%- assign linked_tool = site.data.tool_and_resource_list | where:"id", tool.instance_of | first %}
{%- if linked_tool %} @@ -63,7 +73,7 @@ {%- if tool.how_to_access %} {%- endif %} - {%- unless instances_tool == 0 or total_county_tools == 0 or include.tag == nil %} + {%- unless instances_tool == 0 or include.tag == nil %} @@ -99,16 +109,20 @@
+{%- endif %} {%- if include.tag %} {%- if site.theme_variables.headings.resource-table-all-collapse %}
{%- endif %}
{%- endif %} -{%- unless total_county_tools == 0 or include.tag == nil %} + +{%- endunless %} +{%- unless tool_matches_total == 0 %} {%- if include.tag %} Skip national tools table {%- if site.theme_variables.headings.resource-table-all-collapse %} @@ -120,37 +134,34 @@

{%- endif %} -{%- endif %}

Tools and resources tailored to users in different countries.

- +
- - - {%- assign hide_ids = "resource_title" %} +{%- endif %} {%- for country_page in country_pages %} {%- if include.tag %} - {%- assign tool_matches = country_page.national_resources | where_exp:"resource","resource.related_pages != nil" | where: query, include.tag | sort_natural: "name" %} + {%- assign tool_matches = country_page.national_resources | where_exp:"resource","resource.related_pages != nil" | where: query, include.tag %} {%- else %} - {%- assign tool_matches = country_page.national_resources | sort_natural: "name" %} + {%- assign tool_matches = country_page.national_resources %} {%- endif %} {%- for tool in tool_matches %} - {%- assign tool_id = tool.name | slugify %} - {%- assign hide_ids = hide_ids | append: " " | append: tool_id %} {% if tool.url %} From 23c441c1da478df19e2cfd03940dfe582d188413 Mon Sep 17 00:00:00 2001 From: bedroesb Date: Fri, 2 Aug 2024 13:14:26 +0200 Subject: [PATCH 2/2] add back sort natural --- _includes/resource-table-all.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/resource-table-all.html b/_includes/resource-table-all.html index 6828f6e0..7593c416 100644 --- a/_includes/resource-table-all.html +++ b/_includes/resource-table-all.html @@ -157,7 +157,7 @@
Tool or resource {%- if include.tag -%} + Tool or resource - {%- endif %} + Description Related pagesRegistry {%- if include.tag -%} + Registry - {%- endif %} +
{{tool.name}}