Skip to content

Commit

Permalink
Merge pull request #259 from Bixal/feature/BSD-258-contact-recaptcha
Browse files Browse the repository at this point in the history
BSD fixes #258: Remove contact form from bottom, add as menu item.
  • Loading branch information
mattsqd authored Aug 1, 2024
2 parents 884fe08 + 8164cf6 commit 55f54da
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
# These are set in platform.sh as variables only on prod.
EMAIL_USERNAME: ''
EMAIL_PASSWORD: ''
# Used to enable recaptcha.
RECAPTCHA_SECRET_KEY: ''
cache:
type: 'redis:6'
node:
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 @@ -5,6 +5,7 @@ module:
admin_toolbar_search: 0
admin_toolbar_tools: 0
autocomplete_deluxe: 0
bixal_captcha: 0
bixal_default_content: 0
bixal_drush_commands: 0
block: 0
Expand Down
8 changes: 7 additions & 1 deletion config/sync/core.menu.static_menu_link_overrides.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
_core:
default_config_hash: jdY7AU0tU-QsjmiOw3W8vwpYMb-By--_MSFgbqKUTYM
definitions: { }
definitions:
contact__site_page:
enabled: true
menu_name: footer
parent: ''
expanded: false
weight: 0
3 changes: 3 additions & 0 deletions stories/assets/styles/global/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ h6 {
margin: 14px 0;
padding: 0 10px;
text-transform: uppercase;
h1 {
all: unset;
}
}

dl {
Expand Down
5 changes: 5 additions & 0 deletions web/modules/custom/bixal_captcha/bixal_captcha.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: 'Bixal Captcha'
type: module
description: 'Alters captcha functionality.'
package: Custom
core_version_requirement: ^10
19 changes: 19 additions & 0 deletions web/modules/custom/bixal_captcha/bixal_captcha.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* @file
* Primary module hooks for Bixal Captcha module.
*/

/**
* Implements hook_captcha_alter().
*/
function bixal_captcha_captcha_alter(&$captcha, $info) {
// If the captcha is cacheable and the env variable is not set to enable
// caching for these, turn off caching. reCaptcha was not working with
// caching on.
if (!getenv('CAPTCHA_ALLOW_CACHEABLE') && ($captcha['cacheable'] ?? FALSE) === TRUE) {
$captcha['form']['#cache']['max-age'] = 0;
\Drupal::service('page_cache_kill_switch')->trigger();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
_meta:
version: '1.0'
entity_type: menu_link_content
uuid: e82e4e98-8db6-4dea-9295-e67608b5ef07
bundle: menu_link_content
default_langcode: en
default:
enabled:
-
value: true
title:
-
value: Contact
menu_name:
-
value: main
link:
-
uri: 'internal:/contact'
title: ''
options: { }
external:
-
value: false
rediscover:
-
value: true
weight:
-
value: 0
expanded:
-
value: false
5 changes: 5 additions & 0 deletions web/themes/custom/bixal_uswds/php-includes/page.inc
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ function bixal_uswds_preprocess_page(&$vars) {
$vars['footer'] = [
'#theme' => 'site_wrapper_footer',
];

// Show the contact form in the footer if:
// * The env variable is set
// * The current page is not /contact.
$vars['show_contact_form_in_footer'] = getenv('SHOW_CONTACT_FORM_IN_FOOTER') && \Drupal::routeMatch()->getRouteName() !== 'contact.site_page';
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="bix-container">
<div class="bix-contact__content">
<div class="contact__overview">
<div class="bix-title-prefix">Contact</div>
<div class="bix-title-prefix"><h1>Contact</h1></div>
<h2>
{{ 'How can we help?'|t }}<br />
{{ 'We\'d love to hear from you.'|t }}
Expand Down
6 changes: 4 additions & 2 deletions web/themes/custom/bixal_uswds/templates/layout/page.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
{% endblock %}
</main>

{# Contact block module did not work, it would not print the forms classes. #}
{{ drupal_entity_form('contact_message', values={contact_form: 'site_wide'}) }}
{% if show_contact_form_in_footer %}
{# Contact block module did not work, it would not print the forms classes. #}
{{ drupal_entity_form('contact_message', values={contact_form: 'site_wide'}) }}
{% endif %}
{{ footer }}

0 comments on commit 55f54da

Please sign in to comment.