Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digital-38: migrate shortcodes templates #36

Merged
merged 42 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7167543
DIGITAL-38: Update to btn sc
clmedders Oct 29, 2024
ead7b80
DIGITAL-38: Saving work for note shortcode
clmedders Oct 30, 2024
7f13ed9
Merge remote-tracking branch 'origin' into feature/DIGITAL-38-migrate…
clmedders Oct 30, 2024
70eb0d6
DIGITAL-38: Adding VSCODE file to gitignore
clmedders Oct 30, 2024
69fd2d5
DIGITAL-38: accordion work
clmedders Oct 31, 2024
b36b648
DIGITAL-38: Accordion shortcode
clmedders Oct 31, 2024
5676d07
DIGITAL-38: card prompt short code
clmedders Nov 1, 2024
4316ee3
DIGITAL-38: clean up accordion file
clmedders Nov 1, 2024
1960abb
DIGITAL-38: update to card quote short code
clmedders Nov 1, 2024
0a11f59
DIGITAL-38: card prompt clean up
clmedders Nov 1, 2024
e4fc2e5
DIGITAL-38: Note shortcode
clmedders Nov 4, 2024
e08e8d4
DIGITAL-38: update count for accordion
clmedders Nov 4, 2024
c0c2f52
DIGITAL-38: addin card policy short code
clmedders Nov 4, 2024
4e818fc
DIGITAL-38: removing high light shortcode
clmedders Nov 4, 2024
7fd4967
DIGITAL-38: saving work for author bio
clmedders Nov 4, 2024
ac71aed
DIGITAL-38: adding fetured resource shortcode
clmedders Nov 4, 2024
eccedf5
DIGITAL-38: adding do dont table
clmedders Nov 5, 2024
fd8127b
DIGITAL-38: file clean up
clmedders Nov 5, 2024
6d456d7
DIGITAL-38: File clean up
clmedders Nov 6, 2024
631bf72
DIGITAL-38: updating note shortcode
clmedders Nov 6, 2024
55ae535
DIGITAL-38: removed author bio shortcode
clmedders Nov 6, 2024
5c858c1
DIGITAL-38: saving work
clmedders Nov 6, 2024
9f7ef8e
DIGITAL-38: update to do dont table
clmedders Nov 7, 2024
60501c6
DIGITAL-38: file clean up
clmedders Nov 7, 2024
455bce3
DIGITAL-38: standard cleanup
clmedders Nov 7, 2024
da2c898
DIGITAL-38: update to feature resource
clmedders Nov 8, 2024
ca1b823
DIGITAL-38: code clean up
clmedders Nov 8, 2024
b47b60c
Merge remote-tracking branch 'origin' into feature/DIGITAL-38-migrate…
clmedders Nov 8, 2024
efb67d5
DIGITAL-38: Only track .vscode/launch.json in the .vscode dir.
mattsqd Nov 8, 2024
6efe325
DIGITAL-38: Replaced deprecated xlink:href with href.
mattsqd Nov 8, 2024
4af232e
DIGITAL-38: Allow do don't to use html.
mattsqd Nov 8, 2024
3b9b4d0
DIGITAL-38: Allow note to parse properly with the correct input format.
mattsqd Nov 12, 2024
2c1702b
DIGITAL-38: Make card policy html compliant and use proper text format.
mattsqd Nov 12, 2024
e8aa2a6
DIGITAL-38: Re-use note theme function for note disclaimer.
mattsqd Nov 12, 2024
8f9e79f
DIGITAL-38: Make accordion valid dom and use correct input filter.
mattsqd Nov 12, 2024
2f899a3
DIGITAL-38: Apply patch to convert html that is invalid in xml to val…
mattsqd Nov 12, 2024
98f9d7f
DIGITAL-38: Check the sub item of text.value, text always is not empty.
mattsqd Nov 12, 2024
326424b
DIGITAL-38: Re-use note template again for note join.
mattsqd Nov 12, 2024
b14c0f7
DIGITAL-38: Allow html for card prompt.
mattsqd Nov 12, 2024
9ed3d7b
DIGITAL-38: Set default fields to correct keys. Make URL work for int…
mattsqd Nov 12, 2024
8e1d7ae
DIGITAL-38: Fixed default value for card quote cite.
mattsqd Nov 12, 2024
d07abfd
DIGITAL-38: Add todo to make quote block support HTML.
mattsqd Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ Thumbs.db
# Visual Studio Code
.vscode/*
!.vscode/
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,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",
"drupal/vbo_workflow_transition": "1.0.x-dev@dev",
Expand Down
561 changes: 312 additions & 249 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions composer.log
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ ea93266b87251a27fec5df04a3cbd5d0|Matt Poole|feature/DIGITAL-28-shortcode-embed|T
3d742a578663c259c7f20fe529971425|Matt Poole|feature/DIGITAL-45-roles-and-perms|Wed Nov 6 09:56:58 EST 2024|./composer.sh require drupal/views_bulk_operations
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
3 changes: 3 additions & 0 deletions composer.patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
1 change: 1 addition & 0 deletions config/sync/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module:
text: 0
token: 0
toolbar: 0
twig_field_value: 0
twig_tweak: 0
update: 0
user: 0
Expand Down
18 changes: 18 additions & 0 deletions patches/embedded_content-convert-html-valid-xml.patch
Original file line number Diff line number Diff line change
@@ -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 &nbsp; in the xml by replacing them with decimal entity.
+ $render = str_replace('&nbsp;', '&#160;', $render);
if (!$context->isEmpty()) {
$bubbleable = $bubbleable->merge($context->pop());
}

40 changes: 30 additions & 10 deletions web/modules/custom/ec_shortcodes/ec_shortcodes.module
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,21 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) {
'kicker' => NULL,
'title' => NULL,
'icon' => NULL,
],
],
'ec_shortcodes_author_bio' => [
'variables' => [
'name' => NULL,
'bio' => NULL,
'text' => NULL,
],
],
'ec_shortcodes_card_policy' => [
'variables' => [
'kicker' => NULL,
'title' => NULL,
'src' => NULL,
'text' => NULL,
],
],
'ec_shortcodes_card_prompt' => [
'variables' => [
'intro' => NULL,
'prompt' => NULL,
'text' => NULL,
'url' => NULL,
],
Expand All @@ -60,25 +57,48 @@ function ec_shortcodes_theme($existing, $type, $theme, $path) {
'rows' => NULL,
],
],
'ec_shortcodes_featured_resource' => [
'ec_shortcodes_featured_resource_ext' => [
'variables' => [
'kicker' => NULL,
'url' => NULL,
'text' => NULL,
'title' => NULL,
'summary' => NULL,
],
],
'ec_shortcodes_highlight' => [
'ec_shortcodes_featured_resource' => [
'variables' => [
'text' => NULL,
'content_reference' => NULL,
],
],
'ec_shortcodes_note' => [
'variables' => [
'heading' => NULL,
'type' => NULL,
'text' => NULL,
'text_override' => NULL,
],
],

'ec_shortcodes_note_join' => [
'variables' => [
'text' => NULL,
],
],
'ec_shortcodes_note_disclaimer' => [
'variables' => [
'heading' => NULL,
],
],
];
}

/**
* Implements hook_preprocess_HOOK().
*/
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_join', 'ec_shortcodes_note_disclaimer',
])) {
$variables['theme_path'] = \Drupal::theme()->getActiveTheme()->getPath();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace Drupal\ec_shortcodes\Plugin\EmbeddedContent;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\embedded_content\EmbeddedContentInterface;
use Drupal\embedded_content\EmbeddedContentPluginBase;

/**
* Plugin iframes.
*
* @EmbeddedContent(
* id = "ec_shortcodes_featured_resource_ext",
* label = @Translation("Featured Resource - External"),
* description = @Translation("Renders a styled button link."),
* )
*/
class ECShortCodesFeaturedResourceExt extends EmbeddedContentPluginBase implements EmbeddedContentInterface {

use StringTranslationTrait;

/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'kicker' => NULL,
'url' => NULL,
'title' => NULL,
'summary' => 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['kicker'],
'#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['title'],
'#required' => TRUE,
];
$form['summary'] = [
'#type' => 'textfield',
'#title' => $this->t('Summary'),
'#default_value' => $this->configuration['summary'],
'#required' => TRUE,
];
return $form;
}

