Skip to content

Commit

Permalink
accessibility form test (pre SSL)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrturner committed Feb 26, 2024
1 parent 211d0f8 commit ada4d01
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 97 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ Icon
/local.sh
/zzz/*
/assets/font/Herbik
/site/config/db.php
/site/config/db.php
# /site/templates/z_test.php
# /content/z_test
1 change: 1 addition & 0 deletions content/z_test/z_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Uuid: HIAGvn3L1XPu29XC
2 changes: 1 addition & 1 deletion kirby
Submodule kirby updated 56 files
+1 −1 .gitattributes
+14 −26 .github/workflows/backend.yml
+4 −28 .github/workflows/frontend.yml
+6 −1 SECURITY.md
+1 −1 composer.json
+2 −2 composer.lock
+21 −2 config/api/routes/users.php
+1 −2 config/fields/link.php
+1 −1 config/sections/stats.php
+1 −1 i18n/translations/de.json
+4 −4 i18n/translations/ru.json
+2 −0 panel/.prettierignore
+1 −1 panel/dist/css/style.min.css
+1 −1 panel/dist/js/index.min.js
+19 −0 panel/lab/components/buttons/4_groups/index.vue
+8 −0 panel/lab/components/fieldpreviews/date/index.vue
+8 −8 panel/lab/components/filepreview/index.vue
+13 −0 panel/lab/components/icon/index.vue
+1 −6 panel/src/components/Forms/Field/EmailField.vue
+1 −6 panel/src/components/Forms/Field/NumberField.vue
+1 −6 panel/src/components/Forms/Field/PasswordField.vue
+1 −6 panel/src/components/Forms/Field/RangeField.vue
+1 −6 panel/src/components/Forms/Field/SelectField.vue
+1 −7 panel/src/components/Forms/Field/TagsField.vue
+1 −6 panel/src/components/Forms/Field/TelField.vue
+1 −6 panel/src/components/Forms/Field/TextField.vue
+1 −6 panel/src/components/Forms/Field/TextareaField.vue
+1 −6 panel/src/components/Forms/Field/ToggleField.vue
+9 −7 panel/src/components/Forms/Field/UrlField.vue
+1 −1 panel/src/components/Forms/Input/ColorpickerInput.vue
+4 −0 panel/src/components/Forms/Previews/DateFieldPreview.vue
+2 −2 panel/src/components/Forms/Writer/Extensions.js
+1 −1 panel/src/components/Forms/Writer/Marks/Link.js
+2 −22 panel/src/components/Layout/Frame/IconFrame.vue
+3 −5 panel/src/components/Layout/View.vue
+20 −1 panel/src/components/Misc/Icon.vue
+1 −0 panel/src/components/Navigation/ButtonGroup.vue
+1 −0 panel/src/components/Text/Label.vue
+2 −2 panel/src/helpers/sort.js
+5 −0 panel/src/helpers/string.js
+9 −0 panel/src/helpers/url.isUrl.test.js
+13 −3 panel/src/helpers/url.js
+1 −1 panel/src/panel/language.test.js
+8 −0 src/Cms/FileModifications.php
+2 −1 src/Cms/LicenseStatus.php
+9 −0 src/Filesystem/File.php
+1 −0 src/Http/Remote.php
+1 −1 src/Panel/Panel.php
+10 −1 src/Toolkit/Str.php
+30 −0 tests/Cms/Files/FileModificationsTest.php
+15 −4 tests/Filesystem/FileTest.php
+1 −2 tests/Form/Fields/LinkFieldTest.php
+1 −0 tests/Http/UrlTest.php
+12 −0 tests/Toolkit/StrTest.php
+45 −51 vendor/composer/ClassLoader.php
+6 −6 vendor/composer/installed.php
6 changes: 6 additions & 0 deletions site/blueprints/pages/z_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
title: TEST

fields:
description:
label: Description
type: textarea
15 changes: 13 additions & 2 deletions site/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,25 @@ function generateRelationsJson()
* all config options: https://getkirby.com/docs/reference/system/options
*/
return [
// 'debug' => true,
'debug' => false,
'debug' => true,
// 'debug' => false,
'panel' => [
'install' => true
],
'api' => [
'basicAuth' => true
],
'email' => [
'transport' => [
'type' => 'smtp',
//'host' => 'smtp.company.com',
'host' => 'cp-wc01.per01.ds.network',
'port' => 465,
'security' => true,
'username' => '[email protected]',
'password' => "Dn;in'}47CAd,pk"
]
],
'languages' => true,
'thumbs' => [
'srcsets' => [
Expand Down
2 changes: 1 addition & 1 deletion site/controllers/accessibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
try {
$kirby->email([
'template' => 'email',
'from' => 'alexrturner@gmail.com',
'from' => 'info@tonelist.com.au',
'replyTo' => $data['email'],
'to' => '[email protected]',
'subject' => esc($data['name']) . ' (' . esc($data['pronouns']) . ') sent you an accessibility request via the AE website.',
Expand Down
79 changes: 79 additions & 0 deletions site/controllers/z_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
return function ($kirby, $pages, $page) {

$alert = null;

if ($kirby->request()->is('POST') && get('submit')) {
dump($_POST); // check if you get into this if-statement at all
// check the honeypot
if (empty(get('website')) === false) {
go($page->url());
exit;
}

$data = [
'name' => get('name'),
'pronouns' => get('pronouns'),
'email' => get('email'),
'phone' => get('phone'),
'text' => get('text')
];

$rules = [
'name' => [],
'pronouns' => [],
'email' => ['email'],
'phone' => ['phone'],
'text' => ['minLength' => 3, 'maxLength' => 3000],
];

$messages = [
'name' => 'Please enter your name',
'pronouns' => 'Please enter your pronouns',
'email' => 'Please enter a valid email address',
'phone' => 'Please enter a valid phone number',
'text' => 'Please enter your accessibility request'
];

// some of the data is invalid
if ($invalid = invalid($data, $rules, $messages)) {
$alert = $invalid;

// the data is fine, let's send the email
} else {
dump($data);
try {
$kirby->email([
'template' => 'email',
'from' => '[email protected]',
'replyTo' => $data['email'],
'to' => '[email protected]',
'subject' => esc($data['name']) . ' (' . esc($data['pronouns']) . ') sent you an accessibility request via the AE website.',
'data' => [
'text' => esc($data['text']),
'sender' => esc($data['name'])
]

]);
} catch (Exception $error) {
if (option('debug')) :
$alert['error'] = 'The form could not be sent: ' . $error->getMessage();
else :
$alert['error'] = 'The form could not be sent!';
endif;
}

// no exception occurred, let's send a success message
if (empty($alert) === true) {
$success = 'Your message has been sent, thank you. We will get back to you soon!';
$data = [];
}
}
}

return [
'alert' => $alert,
'data' => $data ?? false,
'success' => $success ?? false
];
};
File renamed without changes.
92 changes: 0 additions & 92 deletions site/templates/upcoming.php

This file was deleted.

66 changes: 66 additions & 0 deletions site/templates/z_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php snippet('header') ?>

<main class="main content-container index">

<section id="col1" class="intro" style="max-width: 60ch;">
<?= kt($page->intro()) ?>
</section>

<section id="col2" class="description" style="max-width: 60ch;">
<?= kt($page->description()) ?>
</section>

<section id="col3" class="form" style="max-width: 60ch;">

<?= kt($page->form()) ?>

<?php if ($success) : ?>
<div class="alert success">
<p><?= $success ?></p>
</div>
<?php else : ?>
<?php if (isset($alert['error'])) : ?>
<div><?= $alert['error'] ?></div>
<?php endif ?>
<form method="post" action="<?= $page->url() ?>">
<div class="honeypot" style="position: absolute; left: -9999px;">
<label for="website">Website <abbr title="required">*</abbr></label>
<input type="url" id="website" name="website" tabindex="-1">
</div>
<div class="field-group">
<div class="field half">
<input type="text" id="name" name="name" value="<?= esc($data['name'] ?? '', 'attr') ?>" placeholder="Name">
<?= isset($alert['name']) ? '<span class="alert error">' . esc($alert['name']) . '</span>' : '' ?>
</div>
<div class="field half">
<input type="text" id="pronouns" name="pronouns" value="<?= esc($data['pronouns'] ?? '', 'attr') ?>" placeholder="Pronouns">
<?= isset($alert['pronouns']) ? '<span class="alert error">' . esc($alert['pronouns']) . '</span>' : '' ?>
</div>
</div>
<div class="field-group">
<div class="field half">
<input type="email" id="email" name="email" value="<?= esc($data['email'] ?? '', 'attr') ?>" placeholder="eMail">
<?= isset($alert['email']) ? '<span class="alert error">' . esc($alert['email']) . '</span>' : '' ?>
</div>
<div class="field half">
<input type="tel" id="phone" name="phone" value="<?= esc($data['phone'] ?? '', 'attr') ?>" placeholder="Phone">
<?= isset($alert['phone']) ? '<span class="alert error">' . esc($alert['phone']) . '</span>' : '' ?>
</div>
</div>
<div class="field">
<textarea id="text" name="text" placeholder="Request" required><?= esc($data['text'] ?? '') ?></textarea>

<?= isset($alert['text']) ? '<span class="alert error">' . esc($alert['text']) . '</span>' : '' ?>
</div>
<div>
<button class="button__link button__submit" type="submit">Get in Touch</button>
<!-- <input type="submit" name="submit" value="Get in Touch"> -->
</div>
</form>
<?php endif ?>
</section>

</main>


<?php snippet('footer') ?>

0 comments on commit ada4d01

Please sign in to comment.