From 08bcbf4f753fb578e4df4ef200c180d98322fa85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20M=C3=A4hr?= Date: Fri, 1 Mar 2024 12:48:26 +0100 Subject: [PATCH] feat: trigger warning added (#48) * feat: trigger warning added * fix: add trigger warnings for browse * fix: more consitent layout --- _data/theme.yml | 6 +++++ _includes/item/trigger-warning.html | 31 +++++++++++++++++++++++++ _layouts/browse.html | 7 +++++- _layouts/item/item-page-base.html | 3 ++- _layouts/item/item-page-full-width.html | 3 ++- 5 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 _includes/item/trigger-warning.html diff --git a/_data/theme.yml b/_data/theme.yml index 8943e93e..d5baf42d 100644 --- a/_data/theme.yml +++ b/_data/theme.yml @@ -19,6 +19,12 @@ home-banner-image-position: center # Default is top # # see _data/metadata-config.csv to define the metadata fields that will display. browse-buttons: true # true / false, adds previous/next arrows to items, but increases build time +trigger-warning: true # true / false, adds trigger warning to item pages +trigger-warning-text: "This collection may contain sensitive content." # optional, if you want to override the default trigger warning text +trigger-warning-text-item: "This item may contain sensitive content." # optional, if you want to override the default trigger warning text for individual items +trigger-field: "subject" # field to trigger warning, e.g. "subject" +trigger-terms: "Success,violence,sexuality,racism,discrimination" # set of subjects separated by , that will trigger warning, e.g. violence,sexuality,racism,discrimination + ########## # SUBJECTS PAGE diff --git a/_includes/item/trigger-warning.html b/_includes/item/trigger-warning.html new file mode 100644 index 00000000..995726ba --- /dev/null +++ b/_includes/item/trigger-warning.html @@ -0,0 +1,31 @@ +{% comment %} + Adds Bootstrap styled trigger warning to page. + By default the trigger warning is: "This item contains sensitive content." + The trigger warning can be customized in the site.data.theme file. +{% endcomment %} + +{% if site.data.theme.trigger-warning %} + {% assign trigger_field = site.data.theme.trigger-field | default: "subject" %} + {% assign trigger_terms = site.data.theme.trigger-terms | split: "," %} + {% assign terms = page[trigger_field] | split: ";" %} + + + + +{% endif %} diff --git a/_layouts/browse.html b/_layouts/browse.html index 9cdfb58e..96f8bbaf 100644 --- a/_layouts/browse.html +++ b/_layouts/browse.html @@ -6,6 +6,12 @@ {{ content }} +{% if site.data.theme.trigger-warning %} + +{% endif %} +
-
diff --git a/_layouts/item/item-page-base.html b/_layouts/item/item-page-base.html index d85df2d6..d1f975cc 100644 --- a/_layouts/item/item-page-base.html +++ b/_layouts/item/item-page-base.html @@ -1,6 +1,6 @@ --- # base layout for other item display_template layouts -# adds breadcrumbs and title at top; citation box, rights box, and browse buttons at bottom +# adds breadcrumbs, trigger-warning, and title at top; citation box, rights box, and browse buttons at bottom layout: default # item-meta adds rich meta markup to the page on production build item-meta: true @@ -8,6 +8,7 @@
{% include item/breadcrumbs.html %} + {% include item/trigger-warning.html %}
{{ page.display_template | replace: "_", " " | upcase }} {% if page.display_template == "compound_object" or page.display_template == "multiple" %}{% assign children = site.data[site.metadata] | where_exp: 'item','item.parentid == page.objectid' %} ({{ children | size }} {{ site.data.translations['_includes']['_layouts']['item']['item-page-base.html']['items'][site.lang] | default: 'Items'}}){% endif %}

{{ page.title }} {% unless page.display_template == 'record' %}{{ site.data.translations['_includes']['_layouts']['item']['item-page-base.html']['item-info'][site.lang] | default: 'Item Info'}} diff --git a/_layouts/item/item-page-full-width.html b/_layouts/item/item-page-full-width.html index 689d6cda..50221b79 100644 --- a/_layouts/item/item-page-full-width.html +++ b/_layouts/item/item-page-full-width.html @@ -1,6 +1,6 @@ --- # base layout for full page item display_template layouts -# adds breadcrumbs and title at top; citation box, rights box, and browse buttons at bottom +# adds breadcrumbs, trigger-warning, and title at top; citation box, rights box, and browse buttons at bottom layout: default # item-meta adds rich meta markup in HTML element to the page on production build for better SEO item-meta: true @@ -9,6 +9,7 @@