From 71675439a5362ded48bf106decd8d018a3b5b549 Mon Sep 17 00:00:00 2001 From: christian medders Date: Tue, 29 Oct 2024 16:21:24 -0400 Subject: [PATCH 01/40] DIGITAL-38: Update to btn sc --- .../ec_shortcodes/templates/ec-shortcodes-button.html.twig | 2 -- 1 file changed, 2 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-button.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-button.html.twig index 073fb50..c3ee86e 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-button.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-button.html.twig @@ -1,5 +1,3 @@ -{# * update link and text to be drupal fields #} - {{ text }} From ead7b80c5108f8dbdf1aa433858eb5693463ba07 Mon Sep 17 00:00:00 2001 From: christian medders Date: Wed, 30 Oct 2024 09:48:51 -0400 Subject: [PATCH 02/40] DIGITAL-38: Saving work for note shortcode --- .../templates/ec-shortcodes-note.html.twig | 85 ++++++++----------- 1 file changed, 35 insertions(+), 50 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig index 0711dee..6678bb5 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig @@ -1,53 +1,38 @@ -{# {{ $variant := (.Get "variant") }} -{{ $icon := "notifications" }} +{% set noteType = form.type.value %} +{% set icons = { + 'activity': 'assessment', + 'action': 'campaign', + 'alert':'report', + 'comment': 'comment', + 'video': 'fast_forward', + 'join': 'groups', + 'note': 'notifications', + 'disclaimer': 'info', +} %} -{{ if eq $variant "activity" }} - {{ $icon = "assessment" }} -{{ else if eq $variant "action" }} - {{ $icon = "campaign" }} -{{ else if eq $variant "alert" }} - {{ $icon = "report" }} -{{ else if eq $variant "comment" }} - {{ $icon = "comment" }} -{{ else if eq $variant "video" }} - {{ $icon = "fast_forward" }} -{{ else if eq $variant "join" }} - {{ $icon = "groups" }} -{{ else if eq $variant "note" }} - {{ $icon = "notifications" }} -{{ else if eq $variant "disclaimer" }} - {{ $icon = "info" }} -{{ end }} +{% set icon = icons[noteType] %} +{% set iconPath = 'uswds/img/sprite.svg#' ~ icon %} -{{- $iconPath := (printf "uswds/img/sprite.svg#%s" $icon) -}} #} - - -
-

- - {{ if $variant }} - {# {{ if eq $variant "join" }} #} - Who can join? - {{ else }} - {# {{ $variant | title }} #} - {{ end }} - {{ else }} - Note - {{ end }} -

- {{ if eq $variant "disclaimer" }} - All references to specific brands, products, and/or companies are used only - for illustrative purposes and do not imply endorsement by the U.S. federal - government or any federal government agency. - {{ else }} - {# {{- .Inner | markdownify -}} #} - {{ end }} +
+

+ + {{ if $variant }} + {{ if eq noteType "join" }} + Who can join? + {{ else }} + {{ noteType | title }} + {{ end }} + {{ else }} + Note + {{ end }} +

+ {{ if eq noteType "disclaimer" }} + All references to specific brands, products, and/or companies are used only + for illustrative purposes and do not imply endorsement by the U.S. federal + government or any federal government agency. + {{ else }} + {{ text }} + {{ end }}
From 70eb0d6cd4505dfdc2cbc487957a83327ad4f86c Mon Sep 17 00:00:00 2001 From: christian medders Date: Wed, 30 Oct 2024 15:46:45 -0400 Subject: [PATCH 03/40] DIGITAL-38: Adding VSCODE file to gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e6857ff..01c12db 100644 --- a/.gitignore +++ b/.gitignore @@ -41,7 +41,7 @@ ehthumbs.db Thumbs.db # Visual Studio Code .vscode/* -!.vscode/ +.vscode/ !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json From 69fd2d5eb76b86d96494ad4372b7ba7a50629583 Mon Sep 17 00:00:00 2001 From: christian medders Date: Wed, 30 Oct 2024 21:30:42 -0400 Subject: [PATCH 04/40] DIGITAL-38: accordion work --- .../custom/ec_shortcodes/ec_shortcodes.module | 8 ++ .../EmbeddedContent/ECShortcodesAccordion.php | 8 ++ .../ec-shortcodes-accordion.html.twig | 105 +++++++++--------- 3 files changed, 67 insertions(+), 54 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/ec_shortcodes.module b/web/modules/custom/ec_shortcodes/ec_shortcodes.module index fa880c9..1962209 100644 --- a/web/modules/custom/ec_shortcodes/ec_shortcodes.module +++ b/web/modules/custom/ec_shortcodes/ec_shortcodes.module @@ -21,6 +21,7 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { 'kicker' => NULL, 'title' => NULL, 'icon' => NULL, + 'text' => NULL, ], ], 'ec_shortcodes_author_bio' => [ @@ -82,3 +83,10 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { ], ]; } + +/** + * Implements hook_preprocess_HOOK(). + */ +function ec_shortcodes_preprocess_ec_shortcodes_accordion(&$variables) { + $variables['theme_path'] = \Drupal::theme()->getActiveTheme()->getPath(); +} diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAccordion.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAccordion.php index 870cf5f..45497fe 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAccordion.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAccordion.php @@ -28,6 +28,7 @@ public function defaultConfiguration() { 'kicker' => NULL, 'title' => NULL, 'icon' => NULL, + 'body' => NULL, ]; } @@ -40,6 +41,7 @@ public function build(): array { '#kicker' => $this->configuration['kicker'], '#title' => $this->configuration['title'], '#icon' => $this->configuration['icon'], + '#text' => $this->configuration['text'], ]; } @@ -66,6 +68,12 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#required' => TRUE, '#media_types' => ['image'], ]; + $form['text'] = [ + '#title' => $this->t('Body'), + '#type' => 'text_format', + '#format'=> 'html', + '#allowed_formats' => ['html'], + ]; return $form; } diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig index 22c6fb2..247e436 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig @@ -1,58 +1,55 @@ -{# * commented out code is from hugo but need to update to durpal fields also review the php code for icon uploading #} + +{# +{{ kicker | json_encode(constant('JSON_PRETTY_PRINT')) }} +{{ title | json_encode(constant('JSON_PRETTY_PRINT')) }} + + +{% set heading_id = 'some text'|clean_id %} +{% set heading_id = 'some text'|clean_id %} +{% set heading_id = 'some text'|clean_id %} + +{{ heading_id }} + +{{ random(50, 100) }} +{{ random(50, 100) }} +{{ random(1, 9999) }} + #} +
- {# {{- .Page.Scratch.Add "count" 1 -}} #} - - -

- -

- - {# {{- if .Inner -}} #} -
- {# {{- .Inner | markdownify -}} #} -
- {{- end -}} +{% set count = random(1, 9999) %} + +

+ +

+ + {% if text %} +
+ {{ text }} +
+ {% endif %}
From b36b64877f4137e0aa65da0d9ea126c756ad4b4b Mon Sep 17 00:00:00 2001 From: christian medders Date: Thu, 31 Oct 2024 15:41:56 -0400 Subject: [PATCH 05/40] DIGITAL-38: Accordion shortcode --- .../EmbeddedContent/ECShortcodesAccordion.php | 17 +++++----- .../ec-shortcodes-accordion.html.twig | 31 ++++++------------- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAccordion.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAccordion.php index 45497fe..4378d04 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAccordion.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAccordion.php @@ -28,7 +28,7 @@ public function defaultConfiguration() { 'kicker' => NULL, 'title' => NULL, 'icon' => NULL, - 'body' => NULL, + 'text' => NULL, ]; } @@ -52,26 +52,27 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $form['kicker'] = [ '#type' => 'textfield', '#title' => $this->t('Kicker'), - '#default_value' => $this->configuration['text'], + '#default_value' => $this->configuration['kicker'], '#required' => TRUE, ]; $form['title'] = [ '#type' => 'textfield', '#title' => $this->t('Title'), - '#default_value' => $this->configuration['text'], + '#default_value' => $this->configuration['title'], '#required' => TRUE, ]; $form['icon'] = [ - '#type' => 'media_library', + '#type' => 'textfield', '#title' => $this->t('Icon'), - '#default_value' => $this->configuration['media_library'], + '#default_value' => $this->configuration['icon'], '#required' => TRUE, - '#media_types' => ['image'], ]; $form['text'] = [ - '#title' => $this->t('Body'), '#type' => 'text_format', - '#format'=> 'html', + '#title' => $this->t('Body'), + // '#description' => print_r($this->configuration['text'],true), + '#default_value' => $this->configuration['text']['value'] ?? '', + '#format' => 'html', '#allowed_formats' => ['html'], ]; diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig index 247e436..d997153 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig @@ -1,36 +1,18 @@ - -{# -{{ kicker | json_encode(constant('JSON_PRETTY_PRINT')) }} -{{ title | json_encode(constant('JSON_PRETTY_PRINT')) }} - - -{% set heading_id = 'some text'|clean_id %} -{% set heading_id = 'some text'|clean_id %} -{% set heading_id = 'some text'|clean_id %} - -{{ heading_id }} - -{{ random(50, 100) }} -{{ random(50, 100) }} -{{ random(1, 9999) }} - #} - -
-{% set count = random(1, 9999) %} + {% set count = random(1, 9999) %}

+

-

- -

- - {# {{- if .Inner -}} #} -
- {# {{- .Inner | markdownify -}} #} - - - - View the full legislation - - -
- {{- end -}} - + {% if text %} +
+ {% set text = { + '#type': 'processed_text', + '#text': text.value, + '#format': text.format, + } %} + {{ text }} + + View the full legislation + + +
+ {% endif %}
From 4e818fc4ebdc727e7fcc3cdb26dcba912e045133 Mon Sep 17 00:00:00 2001 From: christian medders Date: Sun, 3 Nov 2024 21:21:39 -0500 Subject: [PATCH 13/40] DIGITAL-38: removing high light shortcode --- .../custom/ec_shortcodes/ec_shortcodes.module | 5 -- .../EmbeddedContent/ECShortcodesHighlight.php | 62 ------------------- .../ec-shortcoes-highlight.html.twig | 2 - 3 files changed, 69 deletions(-) delete mode 100644 web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesHighlight.php delete mode 100644 web/modules/custom/ec_shortcodes/templates/ec-shortcoes-highlight.html.twig diff --git a/web/modules/custom/ec_shortcodes/ec_shortcodes.module b/web/modules/custom/ec_shortcodes/ec_shortcodes.module index 7c02248..f05b569 100644 --- a/web/modules/custom/ec_shortcodes/ec_shortcodes.module +++ b/web/modules/custom/ec_shortcodes/ec_shortcodes.module @@ -71,11 +71,6 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { 'summary' => NULL, ], ], - 'ec_shortcodes_highlight' => [ - 'variables' => [ - 'text' => NULL, - ], - ], 'ec_shortcodes_note' => [ 'variables' => [ 'heading' => NULL, diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesHighlight.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesHighlight.php deleted file mode 100644 index 86aef3e..0000000 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesHighlight.php +++ /dev/null @@ -1,62 +0,0 @@ - NULL, - ]; - } - - /** - * {@inheritdoc} - */ - public function build(): array { - return [ - '#theme' => 'ec_shortcodes_highlight', - '#text' => $this->configuration['text'], - ]; - } - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['text'] = [ - '#type' => 'textfield', - '#title' => $this->t('Text'), - '#default_value' => $this->configuration['text'], - '#required' => TRUE, - ]; - return $form; - } - - /** - * {@inheritDoc} - */ - public function isInline(): bool { - return TRUE; - } - -} diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcoes-highlight.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcoes-highlight.html.twig deleted file mode 100644 index c739b2e..0000000 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcoes-highlight.html.twig +++ /dev/null @@ -1,2 +0,0 @@ - - {{ text }} From 7fd4967b9e7f20e6e8660ca4e1dd20385d598844 Mon Sep 17 00:00:00 2001 From: christian medders Date: Sun, 3 Nov 2024 21:22:08 -0500 Subject: [PATCH 14/40] DIGITAL-38: saving work for author bio --- .../EmbeddedContent/ECShortcodesAuthorBio.php | 71 +++++++++++++++---- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAuthorBio.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAuthorBio.php index 104a7e4..9542bc9 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAuthorBio.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAuthorBio.php @@ -36,8 +36,8 @@ public function defaultConfiguration() { public function build(): array { return [ '#theme' => 'ec_shortcodes_author_bio', - '#name' => $this->configuration['name'], - '#bio' => $this->configuration['bio'], + // '#name' => $this->configuration['name'], + // '#bio' => $this->configuration['bio'], ]; } @@ -45,18 +45,61 @@ public function build(): array { * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['name'] = [ - '#type' => 'textfield', - '#title' => $this->t('Name'), - '#default_value' => $this->configuration['name'], - '#required' => TRUE, - ]; - $form['bio'] = [ - '#type' => 'textfield', - '#title' => $this->t('Bio'), - '#default_value' => $this->configuration['bio'], - '#required' => TRUE, - ]; + // $form['name'] = [ + // '#type' => 'textfield', + // '#title' => $this->t('Name'), + // '#default_value' => $this->configuration['name'], + // '#required' => TRUE, + // ]; + // $form['bio'] = [ + // '#type' => 'textfield', + // '#title' => $this->t('Bio'), + // '#default_value' => $this->configuration['bio'], + // '#required' => TRUE, + // ]; + + // $form['author'] = [ + // '#type' => 'entity_autocomplete', + // '#target_type' => 'node', + // '#tags' => TRUE, + // '#default_value' => $node, + // '#selection_handler' => 'default', + // '#selection_settings' => [ + // 'target_bundles' => ['authors'], + // ], + // '#autocreate' => [ + // 'bundle' => 'article', + // // 'uid' => , + // ], +// ]; + +$form['author'] = [ + '#type' => 'entity_autocomplete', + '#target_type' => 'node', + '#tags' => TRUE, + '#default_value' => $node, + '#selection_handler' => 'default', + '#selection_settings' => [ + 'target_bundles' => ['authors'], + ], + '#autocreate' => [ + 'bundle' => 'article', + // 'uid' => , + ], + '#process' => function ($element, &$form_state, $form) { + $node = \Drupal::entityTypeManager()->getStorage('node')->load($element['#value']); + if ($node) { + $element['#value'] = [ + 'nid' => $node->id(), + 'field_bio' => $node->field_bio->value, + 'field_first_name' => $node->field_first_name->value, + 'field_last_name' => $node->field_last_name->value, + ]; + } + return $element; + }, +]; + return $form; } From ac71aede7ad0edcdef9aab0d443ab770d0cb8fd1 Mon Sep 17 00:00:00 2001 From: christian medders Date: Sun, 3 Nov 2024 21:41:21 -0500 Subject: [PATCH 15/40] DIGITAL-38: adding fetured resource shortcode --- .../custom/ec_shortcodes/ec_shortcodes.module | 2 +- .../ECShortcodesFeaturedResource.php | 4 +- .../ec-shortcodes-card-policy.html.twig | 2 +- .../ec-shortcodes-featured-resource.html.twig | 101 ++++++++++++++++-- 4 files changed, 99 insertions(+), 10 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/ec_shortcodes.module b/web/modules/custom/ec_shortcodes/ec_shortcodes.module index f05b569..826df66 100644 --- a/web/modules/custom/ec_shortcodes/ec_shortcodes.module +++ b/web/modules/custom/ec_shortcodes/ec_shortcodes.module @@ -67,7 +67,7 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { 'variables' => [ 'kicker' => NULL, 'url' => NULL, - 'text' => NULL, + 'title' => NULL, 'summary' => NULL, ], ], diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php index 08266e6..8eaadb6 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php @@ -40,7 +40,7 @@ public function build(): array { '#theme' => 'ec_shortcodes_featured_resource', '#kicker' => $this->configuration['kicker'], '#url' => $this->configuration['url'], - '#text' => $this->configuration['text'], + '#title' => $this->configuration['text'], '#summary' => $this->configuration['summary'], ]; } @@ -61,7 +61,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#default_value' => $this->configuration['url'], '#required' => TRUE, ]; - $form['text'] = [ + $form['title'] = [ '#type' => 'textfield', '#title' => $this->t('Text'), '#default_value' => $this->configuration['text'], diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-policy.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-policy.html.twig index b3b770f..25d8a17 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-policy.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-policy.html.twig @@ -29,7 +29,7 @@ '#format': text.format, } %} {{ text }} - + View the full legislation -#} From eccedf51d6180aaf064108681e1f502fab9c5744 Mon Sep 17 00:00:00 2001 From: christian medders Date: Tue, 5 Nov 2024 14:33:28 -0500 Subject: [PATCH 16/40] DIGITAL-38: adding do dont table --- .../ec-shortcodes-do-dont-table.html.twig | 115 +++++++++++------- 1 file changed, 69 insertions(+), 46 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig index 8f60d9b..d78886d 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig @@ -1,47 +1,70 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +{# {{/* prettier-ignore-start */}} +{{/* + When setting up a **do-dont-table**, you need to make sure you have the correct formatting. + + 1. Start with a a **do-dont-table** + 2. Add a caption to **do-dont-table** that describes the table contents + 3. Create an opening and closing {{< row >}} + 4. Nest **do-row** and **dont-row** inside + 5. Place text, markdown and shortcodes between the {{ do-row }} & {{ dont-row }} +*/}} + +{{/* + Example: + + {{< do-dont-table caption="This is a table" >}} + {{< row >}} + {{< do-row >}} [Multilingual](https://digital.gov/communities/multilingual/) + {{< /do-row >}} + {{< dont-row >}} Don't follow these bad + practices{{< /dont-row >}} + {{< /row >}} + + {{< row >}} + {{< do-row >}} open "the door" for those who need a hand{{< /do-row >}} + {{< dont-row >}} Don't follow these bad practices{{< /dont-row >}} + {{< /row >}} + + {{< row >}} + {{< do-row >}} read `the directions` before using{{< /do-row >}} + {{< dont-row >}} + forget {{< highlight >}}to wash your hands{{< /highlight >}} for 20 seconds + {{< /dont-row >}} + {{< /row >}} + {{< /do-dont-table >}} +*/}} +{{/* prettier-ignore-end */}} #} + +
- Borderless table: A borderless table can be useful when you want the - information to feel more a part of the text it accompanies and extends. -
Document titleDescriptionYear
Declaration of Independence - Statement adopted by the Continental Congress declaring independence - from the British Empire. - 1776
Bill of Rights - The first ten amendments of the U.S. Constitution guaranteeing rights - and freedoms. - 1791
Declaration of Sentiments - A document written during the Seneca Falls Convention outlining the - rights that American women should be entitled to as citizens. - 1848
Emancipation Proclamation - An executive order granting freedom to slaves in designated southern - states. - 1863
+ + + + + + + + + {% for row in rows %} + + + + + {% endfor %} +
+ {{ caption }} +
+ + What you should do + + + What you shouldn't do +
+ {{ row.do }} + + {{ row.dont }} +
From fd8127b508488737b36f7471fa9a738d06d47ac7 Mon Sep 17 00:00:00 2001 From: christian medders Date: Tue, 5 Nov 2024 14:33:46 -0500 Subject: [PATCH 17/40] DIGITAL-38: file clean up --- .../custom/ec_shortcodes/ec_shortcodes.module | 29 ++++--------------- .../ec-shortcodes-card-prompt.html.twig | 15 ---------- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/ec_shortcodes.module b/web/modules/custom/ec_shortcodes/ec_shortcodes.module index 826df66..e3df634 100644 --- a/web/modules/custom/ec_shortcodes/ec_shortcodes.module +++ b/web/modules/custom/ec_shortcodes/ec_shortcodes.module @@ -84,27 +84,10 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { /** * Implements hook_preprocess_HOOK(). */ -function ec_shortcodes_preprocess_ec_shortcodes_accordion(&$variables) { - $variables['theme_path'] = \Drupal::theme()->getActiveTheme()->getPath(); -} - -/** - * Implements hook_preprocess_HOOK(). - */ -function ec_shortcodes_preprocess_ec_shortcodes_card_policy(&$variables) { - $variables['theme_path'] = \Drupal::theme()->getActiveTheme()->getPath(); -} - -/** - * Implements hook_preprocess_HOOK(). - */ -function ec_shortcodes_preprocess_ec_shortcodes_card_prompt(&$variables) { - $variables['theme_path'] = \Drupal::theme()->getActiveTheme()->getPath(); -} - -/** - * Implements hook_preprocess_HOOK(). - */ -function ec_shortcodes_preprocess_ec_shortcodes_note(&$variables) { - $variables['theme_path'] = \Drupal::theme()->getActiveTheme()->getPath(); +function ec_shortcodes_preprocess(&$variables, $hook) { + if (in_array($hook, ['ec_shortcodes_accordion', 'ec_shortcodes_card_policy', 'ec_shortcodes_card_prompt', + 'ec_shortcodes_note', 'ec_shortcodes_do_dont_table', + ])) { + $variables['theme_path'] = \Drupal::theme()->getActiveTheme()->getPath(); + } } diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-prompt.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-prompt.html.twig index 364bedc..86c8b78 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-prompt.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-prompt.html.twig @@ -1,18 +1,3 @@ -{# * update to take in intro, button text and url #} - -{#
-
-

Informative status

-

- Lorem ipsum dolor sit amet, - consectetur adipiscing - elit, sed do eiusmod. -

-
-
#} - - -
{% if intro %}
From 6d456d7e2a0ec4534e62b2d5cdf9ab7b90ddaef5 Mon Sep 17 00:00:00 2001 From: christian medders Date: Wed, 6 Nov 2024 08:32:50 -0500 Subject: [PATCH 18/40] DIGITAL-38: File clean up --- .../ec-shortcodes-card-prompt.html.twig | 9 --------- .../ec-shortcodes-card-quote.html.twig | 19 ------------------- 2 files changed, 28 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-prompt.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-prompt.html.twig index 86c8b78..68b4b9f 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-prompt.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-prompt.html.twig @@ -19,13 +19,4 @@ {{ text }} - -{# this does not seemed to be used at all #} -{# {{/* Fallback text (I forget what this was for) */}} -{{- if (.Get "fallback") -}} -

{{- .Get "fallback" | markdownify -}}

-{{- end -}} #} -
- - diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-quote.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-quote.html.twig index d0b1718..fce5566 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-quote.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-quote.html.twig @@ -1,20 +1,3 @@ -{# {{/* quote-block partial to display a block of quoted text with optional citation - - @param {string} bg - optional value of "dark" to display a dark background color otherwise will display as gold - @param {string} cite - optional string to display a citation - @param {string} text - required text for displaying a quote - - @example usage - {{< quote-block text="The big idea goes here" cite="Dr. Meredith Larson, Department of Education" ->}} - -*/}} -{{ $bg := .bg }} -{{ $cite := .cite }} -{{ $text := .text }} #} - -{# ! bg does not seemed to be used in this short code #} -{#
#}
@@ -25,5 +8,3 @@ {% endif %}
- - From 631bf72687d9bdc8bb4aa8af7e48cc8c9a5a607c Mon Sep 17 00:00:00 2001 From: christian medders Date: Wed, 6 Nov 2024 08:36:55 -0500 Subject: [PATCH 19/40] DIGITAL-38: updating note shortcode --- .../custom/ec_shortcodes/ec_shortcodes.module | 13 ++- .../EmbeddedContent/ECShortcodesNote.php | 2 - .../ECShortcodesNoteDisclaimer.php | 89 +++++++++++++++++++ .../EmbeddedContent/ECShortcodesNoteJoin.php | 89 +++++++++++++++++++ .../ec-shortcodes-note-disclaimer.html.twig | 11 +++ .../ec-shortcodes-note-join.html.twig | 15 ++++ 6 files changed, 216 insertions(+), 3 deletions(-) create mode 100644 web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteDisclaimer.php create mode 100644 web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteJoin.php create mode 100644 web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-disclaimer.html.twig create mode 100644 web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-join.html.twig diff --git a/web/modules/custom/ec_shortcodes/ec_shortcodes.module b/web/modules/custom/ec_shortcodes/ec_shortcodes.module index e3df634..a56e494 100644 --- a/web/modules/custom/ec_shortcodes/ec_shortcodes.module +++ b/web/modules/custom/ec_shortcodes/ec_shortcodes.module @@ -78,6 +78,17 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { 'text' => NULL, ], ], + + 'ec_shortcodes_note_join' => [ + 'variables' => [ + 'text' => NULL, + ], + ], + 'ec_shortcodes_note_disclaimer' => [ + 'variables' => [ + 'heading' => NULL, + ], + ], ]; } @@ -86,7 +97,7 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { */ function ec_shortcodes_preprocess(&$variables, $hook) { if (in_array($hook, ['ec_shortcodes_accordion', 'ec_shortcodes_card_policy', 'ec_shortcodes_card_prompt', - 'ec_shortcodes_note', 'ec_shortcodes_do_dont_table', + 'ec_shortcodes_note', 'ec_shortcodes_do_dont_table', 'ec_shortcodes_note_join', 'ec_shortcodes_note_disclaimer', ])) { $variables['theme_path'] = \Drupal::theme()->getActiveTheme()->getPath(); } diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNote.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNote.php index faa29ef..274d77c 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNote.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNote.php @@ -61,9 +61,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta 'alert' => $this->t('Alert'), 'comment' => $this->t('Comment'), 'video' => $this->t('Video'), - 'join' => $this->t('Join'), 'note' => $this->t('Note'), - 'disclaimer' => $this->t('Disclaimer'), ], '#default_value' => $this->configuration['type'], '#required' => TRUE, diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteDisclaimer.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteDisclaimer.php new file mode 100644 index 0000000..d786512 --- /dev/null +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteDisclaimer.php @@ -0,0 +1,89 @@ + NULL, + // 'type' => NULL, + // 'text' => NULL, + ]; + } + + /** + * {@inheritdoc} + */ + public function build(): array { + return [ + '#theme' => 'ec_shortcodes_note_disclaimer', + '#heading' => $this->configuration['heading'], + // '#type' => $this->configuration['type'], + // '#text' => $this->configuration['text'], + ]; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $form['heading'] = [ + '#type' => 'textfield', + '#title' => $this->t('Note Heading'), + '#default_value' => $this->configuration['heading'], + ]; + // $form['type'] = [ + // '#type' => 'select', + // '#title' => $this->t('Note Type'), + // '#options' => [ + // 'activity' => $this->t('Activity'), + // 'action' => $this->t('Action'), + // 'alert' => $this->t('Alert'), + // 'comment' => $this->t('Comment'), + // 'video' => $this->t('Video'), + // 'join' => $this->t('Join'), + // 'note' => $this->t('Note'), + // 'disclaimer' => $this->t('Disclaimer'), + // ], + // '#default_value' => $this->configuration['type'], + // '#required' => TRUE, + // ]; + // $form['text'] = [ + // '#type' => 'text_format', + // '#title' => $this->t('Note Text'), + // '#format' => $this->configuration['text']['format'] ?? 'html', + // '#allowed_formats' => ['html'], + // '#default_value' => $this->configuration['text']['value'] ?? '', + // '#required' => TRUE, + // ]; + return $form; + } + + /** + * {@inheritDoc} + */ + public function isInline(): bool { + return FALSE; + } + +} diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteJoin.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteJoin.php new file mode 100644 index 0000000..49056ec --- /dev/null +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteJoin.php @@ -0,0 +1,89 @@ + NULL, + // 'type' => NULL, + 'text' => NULL, + ]; + } + + /** + * {@inheritdoc} + */ + public function build(): array { + return [ + '#theme' => 'ec_shortcodes_note_join', + // '#heading' => $this->configuration['heading'], + // '#type' => $this->configuration['type'], + '#text' => $this->configuration['text'], + ]; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + // $form['heading'] = [ + // '#type' => 'textfield', + // '#title' => $this->t('Note Heading'), + // '#default_value' => $this->configuration['heading'], + // ]; + // $form['type'] = [ + // '#type' => 'select', + // '#title' => $this->t('Note Type'), + // '#options' => [ + // 'activity' => $this->t('Activity'), + // 'action' => $this->t('Action'), + // 'alert' => $this->t('Alert'), + // 'comment' => $this->t('Comment'), + // 'video' => $this->t('Video'), + // 'join' => $this->t('Join'), + // 'note' => $this->t('Note'), + // 'disclaimer' => $this->t('Disclaimer'), + // ], + // '#default_value' => $this->configuration['type'], + // '#required' => TRUE, + // ]; + $form['text'] = [ + '#type' => 'text_format', + '#title' => $this->t('Note Text'), + '#format' => $this->configuration['text']['format'] ?? 'html', + '#allowed_formats' => ['html'], + '#default_value' => $this->configuration['text']['value'] ?? '', + '#required' => TRUE, + ]; + return $form; + } + + /** + * {@inheritDoc} + */ + public function isInline(): bool { + return FALSE; + } + +} diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-disclaimer.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-disclaimer.html.twig new file mode 100644 index 0000000..2eaa5b8 --- /dev/null +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-disclaimer.html.twig @@ -0,0 +1,11 @@ +
+

+ + {{ heading }} +

+ All references to specific brands, products, and/or companies are used only + for illustrative purposes and do not imply endorsement by the U.S. federal + government or any federal government agency. +
diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-join.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-join.html.twig new file mode 100644 index 0000000..24e2099 --- /dev/null +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-join.html.twig @@ -0,0 +1,15 @@ +
+

+ + Who can join? +

+ {% set text = { + '#type': 'processed_text', + '#text': text.value, + '#format': text.format, + } %} + {{ text }} +
+ From 55ae535ba5ac99a1578b41251d29e63de91a8908 Mon Sep 17 00:00:00 2001 From: christian medders Date: Wed, 6 Nov 2024 09:51:24 -0500 Subject: [PATCH 20/40] DIGITAL-38: removed author bio shortcode --- .../custom/ec_shortcodes/ec_shortcodes.module | 11 +- .../EmbeddedContent/ECShortcodesAuthorBio.php | 113 ------------------ .../ec-shortcodes-author-bio.html.twig | 5 - 3 files changed, 5 insertions(+), 124 deletions(-) delete mode 100644 web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAuthorBio.php delete mode 100644 web/modules/custom/ec_shortcodes/templates/ec-shortcodes-author-bio.html.twig diff --git a/web/modules/custom/ec_shortcodes/ec_shortcodes.module b/web/modules/custom/ec_shortcodes/ec_shortcodes.module index a56e494..1562d96 100644 --- a/web/modules/custom/ec_shortcodes/ec_shortcodes.module +++ b/web/modules/custom/ec_shortcodes/ec_shortcodes.module @@ -24,12 +24,6 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { 'text' => NULL, ], ], - 'ec_shortcodes_author_bio' => [ - 'variables' => [ - 'name' => NULL, - 'bio' => NULL, - ], - ], 'ec_shortcodes_card_policy' => [ 'variables' => [ 'kicker' => NULL, @@ -71,6 +65,11 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { 'summary' => NULL, ], ], + 'ec_shortcodes_featured_resource_ext' => [ + 'variables' => [ + 'node' => NULL, + ], + ], 'ec_shortcodes_note' => [ 'variables' => [ 'heading' => NULL, diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAuthorBio.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAuthorBio.php deleted file mode 100644 index 9542bc9..0000000 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAuthorBio.php +++ /dev/null @@ -1,113 +0,0 @@ - NULL, - 'bio' => NULL, - ]; - } - - /** - * {@inheritdoc} - */ - public function build(): array { - return [ - '#theme' => 'ec_shortcodes_author_bio', - // '#name' => $this->configuration['name'], - // '#bio' => $this->configuration['bio'], - ]; - } - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - // $form['name'] = [ - // '#type' => 'textfield', - // '#title' => $this->t('Name'), - // '#default_value' => $this->configuration['name'], - // '#required' => TRUE, - // ]; - // $form['bio'] = [ - // '#type' => 'textfield', - // '#title' => $this->t('Bio'), - // '#default_value' => $this->configuration['bio'], - // '#required' => TRUE, - // ]; - - // $form['author'] = [ - // '#type' => 'entity_autocomplete', - // '#target_type' => 'node', - // '#tags' => TRUE, - // '#default_value' => $node, - // '#selection_handler' => 'default', - // '#selection_settings' => [ - // 'target_bundles' => ['authors'], - // ], - // '#autocreate' => [ - // 'bundle' => 'article', - // // 'uid' => , - // ], -// ]; - -$form['author'] = [ - '#type' => 'entity_autocomplete', - '#target_type' => 'node', - '#tags' => TRUE, - '#default_value' => $node, - '#selection_handler' => 'default', - '#selection_settings' => [ - 'target_bundles' => ['authors'], - ], - '#autocreate' => [ - 'bundle' => 'article', - // 'uid' => , - ], - '#process' => function ($element, &$form_state, $form) { - $node = \Drupal::entityTypeManager()->getStorage('node')->load($element['#value']); - if ($node) { - $element['#value'] = [ - 'nid' => $node->id(), - 'field_bio' => $node->field_bio->value, - 'field_first_name' => $node->field_first_name->value, - 'field_last_name' => $node->field_last_name->value, - ]; - } - return $element; - }, -]; - - return $form; - } - - /** - * {@inheritDoc} - */ - public function isInline(): bool { - return FALSE; - } - -} diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-author-bio.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-author-bio.html.twig deleted file mode 100644 index 277369d..0000000 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-author-bio.html.twig +++ /dev/null @@ -1,5 +0,0 @@ -{# * need to review this shortcode to see how to pull in the bio info from the author content time and then this template needs to style that #} - -

{{ name }}

- -

{{ bio }}

From 5c858c1dfdb1474cbafb414a234673994ed44f0f Mon Sep 17 00:00:00 2001 From: christian medders Date: Wed, 6 Nov 2024 13:35:40 -0500 Subject: [PATCH 21/40] DIGITAL-38: saving work --- .../custom/ec_shortcodes/ec_shortcodes.module | 6 +- .../ECShortCodesFeaturedResourceExt.php | 102 ++++++++++++++++++ .../ECShortcodesFeaturedResource.php | 76 +++++++------ .../ec-shortcodes-do-dont-table.html.twig | 39 +------ ...shortcodes-featured-resource-ext.html.twig | 24 +++++ .../ec-shortcodes-featured-resource.html.twig | 85 ++------------- 6 files changed, 183 insertions(+), 149 deletions(-) create mode 100644 web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php create mode 100644 web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource-ext.html.twig diff --git a/web/modules/custom/ec_shortcodes/ec_shortcodes.module b/web/modules/custom/ec_shortcodes/ec_shortcodes.module index 1562d96..7e1c248 100644 --- a/web/modules/custom/ec_shortcodes/ec_shortcodes.module +++ b/web/modules/custom/ec_shortcodes/ec_shortcodes.module @@ -57,7 +57,7 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { 'rows' => NULL, ], ], - 'ec_shortcodes_featured_resource' => [ + 'ec_shortcodes_featured_resource_ext' => [ 'variables' => [ 'kicker' => NULL, 'url' => NULL, @@ -65,9 +65,9 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { 'summary' => NULL, ], ], - 'ec_shortcodes_featured_resource_ext' => [ + 'ec_shortcodes_featured_resource' => [ 'variables' => [ - 'node' => NULL, + 'content_reference' => NULL, ], ], 'ec_shortcodes_note' => [ diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php new file mode 100644 index 0000000..b893fdc --- /dev/null +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php @@ -0,0 +1,102 @@ + NULL, + 'url' => NULL, + 'text' => NULL, + 'summary' => NULL, + 'node' => NULL, + ]; + } + + /** + * {@inheritdoc} + */ + public function build(): array { + return [ + '#theme' => 'ec_shortcodes_featured_resource_ext', + '#kicker' => $this->configuration['kicker'], + '#url' => $this->configuration['url'], + '#title' => $this->configuration['text'], + '#summary' => $this->configuration['summary'], + ]; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $form['kicker'] = [ + '#type' => 'textfield', + '#title' => $this->t('Kicker'), + '#default_value' => $this->configuration['text'], + '#required' => TRUE, + ]; + $form['url'] = [ + '#type' => 'url', + '#title' => $this->t('Url'), + '#default_value' => $this->configuration['url'], + '#required' => TRUE, + ]; + $form['title'] = [ + '#type' => 'textfield', + '#title' => $this->t('Text'), + '#default_value' => $this->configuration['text'], + '#required' => TRUE, + ]; + $form['summary'] = [ + '#type' => 'textfield', + '#title' => $this->t('Summary'), + '#default_value' => $this->configuration['text'], + '#required' => TRUE, + ]; +// $form['node'] = [ +// '#type' => 'entity_autocomplete', +// '#title' => $this->t('Content Reference'), +// '#target_type' => 'node', +// '#tags' => TRUE, +// '#default_value' => $node, +// '#selection_handler' => 'default', +// '#selection_settings' => [ +// 'target_bundles' => ['authors', 'basic_page', 'community', 'event', 'gide', 'news', 'resources', 'services', 'topics'], +// ], +// '#autocreate' => [ +// 'bundle' => 'article', +// // 'uid' =>
, +// ], +// ]; + return $form; + } + + /** + * {@inheritDoc} + */ + public function isInline(): bool { + return FALSE; + } + +} diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php index 8eaadb6..a5c6e1e 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php @@ -25,10 +25,11 @@ class ECShortcodesFeaturedResource extends EmbeddedContentPluginBase implements */ public function defaultConfiguration() { return [ - 'kicker' => NULL, - 'url' => NULL, - 'text' => NULL, - 'summary' => NULL, + // 'kicker' => NULL, + // 'url' => NULL, + // 'text' => NULL, + // 'summary' => NULL, + 'content_reference' => NULL, ]; } @@ -38,10 +39,12 @@ public function defaultConfiguration() { public function build(): array { return [ '#theme' => 'ec_shortcodes_featured_resource', - '#kicker' => $this->configuration['kicker'], - '#url' => $this->configuration['url'], - '#title' => $this->configuration['text'], - '#summary' => $this->configuration['summary'], + // '#kicker' => $this->configuration['kicker'], + // '#url' => $this->configuration['url'], + // '#title' => $this->configuration['text'], + // '#summary' => $this->configuration['summary'], + '#content_reference' => $this->configuration['content_reference'], + ]; } @@ -49,29 +52,42 @@ public function build(): array { * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['kicker'] = [ - '#type' => 'textfield', - '#title' => $this->t('Kicker'), - '#default_value' => $this->configuration['text'], - '#required' => TRUE, - ]; - $form['url'] = [ - '#type' => 'url', - '#title' => $this->t('Url'), - '#default_value' => $this->configuration['url'], - '#required' => TRUE, - ]; - $form['title'] = [ - '#type' => 'textfield', - '#title' => $this->t('Text'), - '#default_value' => $this->configuration['text'], - '#required' => TRUE, - ]; - $form['summary'] = [ - '#type' => 'textfield', - '#title' => $this->t('Summary'), - '#default_value' => $this->configuration['text'], + // $form['kicker'] = [ + // '#type' => 'textfield', + // '#title' => $this->t('Kicker'), + // '#default_value' => $this->configuration['text'], + // '#required' => TRUE, + // ]; + // $form['url'] = [ + // '#type' => 'url', + // '#title' => $this->t('Url'), + // '#default_value' => $this->configuration['url'], + // '#required' => TRUE, + // ]; + // $form['title'] = [ + // '#type' => 'textfield', + // '#title' => $this->t('Text'), + // '#default_value' => $this->configuration['text'], + // '#required' => TRUE, + // ]; + // $form['summary'] = [ + // '#type' => 'textfield', + // '#title' => $this->t('Summary'), + // '#default_value' => $this->configuration['text'], + // '#required' => TRUE, + // ]; +$form['content_reference'] = [ + '#type' => 'entity_autocomplete', + '#title' => $this->t('Content Reference'), + '#target_type' => 'node', + '#process_default_value' => FALSE, + '#value_callback' => 'entity_autocomplete_value_callback', + '#default_value' => $this->configuration['content_reference'], + '#selection_handler' => 'default', '#required' => TRUE, + '#selection_settings' => [ + 'target_bundles' => ['authors', 'basic_page', 'community', 'event', 'gide', 'news','resources','services', 'topics'], + ], ]; return $form; } diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig index d78886d..2780055 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig @@ -1,40 +1,3 @@ -{# {{/* prettier-ignore-start */}} -{{/* - When setting up a **do-dont-table**, you need to make sure you have the correct formatting. - - 1. Start with a a **do-dont-table** - 2. Add a caption to **do-dont-table** that describes the table contents - 3. Create an opening and closing {{< row >}} - 4. Nest **do-row** and **dont-row** inside - 5. Place text, markdown and shortcodes between the {{ do-row }} & {{ dont-row }} -*/}} - -{{/* - Example: - - {{< do-dont-table caption="This is a table" >}} - {{< row >}} - {{< do-row >}} [Multilingual](https://digital.gov/communities/multilingual/) - {{< /do-row >}} - {{< dont-row >}} Don't follow these bad - practices{{< /dont-row >}} - {{< /row >}} - - {{< row >}} - {{< do-row >}} open "the door" for those who need a hand{{< /do-row >}} - {{< dont-row >}} Don't follow these bad practices{{< /dont-row >}} - {{< /row >}} - - {{< row >}} - {{< do-row >}} read `the directions` before using{{< /do-row >}} - {{< dont-row >}} - forget {{< highlight >}}to wash your hands{{< /highlight >}} for 20 seconds - {{< /dont-row >}} - {{< /row >}} - {{< /do-dont-table >}} -*/}} -{{/* prettier-ignore-end */}} #} - +{% if rows is not empty %} {% for row in rows %} {% endfor %} + {% endif %}
{{ caption }} @@ -56,6 +19,7 @@
@@ -66,5 +30,6 @@
diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource-ext.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource-ext.html.twig new file mode 100644 index 0000000..ed5d779 --- /dev/null +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource-ext.html.twig @@ -0,0 +1,24 @@ +
+ diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource.html.twig index dea3295..98c527a 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource.html.twig @@ -1,100 +1,27 @@ -{# -{{/* +{% set nodeType = content_reference | title %} - Featured Resource Component displays an internal or external resource wrapped in a gray rounded box. - If the link is internal the hugo page lookup will return the fields to display. - If the link is external then yaml data or shortcode fields will be used to populate the display fields. - The source data can be from a hugo page, yaml data from a topics page frontmatter, or a shortcode used in markdown. - - @params {object} resource_data - a dictionary object of strings to display a resource composed of the following properties: - - link (required) - can be internal hugo path or external http(s) link - - title (required) - the title of the resource - - summary (required) - the short description for the resource - - kicker (optional) - a short label or message at the top of the resource box - - @example link paths allowed: - - 18f-accessibility-guide - - /18f-accessibility-guide - - /resources/18f-accessibility-guide - - https://wwww.ai.gov - - http://www.usps.com/ - - @example shortcode with internal link: - {{< featured-resource link="/guides/hcd/discovery-concepts" ->}} -@example shortcode with external link: -{{< featured-resource link="https://wwww.ai.gov" >}} - -@example display a community in a shortcode: -{{< featured-resource link="/communities/communicators" kicker="Join the Community" >}} - -@example allowed community resource paths: - communicators - multilingual - -plain-language - social-media - user-experience - web-analytics-and-optimization -- web-managers-forum */}} - - -{{ $resource := .resource_data }} -{{ $title := "" }} -{{ $summary := "" }} -{{ $image := "" }} -{{ $kicker := "" }} -{{ $internalLink := "" }} -{{ $externalLink := "" }} -{{ $href := "" }} -{{ $isExternal := false }} - -{{/* Check if page is an external link, otherwise return a hugo page object */}} -{{ if or (strings.HasPrefix $resource.link "https://") (strings.HasPrefix $resource.link "http://") }} - {{ $isExternal = true }} - {{ $title = $resource.title }} - {{ $summary = $resource.summary }} - {{ $kicker = $resource.kicker }} - {{ $externalLink = $resource.link }} -{{ else }} - {{ $page := .Site.GetPage $resource.link }} - {{ $title = $page.Title }} - {{ $summary = $page.Params.summary }} - {{ $image = $page.Params.image }} - {{ $internalLink = $page.Permalink }} - - {{/* Check if kicker is present as a custom key, otherwise use page parameter to set */}} - {{ if $resource.kicker }} - {{ $kicker = $resource.kicker }} - {{ else }} - {{ if $page.Params.kicker }} - {{ $kicker = $page.Params.kicker }} - {{ end }} - {{ end }} -{{ end }} - -{{ if $isExternal }} - {{ $href = $externalLink }} -{{ else }} - {{ $href = ($internalLink | relURL) }} -{{ end }} #} + +{{ content_reference | json_encode(constant('JSON_PRETTY_PRINT')) }} + + + From 9f7ef8ea0920aefad180903052043dbf9d3943dc Mon Sep 17 00:00:00 2001 From: christian medders Date: Wed, 6 Nov 2024 21:36:24 -0500 Subject: [PATCH 22/40] DIGITAL-38: update to do dont table --- .../ec-shortcodes-do-dont-table.html.twig | 76 ++++++++++--------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig index 2780055..cae5e1e 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig @@ -1,35 +1,41 @@ - - - - - - - - - -{% if rows is not empty %} - {% for row in rows %} - - - - - {% endfor %} - {% endif %} - -
- {{ caption }} -
- - What you should do - - - What you shouldn't do -
- {{ row.do }} - - {{ row.dont }} -
+{% if rows %} + {% set table_rows %}{% apply spaceless %} + {% for row in rows %} + {% if row.do is not empty and row.dont is not empty %} + + + {{ row.do }} + + + {{ row.dont }} + + + {% endif %} + {% endfor %} + {% endapply %}{% endset %} +{% endif %} + +{% if table_rows %} + + + + + + + + + + {{ table_rows }} + +
{{ caption }}
+ + {{ 'What you should do'|t }} + + + {{ "What you shouldn't do"|t }} +
+{% endif %} From 60501c6d8f69fe2494298abd5c6308034e561bd9 Mon Sep 17 00:00:00 2001 From: christian medders Date: Wed, 6 Nov 2024 21:54:42 -0500 Subject: [PATCH 23/40] DIGITAL-38: file clean up --- .../ECShortCodesFeaturedResourceExt.php | 18 +--- .../ECShortcodesFeaturedResource.php | 86 +++++++++++-------- ...shortcodes-featured-resource-ext.html.twig | 2 +- .../ec-shortcodes-featured-resource.html.twig | 8 +- .../ec-shortcodes-note-disclaimer.html.twig | 4 +- .../ec-shortcodes-note-join.html.twig | 2 +- .../templates/ec-shortcodes-note.html.twig | 11 --- 7 files changed, 59 insertions(+), 72 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php index b893fdc..631bf2b 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php @@ -27,9 +27,8 @@ public function defaultConfiguration() { return [ 'kicker' => NULL, 'url' => NULL, - 'text' => NULL, + 'title' => NULL, 'summary' => NULL, - 'node' => NULL, ]; } @@ -74,21 +73,6 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#default_value' => $this->configuration['text'], '#required' => TRUE, ]; -// $form['node'] = [ -// '#type' => 'entity_autocomplete', -// '#title' => $this->t('Content Reference'), -// '#target_type' => 'node', -// '#tags' => TRUE, -// '#default_value' => $node, -// '#selection_handler' => 'default', -// '#selection_settings' => [ -// 'target_bundles' => ['authors', 'basic_page', 'community', 'event', 'gide', 'news', 'resources', 'services', 'topics'], -// ], -// '#autocreate' => [ -// 'bundle' => 'article', -// // 'uid' => , -// ], -// ]; return $form; } diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php index a5c6e1e..c81a546 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php @@ -2,10 +2,14 @@ namespace Drupal\ec_shortcodes\Plugin\EmbeddedContent; +use Drupal\Core\Entity\Element\EntityAutocomplete; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\embedded_content\EmbeddedContentInterface; use Drupal\embedded_content\EmbeddedContentPluginBase; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; /** * Plugin iframes. @@ -16,19 +20,54 @@ * description = @Translation("Renders a styled button link."), * ) */ -class ECShortcodesFeaturedResource extends EmbeddedContentPluginBase implements EmbeddedContentInterface { +class ECShortcodesFeaturedResource extends EmbeddedContentPluginBase implements EmbeddedContentInterface, ContainerFactoryPluginInterface { use StringTranslationTrait; + /** + * The entity type manager. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected $entityTypeManager; + +/** + * Constructs a ECShortcodesFeaturedResource. + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin_id for the plugin instance. + * @param mixed $plugin_definition + * The plugin implementation definition. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + + * The entity type manager. + + */ + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + + $this->entityTypeManager = $entity_type_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager') + ); + } + /** * {@inheritdoc} */ public function defaultConfiguration() { return [ - // 'kicker' => NULL, - // 'url' => NULL, - // 'text' => NULL, - // 'summary' => NULL, 'content_reference' => NULL, ]; } @@ -39,12 +78,7 @@ public function defaultConfiguration() { public function build(): array { return [ '#theme' => 'ec_shortcodes_featured_resource', - // '#kicker' => $this->configuration['kicker'], - // '#url' => $this->configuration['url'], - // '#title' => $this->configuration['text'], - // '#summary' => $this->configuration['summary'], '#content_reference' => $this->configuration['content_reference'], - ]; } @@ -52,37 +86,19 @@ public function build(): array { * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - // $form['kicker'] = [ - // '#type' => 'textfield', - // '#title' => $this->t('Kicker'), - // '#default_value' => $this->configuration['text'], - // '#required' => TRUE, - // ]; - // $form['url'] = [ - // '#type' => 'url', - // '#title' => $this->t('Url'), - // '#default_value' => $this->configuration['url'], - // '#required' => TRUE, - // ]; - // $form['title'] = [ - // '#type' => 'textfield', - // '#title' => $this->t('Text'), - // '#default_value' => $this->configuration['text'], - // '#required' => TRUE, - // ]; - // $form['summary'] = [ - // '#type' => 'textfield', - // '#title' => $this->t('Summary'), - // '#default_value' => $this->configuration['text'], - // '#required' => TRUE, - // ]; + $node = null; + if (!empty($this->configuration['content_reference'])) { + $node = \Drupal::entityTypeManager()->getStorage('node')->load($this->configuration['content_reference']); + $node = EntityAutocomplete::getEntityLabels([$node]); + } + $form['content_reference'] = [ '#type' => 'entity_autocomplete', '#title' => $this->t('Content Reference'), '#target_type' => 'node', '#process_default_value' => FALSE, '#value_callback' => 'entity_autocomplete_value_callback', - '#default_value' => $this->configuration['content_reference'], + '#default_value' => $node, '#selection_handler' => 'default', '#required' => TRUE, '#selection_settings' => [ diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource-ext.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource-ext.html.twig index ed5d779..d63736f 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource-ext.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource-ext.html.twig @@ -5,7 +5,7 @@ {% if kicker %} {{ kicker }} {% else %} - Featured Resource + {{ 'Featured Resource'|t }} {% endif %}

{% if title %} diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource.html.twig index 98c527a..1b7d647 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource.html.twig @@ -1,12 +1,10 @@ -{% set nodeType = content_reference | title %} - - +{% set nodeType = content_reference.label | title %}
diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-join.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-join.html.twig index 24e2099..dd89d3d 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-join.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-join.html.twig @@ -3,7 +3,7 @@ - Who can join? + {{ 'Who can join?'|t }} {% set text = { '#type': 'processed_text', diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig index 17f0f2d..2c01dea 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig @@ -17,23 +17,12 @@ - {% if selectedType == "Join" %} - Who can join? - {% else %} {{ heading }} - {% endif %} - {% if selectedType == "Disclaimer" %} - All references to specific brands, products, and/or companies are used only - for illustrative purposes and do not imply endorsement by the U.S. federal - government or any federal government agency. - {% else %} {% set text = { '#type': 'processed_text', '#text': text.value, '#format': text.format, } %} {{ text }} - - {% endif %} From 455bce3ff67d3db4acca6465d543e9e33107680d Mon Sep 17 00:00:00 2001 From: christian medders Date: Wed, 6 Nov 2024 21:59:10 -0500 Subject: [PATCH 24/40] DIGITAL-38: standard cleanup --- .../custom/ec_shortcodes/ec_shortcodes.module | 2 +- .../ECShortCodesFeaturedResourceExt.php | 2 +- .../ECShortcodesNoteDisclaimer.php | 24 ------------------ .../EmbeddedContent/ECShortcodesNoteJoin.php | 25 ------------------- 4 files changed, 2 insertions(+), 51 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/ec_shortcodes.module b/web/modules/custom/ec_shortcodes/ec_shortcodes.module index 7e1c248..6249f82 100644 --- a/web/modules/custom/ec_shortcodes/ec_shortcodes.module +++ b/web/modules/custom/ec_shortcodes/ec_shortcodes.module @@ -65,7 +65,7 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { 'summary' => NULL, ], ], - 'ec_shortcodes_featured_resource' => [ + 'ec_shortcodes_featured_resource' => [ 'variables' => [ 'content_reference' => NULL, ], diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php index 631bf2b..6c300e5 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php @@ -16,7 +16,7 @@ * description = @Translation("Renders a styled button link."), * ) */ -class ECShortcodesFeaturedResourceExt extends EmbeddedContentPluginBase implements EmbeddedContentInterface { +class ECShortCodesFeaturedResourceExt extends EmbeddedContentPluginBase implements EmbeddedContentInterface { use StringTranslationTrait; diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteDisclaimer.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteDisclaimer.php index d786512..d759bcb 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteDisclaimer.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteDisclaimer.php @@ -52,30 +52,6 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#title' => $this->t('Note Heading'), '#default_value' => $this->configuration['heading'], ]; - // $form['type'] = [ - // '#type' => 'select', - // '#title' => $this->t('Note Type'), - // '#options' => [ - // 'activity' => $this->t('Activity'), - // 'action' => $this->t('Action'), - // 'alert' => $this->t('Alert'), - // 'comment' => $this->t('Comment'), - // 'video' => $this->t('Video'), - // 'join' => $this->t('Join'), - // 'note' => $this->t('Note'), - // 'disclaimer' => $this->t('Disclaimer'), - // ], - // '#default_value' => $this->configuration['type'], - // '#required' => TRUE, - // ]; - // $form['text'] = [ - // '#type' => 'text_format', - // '#title' => $this->t('Note Text'), - // '#format' => $this->configuration['text']['format'] ?? 'html', - // '#allowed_formats' => ['html'], - // '#default_value' => $this->configuration['text']['value'] ?? '', - // '#required' => TRUE, - // ]; return $form; } diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteJoin.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteJoin.php index 49056ec..e9aaac2 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteJoin.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteJoin.php @@ -25,8 +25,6 @@ class ECShortcodesNoteJoin extends EmbeddedContentPluginBase implements Embedded */ public function defaultConfiguration() { return [ - // 'heading' => NULL, - // 'type' => NULL, 'text' => NULL, ]; } @@ -37,8 +35,6 @@ public function defaultConfiguration() { public function build(): array { return [ '#theme' => 'ec_shortcodes_note_join', - // '#heading' => $this->configuration['heading'], - // '#type' => $this->configuration['type'], '#text' => $this->configuration['text'], ]; } @@ -47,27 +43,6 @@ public function build(): array { * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - // $form['heading'] = [ - // '#type' => 'textfield', - // '#title' => $this->t('Note Heading'), - // '#default_value' => $this->configuration['heading'], - // ]; - // $form['type'] = [ - // '#type' => 'select', - // '#title' => $this->t('Note Type'), - // '#options' => [ - // 'activity' => $this->t('Activity'), - // 'action' => $this->t('Action'), - // 'alert' => $this->t('Alert'), - // 'comment' => $this->t('Comment'), - // 'video' => $this->t('Video'), - // 'join' => $this->t('Join'), - // 'note' => $this->t('Note'), - // 'disclaimer' => $this->t('Disclaimer'), - // ], - // '#default_value' => $this->configuration['type'], - // '#required' => TRUE, - // ]; $form['text'] = [ '#type' => 'text_format', '#title' => $this->t('Note Text'), From da2c898c3a608604b5383ecee9a08d5f01771d63 Mon Sep 17 00:00:00 2001 From: christian medders Date: Fri, 8 Nov 2024 10:58:41 -0500 Subject: [PATCH 25/40] DIGITAL-38: update to feature resource --- composer.json | 1 + composer.lock | 66 ++++++++++++++++++- composer.log | 1 + config/sync/core.extension.yml | 1 + .../ec-shortcodes-featured-resource.html.twig | 16 ++--- .../ec-shortcodes-note-disclaimer.html.twig | 6 +- 6 files changed, 77 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 07cc8e0..ab6b099 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,7 @@ "drupal/require_revision_log_message": "^2.0", "drupal/scheduler": "^2.0", "drupal/scheduler_content_moderation_integration": "^2.0@beta", + "drupal/twig_field_value": "^2.0", "drupal/twig_tweak": "^3.3", "drupal/uswds_templates": "^3.0@dev", "drush/drush": "^12.5", diff --git a/composer.lock b/composer.lock index a09492b..cb46f6c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "863e3efceeba94300161b2363b680513", + "content-hash": "c58be2a3df0e0807fbc74a17450a40f0", "packages": [ { "name": "asm89/stack-cors", @@ -2790,6 +2790,70 @@ "error": "Invalid dependency: \"scheduler\", Could not parse version constraint ~: Invalid version string \"~\"" } }, + { + "name": "drupal/twig_field_value", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/twig_field_value.git", + "reference": "2.0.5" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/twig_field_value-2.0.5.zip", + "reference": "2.0.5", + "shasum": "9a13925fc1f9788db65044b179871139da8a7cfd" + }, + "require": { + "drupal/core": "^9 || ^10 || ^11" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "2.0.5", + "datestamp": "1728385526", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "anybody", + "homepage": "https://www.drupal.org/user/291091" + }, + { + "name": "bizar1984", + "homepage": "https://www.drupal.org/user/3719064" + }, + { + "name": "Gerben Spil", + "homepage": "https://www.drupal.org/user/728030" + }, + { + "name": "grevil", + "homepage": "https://www.drupal.org/user/3668491" + }, + { + "name": "sutharsan", + "homepage": "https://www.drupal.org/user/73854" + }, + { + "name": "thomas.frobieter", + "homepage": "https://www.drupal.org/user/409335" + } + ], + "description": "Twig filters for value(s) and label.", + "homepage": "https://www.drupal.org/project/twig_field_value", + "support": { + "source": "https://git.drupalcode.org/project/twig_field_value" + } + }, { "name": "drupal/twig_tweak", "version": "3.4.0", diff --git a/composer.log b/composer.log index 67792cf..8e9a9df 100644 --- a/composer.log +++ b/composer.log @@ -23,3 +23,4 @@ ae2759e9c45acbf0d8378d04e842d0a8|Matt Poole|develop|Tue Jul 2 13:45:43 EDT 2024 19cf61801de888c57552ec84d66ac668|christian medders|feature/dg-28-shortcode-embed|Wed Oct 16 15:12:23 EDT 2024|./composer.sh require drupal/embedded_content:^2.0 5cef6cc07d3331402a059556429ad233|christian medders|feature/dg-28-shortcode-embed|Wed Oct 16 15:53:48 EDT 2024|./composer.sh remove drupal/ckeditor5_embedded_content ea93266b87251a27fec5df04a3cbd5d0|Matt Poole|feature/DIGITAL-28-shortcode-embed|Thu Oct 24 16:50:38 EDT 2024|./composer.sh require drupal/multivalue_form_element:@beta +94cea224856de297893b41cdaa146ef8|christian medders|feature/DIGITAL-38-migrate-shortcodes|Fri Nov 8 10:32:48 EST 2024|./composer.sh require drupal/twig_field_value diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml index 98565db..9a26793 100644 --- a/config/sync/core.extension.yml +++ b/config/sync/core.extension.yml @@ -53,6 +53,7 @@ module: system: 0 text: 0 toolbar: 0 + twig_field_value: 0 twig_tweak: 0 update: 0 user: 0 diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource.html.twig index 1b7d647..86dbdc4 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource.html.twig @@ -1,4 +1,4 @@ -{% set nodeType = content_reference.label | title %} +{% set summary = drupal_field('field_summary','node', content_reference) | field_value %} - - -{{ node | json_encode(constant('JSON_PRETTY_PRINT')) }} - - - diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-disclaimer.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-disclaimer.html.twig index 8a06e83..4c528b2 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-disclaimer.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-disclaimer.html.twig @@ -5,7 +5,9 @@ {{ heading }} - {{ 'All references to specific brands, products, and/or companies are used only + {% trans %} + All references to specific brands, products, and/or companies are used only for illustrative purposes and do not imply endorsement by the U.S. federal - government or any federal government agency.'|t }} + government or any federal government agency. + {% endtrans %} From ca1b82373fbef28c6a90a8de194a15735c2d5d74 Mon Sep 17 00:00:00 2001 From: christian medders Date: Fri, 8 Nov 2024 11:12:25 -0500 Subject: [PATCH 26/40] DIGITAL-38: code clean up --- .../ECShortcodesFeaturedResource.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php index c81a546..f8c2987 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesFeaturedResource.php @@ -3,13 +3,13 @@ namespace Drupal\ec_shortcodes\Plugin\EmbeddedContent; use Drupal\Core\Entity\Element\EntityAutocomplete; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\embedded_content\EmbeddedContentInterface; use Drupal\embedded_content\EmbeddedContentPluginBase; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; /** * Plugin iframes. @@ -31,7 +31,7 @@ class ECShortcodesFeaturedResource extends EmbeddedContentPluginBase implements */ protected $entityTypeManager; -/** + /** * Constructs a ECShortcodesFeaturedResource. * * @param array $configuration @@ -41,9 +41,7 @@ class ECShortcodesFeaturedResource extends EmbeddedContentPluginBase implements * @param mixed $plugin_definition * The plugin implementation definition. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager. - */ public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); @@ -86,13 +84,13 @@ public function build(): array { * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $node = null; - if (!empty($this->configuration['content_reference'])) { - $node = \Drupal::entityTypeManager()->getStorage('node')->load($this->configuration['content_reference']); - $node = EntityAutocomplete::getEntityLabels([$node]); - } + $node = NULL; + if (!empty($this->configuration['content_reference'])) { + $node = \Drupal::entityTypeManager()->getStorage('node')->load($this->configuration['content_reference']); + $node = EntityAutocomplete::getEntityLabels([$node]); + } -$form['content_reference'] = [ + $form['content_reference'] = [ '#type' => 'entity_autocomplete', '#title' => $this->t('Content Reference'), '#target_type' => 'node', @@ -102,7 +100,9 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#selection_handler' => 'default', '#required' => TRUE, '#selection_settings' => [ - 'target_bundles' => ['authors', 'basic_page', 'community', 'event', 'gide', 'news','resources','services', 'topics'], + 'target_bundles' => ['authors', 'basic_page', 'community', 'event', 'gide', + 'news', 'resources', 'services', 'topics', + ], ], ]; return $form; From efb67d5c2b39c20167d877576f711a7ddb1cf3bd Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Fri, 8 Nov 2024 15:04:52 -0500 Subject: [PATCH 27/40] DIGITAL-38: Only track .vscode/launch.json in the .vscode dir. --- .gitignore | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 01c12db..4f7f52f 100644 --- a/.gitignore +++ b/.gitignore @@ -41,12 +41,8 @@ ehthumbs.db Thumbs.db # Visual Studio Code .vscode/* -.vscode/ -!.vscode/settings.json -!.vscode/tasks.json +!.vscode/ !.vscode/launch.json -!.vscode/extensions.json -!.vscode/*.code-snippets # Local History for Visual Studio Code .history/ # Built Visual Studio Code Extensions From 6efe3256d6897ca20be7d805b2b83558a2369a9a Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Fri, 8 Nov 2024 15:46:47 -0500 Subject: [PATCH 28/40] DIGITAL-38: Replaced deprecated xlink:href with href. --- .../templates/ec-shortcodes-do-dont-table.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig index cae5e1e..00bf86e 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig @@ -22,13 +22,13 @@ {{ 'What you should do'|t }} {{ "What you shouldn't do"|t }} From 4af232ecb405f4fc7c51287ba40ec617533d5301 Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Fri, 8 Nov 2024 16:18:33 -0500 Subject: [PATCH 29/40] DIGITAL-38: Allow do don't to use html. --- .../ECShortcodesDoDontTable.php | 18 ++++++++++++++++-- .../ec-shortcodes-do-dont-table.html.twig | 16 +++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesDoDontTable.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesDoDontTable.php index dd72849..c2c082d 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesDoDontTable.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesDoDontTable.php @@ -52,6 +52,16 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#default_value' => $this->configuration['caption'], '#required' => TRUE, ]; + // Required to change the value of text_format to just be value. + if (!empty($this->configuration['rows'])) { + foreach ($this->configuration['rows'] as $key => &$row) { + if ($key === 'add_more') { + continue; + } + $row['do'] = $row['do']['value']; + $row['dont'] = $row['dont']['value']; + } + } $form['rows'] = [ '#type' => 'multivalue', '#title' => $this->t("Rows"), @@ -59,14 +69,18 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#cardinality' => MultiValue::CARDINALITY_UNLIMITED, '#default_value' => $this->configuration['rows'], 'do' => [ - '#type' => 'textarea', + '#type' => 'text_format', '#title' => $this->t('Do'), + '#format' => 'multiline_inline_html', + '#allowed_formats' => ['multiline_inline_html'], '#description' => $this->t('This will add text for the Do Colum'), ], 'dont' => [ - '#type' => 'textarea', '#title' => $this->t("Don't"), '#description' => $this->t("This will add text for the Don't Colum"), + '#type' => 'text_format', + '#format' => 'multiline_inline_html', + '#allowed_formats' => ['multiline_inline_html'], ], ]; return $form; diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig index 00bf86e..8c85b61 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-do-dont-table.html.twig @@ -1,13 +1,23 @@ {% if rows %} {% set table_rows %}{% apply spaceless %} {% for row in rows %} - {% if row.do is not empty and row.dont is not empty %} + {% if row.do.value is not empty and row.dont.value is not empty %} - {{ row.do }} + {% set do = { + '#type': 'processed_text', + '#text': row.do.value, + '#format': row.do.format, + } %} + {{ do }} - {{ row.dont }} + {% set dont = { + '#type': 'processed_text', + '#text': row.dont.value, + '#format': row.dont.format, + } %} + {{ dont }} {% endif %} From 3b9b4d0d58ec71ee99a4a820d90622967d0b8999 Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Tue, 12 Nov 2024 10:03:09 -0500 Subject: [PATCH 30/40] DIGITAL-38: Allow note to parse properly with the correct input format. --- .../src/Plugin/EmbeddedContent/ECShortcodesNote.php | 4 ++-- .../ec_shortcodes/templates/ec-shortcodes-note.html.twig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNote.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNote.php index 274d77c..2bee22f 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNote.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNote.php @@ -69,8 +69,8 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $form['text'] = [ '#type' => 'text_format', '#title' => $this->t('Note Text'), - '#format' => $this->configuration['text']['format'] ?? 'html', - '#allowed_formats' => ['html'], + '#format' => $this->configuration['text']['format'] ?? 'multiline_inline_html', + '#allowed_formats' => ['multiline_inline_html'], '#default_value' => $this->configuration['text']['value'] ?? '', '#required' => TRUE, ]; diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig index 2c01dea..efe3914 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig @@ -15,7 +15,7 @@

{{ heading }}

From 2c1702b018678ef7b1c371f86cb7acb105ba22cb Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Tue, 12 Nov 2024 10:39:19 -0500 Subject: [PATCH 31/40] DIGITAL-38: Make card policy html compliant and use proper text format. --- .../src/Plugin/EmbeddedContent/ECShortcodesCardPolicy.php | 4 ++-- .../templates/ec-shortcodes-card-policy.html.twig | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesCardPolicy.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesCardPolicy.php index bb5c6e5..0640d16 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesCardPolicy.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesCardPolicy.php @@ -72,8 +72,8 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#type' => 'text_format', '#title' => $this->t('Body'), '#default_value' => $this->configuration['text']['value'] ?? '', - '#format' => 'html', - '#allowed_formats' => ['html'], + '#format' => 'multiline_inline_html', + '#allowed_formats' => ['multiline_inline_html'], ]; return $form; diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-policy.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-policy.html.twig index 25d8a17..0d26bc2 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-policy.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-policy.html.twig @@ -6,7 +6,7 @@ @@ -32,7 +32,7 @@ View the full legislation From e8aa2a6b1bd71dec6b80fcb84dfc14319cfb1f39 Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Tue, 12 Nov 2024 10:40:06 -0500 Subject: [PATCH 32/40] DIGITAL-38: Re-use note theme function for note disclaimer. --- .../custom/ec_shortcodes/ec_shortcodes.module | 1 + .../ECShortcodesNoteDisclaimer.php | 4 ---- .../ec-shortcodes-note-disclaimer.html.twig | 20 ++++++++----------- .../templates/ec-shortcodes-note.html.twig | 18 ++++++++++------- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/ec_shortcodes.module b/web/modules/custom/ec_shortcodes/ec_shortcodes.module index 6249f82..4b406f8 100644 --- a/web/modules/custom/ec_shortcodes/ec_shortcodes.module +++ b/web/modules/custom/ec_shortcodes/ec_shortcodes.module @@ -75,6 +75,7 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) { 'heading' => NULL, 'type' => NULL, 'text' => NULL, + 'text_override' => NULL, ], ], diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteDisclaimer.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteDisclaimer.php index d759bcb..404f2ba 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteDisclaimer.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesNoteDisclaimer.php @@ -26,8 +26,6 @@ class ECShortcodesNoteDisclaimer extends EmbeddedContentPluginBase implements Em public function defaultConfiguration() { return [ 'heading' => NULL, - // 'type' => NULL, - // 'text' => NULL, ]; } @@ -38,8 +36,6 @@ public function build(): array { return [ '#theme' => 'ec_shortcodes_note_disclaimer', '#heading' => $this->configuration['heading'], - // '#type' => $this->configuration['type'], - // '#text' => $this->configuration['text'], ]; } diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-disclaimer.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-disclaimer.html.twig index 4c528b2..d1b39e3 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-disclaimer.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-disclaimer.html.twig @@ -1,13 +1,9 @@ -
-

- - {{ heading }} -

- {% trans %} - All references to specific brands, products, and/or companies are used only +{{ { + '#theme': 'ec_shortcodes_note', + '#type': 'disclaimer', + '#heading': heading, + '#text_override': 'All references to specific brands, products, and/or companies are used only for illustrative purposes and do not imply endorsement by the U.S. federal - government or any federal government agency. - {% endtrans %} -
+ government or any federal government agency.' | t +} +}} diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig index efe3914..d56504c 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note.html.twig @@ -1,4 +1,4 @@ -{% set selectedType = type | title %} +{% set selectedType = type | lower %} {% set icons = { 'activity': 'assessment', 'action': 'campaign', @@ -19,10 +19,14 @@ {{ heading }} - {% set text = { - '#type': 'processed_text', - '#text': text.value, - '#format': text.format, - } %} - {{ text }} + {% if text_override %} + {{ text_override }} + {% else %} + {% set text = { + '#type': 'processed_text', + '#text': text.value, + '#format': text.format, + } %} + {{ text }} + {% endif %}
From 8f9e79f476fff66e450a76b98584b385b07f125d Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Tue, 12 Nov 2024 11:06:06 -0500 Subject: [PATCH 33/40] DIGITAL-38: Make accordion valid dom and use correct input filter. --- .../src/Plugin/EmbeddedContent/ECShortcodesAccordion.php | 4 ++-- .../ec_shortcodes/templates/ec-shortcodes-accordion.html.twig | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAccordion.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAccordion.php index 6c71d77..696910e 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAccordion.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesAccordion.php @@ -71,8 +71,8 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#type' => 'text_format', '#title' => $this->t('Body'), '#default_value' => $this->configuration['text']['value'] ?? '', - '#format' => 'html', - '#allowed_formats' => ['html'], + '#format' => 'multiline_inline_html', + '#allowed_formats' => ['multiline_inline_html'], ]; return $form; diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig index 5090d65..55d17ab 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig @@ -4,13 +4,13 @@ {% if icon %} {% else %} {% endif %} From 2f899a37c683d3e77fced6f113ecc6b0877f18fa Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Tue, 12 Nov 2024 11:07:06 -0500 Subject: [PATCH 34/40] DIGITAL-38: Apply patch to convert html that is invalid in xml to valid xml. --- composer.lock | 4 ++-- composer.log | 1 + composer.patches.json | 3 +++ ...bedded_content-convert-html-valid-xml.patch | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 patches/embedded_content-convert-html-valid-xml.patch diff --git a/composer.lock b/composer.lock index cf4df71..c68b88e 100644 --- a/composer.lock +++ b/composer.lock @@ -14764,7 +14764,7 @@ }, "prefer-stable": true, "prefer-lowest": false, - "platform": [], - "platform-dev": [], + "platform": {}, + "platform-dev": {}, "plugin-api-version": "2.6.0" } diff --git a/composer.log b/composer.log index 1f5da43..9d93168 100644 --- a/composer.log +++ b/composer.log @@ -31,3 +31,4 @@ ea93266b87251a27fec5df04a3cbd5d0|Matt Poole|feature/DIGITAL-28-shortcode-embed|T 1eaf30055796759652004514d15f30d9|christian medders|feature/DIGITAL-31-sitemap-path-auto|Fri Nov 8 14:03:39 EST 2024|./composer.sh require drupal/pathauto:^1.13 58d882c244d0e746a3ad90844a2f361f|christian medders|feature/DIGITAL-31-sitemap-path-auto|Fri Nov 8 14:05:23 EST 2024|./composer.sh require drupal/xmlsitemap:^1.5 94cea224856de297893b41cdaa146ef8|christian medders|feature/DIGITAL-38-migrate-shortcodes|Fri Nov 8 10:32:48 EST 2024|./composer.sh require drupal/twig_field_value +464e1ed27d945bb31dcb7a3d79a19d13|Matt Poole|feature/DIGITAL-38-migrate-shortcodes|Tue Nov 12 16:04:45 UTC 2024|./composer.sh update --lock diff --git a/composer.patches.json b/composer.patches.json index 6fa2e09..e533ef3 100644 --- a/composer.patches.json +++ b/composer.patches.json @@ -8,6 +8,9 @@ "/project/default_content/issues/3203014: BaseFieldOverride cause inconsistencies during export": "https://www.drupal.org/files/issues/2022-12-13/base_field_override_inconsistencies-3203014-9.patch", "/project/default_content/issues/3200212: Import should overwrite files": "https://www.drupal.org/files/issues/2024-08-27/default_content-3200212-25.patch" }, + "drupal/embedded_content": { + "Convert html to valid xml": "patches/embedded_content-convert-html-valid-xml.patch" + }, "drupal/maillog": { "/project/maillog/issues/3176023: Not configurable sender and other issues.": "https://www.drupal.org/files/issues/2024-07-24/maillog-n3176023-9.patch" } diff --git a/patches/embedded_content-convert-html-valid-xml.patch b/patches/embedded_content-convert-html-valid-xml.patch new file mode 100644 index 0000000..6bd85a0 --- /dev/null +++ b/patches/embedded_content-convert-html-valid-xml.patch @@ -0,0 +1,18 @@ +Index: src/Plugin/Filter/EmbeddedContent.php +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/Plugin/Filter/EmbeddedContent.php b/src/Plugin/Filter/EmbeddedContent.php +--- a/src/Plugin/Filter/EmbeddedContent.php ++++ b/src/Plugin/Filter/EmbeddedContent.php (date 1731427147463) +@@ -88,6 +88,8 @@ + $replacement = $instance->build(); + $context = new RenderContext(); + $render = $this->renderer->executeInRenderContext($context, fn() => $this->renderer->render($replacement)); ++ // Allow   in the xml by replacing them with decimal entity. ++ $render = str_replace(' ', ' ', $render); + if (!$context->isEmpty()) { + $bubbleable = $bubbleable->merge($context->pop()); + } + From 98f9d7f8cfeed3a13c931ae349f5bb0514a4fcb6 Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Tue, 12 Nov 2024 11:11:01 -0500 Subject: [PATCH 35/40] DIGITAL-38: Check the sub item of text.value, text always is not empty. --- .../ec_shortcodes/templates/ec-shortcodes-accordion.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig index 55d17ab..8d2e1c4 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-accordion.html.twig @@ -26,7 +26,7 @@ - {% if text %} + {% if text.value %}
{% set text = { '#type': 'processed_text', From 326424b5a0161c6bdfd4f3090168ab99da354a9b Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Tue, 12 Nov 2024 11:14:06 -0500 Subject: [PATCH 36/40] DIGITAL-38: Re-use note template again for note join. --- .../ec-shortcodes-note-join.html.twig | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-join.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-join.html.twig index dd89d3d..e8f09ed 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-join.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-note-join.html.twig @@ -1,15 +1,7 @@ -
-

- - {{ 'Who can join?'|t }} -

- {% set text = { - '#type': 'processed_text', - '#text': text.value, - '#format': text.format, - } %} - {{ text }} -
- +{{ { + '#theme': 'ec_shortcodes_note', + '#type': 'join', + '#heading': 'Who can join?' | t, + '#text': text +} +}} From b14c0f7d36ae29b734bf45ad01d3cc298952550a Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Tue, 12 Nov 2024 11:27:20 -0500 Subject: [PATCH 37/40] DIGITAL-38: Allow html for card prompt. --- .../ECShortcodesCardPrompt.php | 12 +++-- .../ec-shortcodes-card-prompt.html.twig | 50 ++++++++++++------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesCardPrompt.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesCardPrompt.php index bf72dcf..aa09599 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesCardPrompt.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortcodesCardPrompt.php @@ -50,15 +50,19 @@ public function build(): array { */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['intro'] = [ - '#type' => 'textfield', + '#type' => 'text_format', '#title' => $this->t('Intro'), - '#default_value' => $this->configuration['intro'], + '#format' => 'multiline_inline_html', + '#allowed_formats' => ['multiline_inline_html'], + '#default_value' => $this->configuration['text']['value'] ?? '', '#required' => TRUE, ]; $form['prompt'] = [ - '#type' => 'textfield', + '#type' => 'text_format', '#title' => $this->t('Prompt'), - '#default_value' => $this->configuration['prompt'], + '#format' => 'multiline_inline_html', + '#allowed_formats' => ['multiline_inline_html'], + '#default_value' => $this->configuration['text']['value'] ?? '', '#required' => TRUE, ]; $form['text'] = [ diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-prompt.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-prompt.html.twig index 68b4b9f..f191208 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-prompt.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-card-prompt.html.twig @@ -1,22 +1,36 @@ -
- {% if intro %} -
-
- -
-

{{ intro }}

-
+
+ {% if intro %} +
+
+ +
+ {% set intro = { + '#type': 'processed_text', + '#text': intro.value, + '#format': intro.format, + } %} +

{{ intro }}

+
{% endif %} -{% if prompt %} -
- {{ prompt }} -
-{% endif %} + {% if prompt.value %} +
+ {% set prompt = { + '#type': 'processed_text', + '#text': prompt.value, + '#format': prompt.format, + } %} + {{ prompt }} +
+ {% endif %} - - {{ text }} - + {# NOT-MIGRATED + This was what was here before, when we migrate the partial, use it. + {{ partial "core/usa-button.html" (dict "href" (.Get "button-url") "text" (.Get "button-text")) }} + #} + + {{ text }} +
From 9ed3d7bc1ee77b1d499bdb7533c9daaf4d62b62b Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Tue, 12 Nov 2024 11:51:40 -0500 Subject: [PATCH 38/40] DIGITAL-38: Set default fields to correct keys. Make URL work for internal resource. --- .../ECShortCodesFeaturedResourceExt.php | 6 ++-- ...shortcodes-featured-resource-ext.html.twig | 4 +++ .../ec-shortcodes-featured-resource.html.twig | 33 +++++++++++-------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php index 6c300e5..d3eaecc 100644 --- a/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php +++ b/web/modules/custom/ec_shortcodes/src/Plugin/EmbeddedContent/ECShortCodesFeaturedResourceExt.php @@ -52,7 +52,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $form['kicker'] = [ '#type' => 'textfield', '#title' => $this->t('Kicker'), - '#default_value' => $this->configuration['text'], + '#default_value' => $this->configuration['kicker'], '#required' => TRUE, ]; $form['url'] = [ @@ -64,13 +64,13 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $form['title'] = [ '#type' => 'textfield', '#title' => $this->t('Text'), - '#default_value' => $this->configuration['text'], + '#default_value' => $this->configuration['title'], '#required' => TRUE, ]; $form['summary'] = [ '#type' => 'textfield', '#title' => $this->t('Summary'), - '#default_value' => $this->configuration['text'], + '#default_value' => $this->configuration['summary'], '#required' => TRUE, ]; return $form; diff --git a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource-ext.html.twig b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource-ext.html.twig index d63736f..941d79d 100644 --- a/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource-ext.html.twig +++ b/web/modules/custom/ec_shortcodes/templates/ec-shortcodes-featured-resource-ext.html.twig @@ -1,3 +1,7 @@ +{# NOT MIGRATED + This should be the partial for featured recources + Kicker should also allow html, but only a single line. +#}