From 2b53fc93af16c30f23d516df10dcc7102d90f41d Mon Sep 17 00:00:00 2001 From: Jacob Korf Date: Wed, 13 Nov 2024 11:56:42 -0600 Subject: [PATCH 1/8] CSS fixes for taxonomy pages --- css/ucb-taxonomy-page.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/css/ucb-taxonomy-page.css b/css/ucb-taxonomy-page.css index 003f0a33..7d0b16f6 100644 --- a/css/ucb-taxonomy-page.css +++ b/css/ucb-taxonomy-page.css @@ -38,6 +38,7 @@ font-size: 85%; line-height: 85%; margin-bottom: 10px; + margin-top: 10px; } .ucb-taxonomy-title { @@ -45,7 +46,7 @@ font-weight: normal; margin-bottom: 10px; line-height: 1.3; - margin: 0 0 10px 0; + margin: 0; } .ucb-taxonomy-thumbnail { From e1dccd51719c69f58051f34a5da31965aa08a7f7 Mon Sep 17 00:00:00 2001 From: Jacob Korf Date: Mon, 18 Nov 2024 12:13:56 -0600 Subject: [PATCH 2/8] Padding fixes --- css/ucb-taxonomy-page.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/css/ucb-taxonomy-page.css b/css/ucb-taxonomy-page.css index 7d0b16f6..f24d51cd 100644 --- a/css/ucb-taxonomy-page.css +++ b/css/ucb-taxonomy-page.css @@ -38,12 +38,13 @@ font-size: 85%; line-height: 85%; margin-bottom: 10px; - margin-top: 10px; + margin-top: 5px; } .ucb-taxonomy-title { font-size: 120%; font-weight: normal; + padding-bottom: 10px; margin-bottom: 10px; line-height: 1.3; margin: 0; From bc8c5e33c282aeb692d77b8dcd73a5e18931bcbc Mon Sep 17 00:00:00 2001 From: Pat Date: Mon, 18 Nov 2024 11:54:43 -0700 Subject: [PATCH 3/8] Article List + Article List Block date hide --- css/block/ucb-article-list-block.css | 5 +++ js/ucb-article-list-block.js | 59 ++++++++++++++++++++-------- js/ucb-article-list.js | 4 +- 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/css/block/ucb-article-list-block.css b/css/block/ucb-article-list-block.css index 86c56daa..e5a68eb8 100644 --- a/css/block/ucb-article-list-block.css +++ b/css/block/ucb-article-list-block.css @@ -76,6 +76,11 @@ margin: 0; line-height: 1.3; } + +.ucb-article-card-title-no-date{ + margin-bottom: 12px; +} + .ucb-article-card-title-feature { font-size: 130%; font-weight: bolder; diff --git a/js/ucb-article-list-block.js b/js/ucb-article-list-block.js index d5388075..8d858dcf 100644 --- a/js/ucb-article-list-block.js +++ b/js/ucb-article-list-block.js @@ -114,15 +114,27 @@ class ArticleListBlockElement extends HTMLElement { // If no path alias set, use defaults const path = item.attributes.path.alias ? item.attributes.path.alias : `/node/${item.attributes.drupal_internal__nid}`; + + /** + * + * + * + * const date = item.attributes.field_ucb_article_date_override == "7" ? null : new Date(item.attributes.created).toLocaleDateString('en-us', { + year: 'numeric', + month: 'short', + day: 'numeric', + }); + */ return { title: item.attributes.title, link: this._baseURI + path, image: imageSrc, imageWide: imageSrcWide, - date: new Date(item.attributes.created).toLocaleDateString( - "en-us", - { year: "numeric", month: "short", day: "numeric" } - ), + date: item.attributes.field_ucb_article_date_override == "7" ? null : new Date(item.attributes.created).toLocaleDateString('en-us', { + year: 'numeric', + month: 'short', + day: 'numeric', + }), body: body.trim(), }; } @@ -288,13 +300,18 @@ class ArticleListBlockElement extends HTMLElement { var articleHeader = document.createElement("h3"); articleHeader.classList = "ucb-article-card-title-feature"; + if(!articleDate){ + articleHeader.classList.add("ucb-article-card-title-no-date"); + } articleHeader.innerText = articleTitle; headerLink.appendChild(articleHeader); - var date = document.createElement("span"); - date.classList = "ucb-article-card-date"; - date.innerText = articleDate; + if(articleDate){ + var date = document.createElement("span"); + date.classList = "ucb-article-card-date"; + date.innerText = articleDate; + } var articleSummary = document.createElement("p"); articleSummary.innerText = articleSumm; @@ -307,7 +324,7 @@ class ArticleListBlockElement extends HTMLElement { readMore.setAttribute("aria-hidden", "true"); articleBody.appendChild(headerLink); - articleBody.appendChild(date); + if (articleDate){articleBody.appendChild(date)}; articleBody.appendChild(articleSummary); articleBody.appendChild(readMore); @@ -359,13 +376,18 @@ class ArticleListBlockElement extends HTMLElement { var articleHeader = document.createElement("h3"); articleHeader.classList = "ucb-article-card-title-feature"; + if(!articleDate){ + articleHeader.classList.add("ucb-article-card-title-no-date"); + } articleHeader.innerText = articleTitle; headerLink.appendChild(articleHeader); - var date = document.createElement("span"); - date.classList = "ucb-article-card-date"; - date.innerText = articleDate; + if(articleDate){ + var date = document.createElement("span"); + date.classList = "ucb-article-card-date"; + date.innerText = articleDate; + } var articleSummary = document.createElement("p"); articleSummary.innerText = articleSumm; @@ -378,7 +400,7 @@ class ArticleListBlockElement extends HTMLElement { readMore.setAttribute("aria-hidden", "true"); articleBody.appendChild(headerLink); - articleBody.appendChild(date); + if(articleDate){articleBody.appendChild(date)}; articleBody.appendChild(articleSummary); articleBody.appendChild(readMore); @@ -514,14 +536,19 @@ class ArticleListBlockElement extends HTMLElement { var articleHeader = document.createElement("a"); articleHeader.classList = "ucb-article-card-title-teaser"; + if(!articleDate){ + articleHeader.classList.add("ucb-article-card-title-no-date"); + } articleHeader.href = articleLink; articleHeader.innerText = articleTitle; headerStrong.appendChild(articleHeader); - var date = document.createElement("span"); - date.classList = "ucb-article-card-date"; - date.innerText = articleDate; + if(articleDate){ + var date = document.createElement("span"); + date.classList = "ucb-article-card-date"; + date.innerText = articleDate; + } var articleSummary = document.createElement("p"); articleSummary.innerText = articleSumm; @@ -534,7 +561,7 @@ class ArticleListBlockElement extends HTMLElement { readMore.setAttribute("aria-hidden", "true"); articleBody.appendChild(headerStrong); - articleBody.appendChild(date); + if(articleDate){articleBody.appendChild(date)}; articleBody.appendChild(articleSummary); articleBody.appendChild(readMore); diff --git a/js/ucb-article-list.js b/js/ucb-article-list.js index e7d964d6..07c92d0d 100644 --- a/js/ucb-article-list.js +++ b/js/ucb-article-list.js @@ -530,8 +530,8 @@ imageSrc = altObj[idObj[thumbId]]; } - // Format date - const date = new Date(item.attributes.created).toLocaleDateString('en-us', { + // Format + const date = item.attributes.field_ucb_article_date_override == "7" ? null : new Date(item.attributes.created).toLocaleDateString('en-us', { year: 'numeric', month: 'short', day: 'numeric', From 6ae58921fa71709e2a8e604c9715fbd717f827a7 Mon Sep 17 00:00:00 2001 From: Pat Date: Mon, 18 Nov 2024 11:58:55 -0700 Subject: [PATCH 4/8] remove comment --- js/ucb-article-list-block.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/js/ucb-article-list-block.js b/js/ucb-article-list-block.js index 8d858dcf..8ef2329e 100644 --- a/js/ucb-article-list-block.js +++ b/js/ucb-article-list-block.js @@ -114,17 +114,6 @@ class ArticleListBlockElement extends HTMLElement { // If no path alias set, use defaults const path = item.attributes.path.alias ? item.attributes.path.alias : `/node/${item.attributes.drupal_internal__nid}`; - - /** - * - * - * - * const date = item.attributes.field_ucb_article_date_override == "7" ? null : new Date(item.attributes.created).toLocaleDateString('en-us', { - year: 'numeric', - month: 'short', - day: 'numeric', - }); - */ return { title: item.attributes.title, link: this._baseURI + path, From c6456259ae2d5ee450aaa63f8dace414ff815fdc Mon Sep 17 00:00:00 2001 From: Pat Date: Thu, 21 Nov 2024 09:06:28 -0700 Subject: [PATCH 5/8] Article List: global and per-node date functionality --- js/ucb-article-list.js | 16 ++++++++++------ .../content/node--ucb-article-list.html.twig | 4 ++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/js/ucb-article-list.js b/js/ucb-article-list.js index 07c92d0d..40221cc1 100644 --- a/js/ucb-article-list.js +++ b/js/ucb-article-list.js @@ -19,7 +19,6 @@ this.pageCount = pageCount; this._categoryTerms = null; this._tagTerms = null; - // Build the endpoint path, now in JS this.endpoint = this.buildEndpointPath(); } @@ -189,6 +188,8 @@ this._filterFormElement.style.alignItems = 'center'; this._contentElement.setAttribute('aria-live', 'polite'); } + // Date format + this.globalDateSetting = this.getAttribute('global-date-format'); this.appendChild(this._contentElement); // Loader this._loadingElement = document.createElement('div'); @@ -531,11 +532,14 @@ } // Format - const date = item.attributes.field_ucb_article_date_override == "7" ? null : new Date(item.attributes.created).toLocaleDateString('en-us', { - year: 'numeric', - month: 'short', - day: 'numeric', - }); + const date = (item.attributes.field_ucb_article_date_override != "7" && + (this.globalDateSetting != 6 || item.attributes.field_ucb_article_date_override != "0")) + ? new Date(item.attributes.created).toLocaleDateString('en-us', { + year: 'numeric', + month: 'short', + day: 'numeric', + }) + : null; const title = item.attributes.title; // If no path alias set, use defaults const path = item.attributes.path.alias ? item.attributes.path.alias : `/node/${item.attributes.drupal_internal__nid}`; diff --git a/templates/content/node--ucb-article-list.html.twig b/templates/content/node--ucb-article-list.html.twig index 908ee20f..69f38d9d 100644 --- a/templates/content/node--ucb-article-list.html.twig +++ b/templates/content/node--ucb-article-list.html.twig @@ -72,6 +72,9 @@ {# Base Url #} {% set baseurlJSON = url('')|render|trim('/') %} +{# Show/Hide Date #} +{% set global_date_format = drupal_config('ucb_site_configuration.settings', 'article_date_format') %} + {# include and exclude options set by the user #} {% set includeCategories = '' %} {% set myCategories = content.field_ucb_filter_by_category|render|striptags|trim|split(' ') %} @@ -149,6 +152,7 @@ 'exclude-tags': excludeTags, 'expose-categories' : exposeCategory, 'expose-tags': exposeTag, + 'global-date-format': global_date_format, }) }} > From 2d2dd7f7c41d3c965c108844ed84055b38e4f70b Mon Sep 17 00:00:00 2001 From: Pat Date: Thu, 21 Nov 2024 09:29:20 -0700 Subject: [PATCH 6/8] Article List Block: uses global and per-node date overrides --- js/ucb-article-list-block.js | 15 +++++++++------ .../block/block--article-list-block.html.twig | 7 ++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/js/ucb-article-list-block.js b/js/ucb-article-list-block.js index 8ef2329e..4618bed0 100644 --- a/js/ucb-article-list-block.js +++ b/js/ucb-article-list-block.js @@ -6,7 +6,7 @@ class ArticleListBlockElement extends HTMLElement { var display = this.getAttribute("display"); var API = this.getAttribute("jsonapi"); this._baseURI = this.getAttribute("base-uri"); - + this.globalDateSetting = this.getAttribute('global-date-format'); // Exclusions are done on the JS side, get into arrays. Blank if no exclusions var excludeCatArray = this.getAttribute("exCats").split(",").map(Number); var excludeTagArray = this.getAttribute("exTags").split(",").map(Number); @@ -119,11 +119,14 @@ class ArticleListBlockElement extends HTMLElement { link: this._baseURI + path, image: imageSrc, imageWide: imageSrcWide, - date: item.attributes.field_ucb_article_date_override == "7" ? null : new Date(item.attributes.created).toLocaleDateString('en-us', { - year: 'numeric', - month: 'short', - day: 'numeric', - }), + date: (item.attributes.field_ucb_article_date_override != "7" && + (this.globalDateSetting != 6 || item.attributes.field_ucb_article_date_override != "0")) + ? new Date(item.attributes.created).toLocaleDateString('en-us', { + year: 'numeric', + month: 'short', + day: 'numeric', + }) + : null, body: body.trim(), }; } diff --git a/templates/block/block--article-list-block.html.twig b/templates/block/block--article-list-block.html.twig index 9db1f9de..272c72f7 100644 --- a/templates/block/block--article-list-block.html.twig +++ b/templates/block/block--article-list-block.html.twig @@ -15,6 +15,9 @@ {# Base Url #} {% set baseurlJSON = url('')|render|trim('/') %} +{# Show/Hide Date #} +{% set global_date_format = drupal_config('ucb_site_configuration.settings', 'article_date_format') %} + {# This block mirrors the Article List Node - constructs a JSON endpoint in TWIG using include filters #} {# JSON API Endpoint information #} {% set articlesJSON = (url('')|render|trim('/')) @@ -179,7 +182,9 @@ exCats="{{ excludeCategories }}" exTags="{{ excludeTags }}" display="{{ content.field_art_list_block_display|render|striptags|trim }}" - count="{{ content.field_art_list_block_item_count|render|striptags|trim }}"> + count="{{ content.field_art_list_block_item_count|render|striptags|trim }}" + global-date-format="{{global_date_format}}" + >
From 9bf2bbf2e983dbf368374fa40c20ca9343fd2b9f Mon Sep 17 00:00:00 2001 From: Pat Date: Mon, 9 Dec 2024 12:11:27 -0700 Subject: [PATCH 7/8] Newsletter taxonomy: css fix --- css/ucb-taxonomy-page.css | 1 - 1 file changed, 1 deletion(-) diff --git a/css/ucb-taxonomy-page.css b/css/ucb-taxonomy-page.css index 27fdcdfd..550cb7e4 100644 --- a/css/ucb-taxonomy-page.css +++ b/css/ucb-taxonomy-page.css @@ -73,7 +73,6 @@ .ucb-newsletter-row{ margin-bottom: 20px; - border-bottom: 1px solid rgba(128, 128, 128, 0.333); padding-bottom: 20px; } From 9984d9ca853d69515de935d77fcc64f1d07cb7af Mon Sep 17 00:00:00 2001 From: Pat Date: Tue, 10 Dec 2024 11:12:26 -0700 Subject: [PATCH 8/8] Theme hook to escape special HTML entities --- boulder_base.theme | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/boulder_base.theme b/boulder_base.theme index 6c6a4830..c642e325 100755 --- a/boulder_base.theme +++ b/boulder_base.theme @@ -355,6 +355,26 @@ function boulder_base_form_system_theme_settings_alter(&$form, FormStateInterfac } } +/** + * Implements hook_preprocess_views_view(). + */ +function boulder_base_preprocess_views_view(&$variables) { + // Adjust header content for the taxonomy_term view. + // Needed because the Full HTML text filter doesn't escape special HTML entities like & + if ($variables['view']->id() === 'taxonomy_term') { + if (isset($variables['header']['area']['#text'])) { + // Decode HTML entities in the header text. + $variables['header']['area']['#text'] = html_entity_decode($variables['header']['area']['#text']); + } + } +} + + + + + + + /** * This is for list styles during migration. */