From 387fce0b6a1ddfdbcb097faf92dd4b7de9558d7d Mon Sep 17 00:00:00 2001 From: mtwente <127845092+mtwente@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:52:17 +0200 Subject: [PATCH 1/2] feat: add list view --- _includes/js/list-js.html | 87 +++++++++++++++++++++++++++++++++++++++ _layouts/list.html | 33 +++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 _includes/js/list-js.html create mode 100644 _layouts/list.html diff --git a/_includes/js/list-js.html b/_includes/js/list-js.html new file mode 100644 index 0000000..84a80cb --- /dev/null +++ b/_includes/js/list-js.html @@ -0,0 +1,87 @@ +{%- comment -%} + + Generates a list-group using js to process the terms for display on "list" layout. + Requires CB's array_count_uniq.rb plugin! + +{%- endcomment -%} +{% if site.data.theme.browse-child-objects == true %} +{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid' -%} +{% else %} +{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid and item.parentid == nil' -%} +{% endif %} +{%- assign termsMin = include.min | plus: 0 | default: 1 -%} +{%- assign list_id = include.id | default: "list-group" -%} +{%- assign list-fields = include.fields | split: ";" -%} + +{%- comment -%} capture terms from all list fields {%- endcomment -%} +{%- assign terms = "" -%} +{%- for c in list-fields -%} +{% assign new = items | map: c | join: ";" %} +{% assign terms = terms | append: ";" | append: new %} +{%- endfor -%} +{%- comment -%} find unique terms and counts {%- endcomment -%} +{%- assign uniqTerms = terms | split: ";" | array_count_uniq | sort | where_exp: 't','t[1] >= termsMin' -%} + + \ No newline at end of file diff --git a/_layouts/list.html b/_layouts/list.html new file mode 100644 index 0000000..0e5b51b --- /dev/null +++ b/_layouts/list.html @@ -0,0 +1,33 @@ +--- +layout: page +--- + +{{ content }} + + +{%- if page.cloud-fields == "site.data.theme.subjects-fields" -%} + {% assign fields = site.data.theme.subjects-fields %} + {% assign min = site.data.theme.subjects-min | default: 1 %} + {% assign stopwords = site.data.theme.subjects-stopwords %} +{%- elsif page.cloud-fields == "site.data.theme.locations-fields" -%} + {% assign fields = site.data.theme.locations-fields %} + {% assign min = site.data.theme.locations-min | default: 1 %} + {% assign stopwords = site.data.theme.locations-stopwords %} +{%- else -%} + {% assign fields = page.cloud-fields | default: "subjects" %} + {% assign min = page.cloud-min | default: 1 %} + {% assign stopwords = page.cloud-stopwords %} +{%- endif -%} + +{% assign list_id = "list-div-" | append: fields | slugify %} + +
+{% include js/list-js.html id=list_id fields=fields min=min stopwords=stopwords %} \ No newline at end of file From 814341fb95cb1fffa87a67fe6c74d401ad3437c3 Mon Sep 17 00:00:00 2001 From: mtwente <127845092+mtwente@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:52:26 +0200 Subject: [PATCH 2/2] feat: change pages to list view --- pages/locations.md | 7 ++----- pages/subjects.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/pages/locations.md b/pages/locations.md index 056ef86..7c0b3dc 100644 --- a/pages/locations.md +++ b/pages/locations.md @@ -1,13 +1,10 @@ --- title: Locations -layout: cloud +layout: list permalink: /locations.html # Default locations page is configured in "_data/theme.yml" # leave cloud-fields as "site.data.theme.locations-fields" cloud-fields: site.data.theme.locations-fields --- -## Browse Locations - -Use this word cloud visualization to browse locations. -Word size is determined by frequency and all words link to a corresponding collection search. +## Browse Locations \ No newline at end of file diff --git a/pages/subjects.md b/pages/subjects.md index 2642ea3..07c8435 100644 --- a/pages/subjects.md +++ b/pages/subjects.md @@ -1,13 +1,10 @@ --- title: Subjects -layout: cloud +layout: list permalink: /subjects.html # Default subject page is configured in "_data/theme.yml" # leave cloud-fields as "site.data.theme.subjects-fields" cloud-fields: site.data.theme.subjects-fields --- -## Browse Subjects - -Use this word cloud visualization to browse terms and subjects. -Word size is determined by frequency and all words link to a corresponding collection search. +## Browse Tags \ No newline at end of file