/**
* {@inheritDoc}
*/
public function isInline(): bool {
return FALSE;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function defaultConfiguration() {
'kicker' => NULL,
'title' => NULL,
'icon' => NULL,
'text' => NULL,
];
}

Expand All @@ -40,6 +41,7 @@ public function build(): array {
'#kicker' => $this->configuration['kicker'],
'#title' => $this->configuration['title'],
'#icon' => $this->configuration['icon'],
'#text' => $this->configuration['text'],
];
}

Expand All @@ -50,21 +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'] = [
'#type' => 'text_format',
'#title' => $this->t('Body'),
'#default_value' => $this->configuration['text']['value'] ?? '',
'#format' => 'multiline_inline_html',
'#allowed_formats' => ['multiline_inline_html'],
];

return $form;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function defaultConfiguration() {
'kicker' => NULL,
'title' => NULL,
'src' => NULL,
'text' => NULL,
];
}

Expand All @@ -40,6 +41,8 @@ public function build(): array {
'#kicker' => $this->configuration['kicker'],
'#title' => $this->configuration['title'],
'#src' => $this->configuration['src'],
'#text' => $this->configuration['text'],

];
}

Expand All @@ -50,13 +53,13 @@ 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['url'] = [
Expand All @@ -65,6 +68,13 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
'#default_value' => $this->configuration['url'],
'#required' => TRUE,
];
$form['text'] = [
'#type' => 'text_format',
'#title' => $this->t('Body'),
'#default_value' => $this->configuration['text']['value'] ?? '',
'#format' => 'multiline_inline_html',
'#allowed_formats' => ['multiline_inline_html'],
];

return $form;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ECShortcodesCardPrompt extends EmbeddedContentPluginBase implements Embedd
public function defaultConfiguration() {
return [
'intro' => NULL,
'prompt' => NULL,
'text' => NULL,
'url' => NULL,
];
Expand All @@ -38,6 +39,7 @@ public function build(): array {
return [
'#theme' => 'ec_shortcodes_card_prompt',
'#intro' => $this->configuration['intro'],
'#prompt' => $this->configuration['prompt'],
'#text' => $this->configuration['text'],
'#url' => $this->configuration['url'],
];
Expand All @@ -48,9 +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['text'],
'#format' => 'multiline_inline_html',
'#allowed_formats' => ['multiline_inline_html'],
'#default_value' => $this->configuration['text']['value'] ?? '',
'#required' => TRUE,
];
$form['prompt'] = [
'#type' => 'text_format',
'#title' => $this->t('Prompt'),
'#format' => 'multiline_inline_html',
'#allowed_formats' => ['multiline_inline_html'],
'#default_value' => $this->configuration['text']['value'] ?? '',
'#required' => TRUE,
];
$form['text'] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
$form['cite'] = [
'#type' => 'textfield',
'#title' => $this->t('Cite'),
'#default_value' => $this->configuration['text'],
'#default_value' => $this->configuration['cite'],
'#required' => TRUE,
];

Expand Down
Loading