From 567fb06c44ba90d2ca298d1462cbdff73daa3004 Mon Sep 17 00:00:00 2001 From: Devin Becker Date: Tue, 22 Oct 2024 13:07:40 -0700 Subject: [PATCH] data files --- assets/data/filter-facets.json | 24 ++++++++++++++++++++++++ assets/data/filters.csv | 15 +++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 assets/data/filter-facets.json create mode 100644 assets/data/filters.csv diff --git a/assets/data/filter-facets.json b/assets/data/filter-facets.json new file mode 100644 index 0000000..caac71d --- /dev/null +++ b/assets/data/filter-facets.json @@ -0,0 +1,24 @@ +--- +# filter facets generator +# this creates a csv of unique values that are stored in your transcripts 'tags' column and their counts +# +# Requires CB's array_count_uniq.rb plugin! +--- +{% assign transcripts = site.data.transcripts %}{% for transcript in transcripts %} +{% assign items = transcript[1] %} +{%- assign min-count = 1 -%} +{%- assign raw-subjects = items | map: "tags" | compact | join: ";" | split: ";" -%} +{%- capture subjects -%}{% for s in raw-subjects %}{% if s != "" %}{{- s | strip | downcase -}};{% endif %}{%- endfor -%}{%-endcapture -%} +{%- assign subjects = subjects | split: ";" -%} +{%- assign allSubjects = allSubjects | concat: subjects -%}{% endfor %} +{ + "facets": [ + {%- assign uniqueArray = allSubjects | array_count_uniq -%} + { + "field": "tags", + "terms": { {% for unique in uniqueArray %} + {{ unique[0] | jsonify }}: {{ unique[1] | jsonify }}{% unless forloop.last %},{% endunless %}{% endfor %} + } + }{% unless forloop.last %},{% endunless %} + ] +} diff --git a/assets/data/filters.csv b/assets/data/filters.csv new file mode 100644 index 0000000..b963cf5 --- /dev/null +++ b/assets/data/filters.csv @@ -0,0 +1,15 @@ +--- +# create a filters.csv for the oral history visualization or check your filters against an autogenerated one +--- +{% assign transcripts = site.data.transcripts %}{% for transcript in transcripts %} +{% assign items = transcript[1] %} +{%- assign min-count = 1 -%} +{%- assign raw-subjects = items | map: "tags" | compact | join: ";" | split: ";" -%} +{%- capture subjects -%}{% for s in raw-subjects %}{% if s != "" %}{{- s | strip | downcase -}};{% endif %}{%- endfor -%}{%-endcapture -%} +{%- assign subjects = subjects | split: ";" -%} +{%- assign uniqueSubjects = subjects | uniq | sort -%} +{%- assign allUniqueSubjects = allUniqueSubjects | concat: uniqueSubjects -%}{% endfor %} +{%- assign tags = allUniqueSubjects | uniq | sort -%} +tag,description{% for tag in tags %} +{%- if tag != "" -%}{{ tag }},"On {{ tag}}"{% endif %} +{% endfor %} \ No newline at end of file