Skip to content

Commit

Permalink
data files
Browse files Browse the repository at this point in the history
  • Loading branch information
dcnb committed Oct 22, 2024
1 parent 824b5aa commit 567fb06
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
24 changes: 24 additions & 0 deletions assets/data/filter-facets.json
Original file line number Diff line number Diff line change
@@ -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 %}
]
}
15 changes: 15 additions & 0 deletions assets/data/filters.csv
Original file line number Diff line number Diff line change
@@ -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 %}

0 comments on commit 567fb06

Please sign in to comment.