From e284d006664408e7c0f1259113d89efc76e28293 Mon Sep 17 00:00:00 2001 From: librasteve Date: Wed, 24 Jun 2026 10:42:54 +0100 Subject: [PATCH 1/5] add 29-mailform --- Changes | 1 + META6.json | 3 ++- bin/29-mailform.raku | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 bin/29-mailform.raku diff --git a/Changes b/Changes index 9383d42..dd65d27 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for Air::Examples {{$NEXT}} + - add 29-mailform 0.0.25 2026-06-23T17:23:18+01:00 - add Fold to baseexamples diff --git a/META6.json b/META6.json index 456be76..6dc0dfa 100644 --- a/META6.json +++ b/META6.json @@ -10,7 +10,8 @@ "Air::Plugin::Hilite", "Air::Plugin::Asciinema", "Air::Plugin::Wordcloud", - "Air::Plugin::Rakudoc" + "Air::Plugin::Rakudoc", + "Air::Plugin::MailForm" ], "description": "hArc stack website examples (HTMX, Air, Red, Cro)", "license": "Artistic-2.0", diff --git a/bin/29-mailform.raku b/bin/29-mailform.raku new file mode 100644 index 0000000..37a4600 --- /dev/null +++ b/bin/29-mailform.raku @@ -0,0 +1,23 @@ +#!/usr/bin/env raku + +use Air::Functional :BASE; +use Air::Base; +use Air::Plugin::MailForm; + +my &index = &page.assuming( + title => 'Contact Us', + nav => nav( + widgets => [lightdark], + ), +); + +my $site = +site :register[$mail-form, LightDark.new], + index + main [ + h3 'Contact Us'; + $mail-form; + ] +; + +$site.serve; From 0766d2730e31020346ecd6ef5f272604beaa2655 Mon Sep 17 00:00:00 2001 From: librasteve Date: Wed, 24 Jun 2026 14:40:53 +0100 Subject: [PATCH 2/5] use ContactForm in example --- bin/29-mailform.raku | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) mode change 100644 => 100755 bin/29-mailform.raku diff --git a/bin/29-mailform.raku b/bin/29-mailform.raku old mode 100644 new mode 100755 index 37a4600..5b43b54 --- a/bin/29-mailform.raku +++ b/bin/29-mailform.raku @@ -4,6 +4,8 @@ use Air::Functional :BASE; use Air::Base; use Air::Plugin::MailForm; +my $contact = Air::Plugin::ContactForm.empty; + my &index = &page.assuming( title => 'Contact Us', nav => nav( @@ -12,11 +14,11 @@ my &index = &page.assuming( ); my $site = -site :register[$mail-form, LightDark.new], +site :register[$contact, LightDark.new], index main [ h3 'Contact Us'; - $mail-form; + $contact; ] ; From 1cb8cc9233ab1ede8dbd0efa10ac6cb2ad9d6f12 Mon Sep 17 00:00:00 2001 From: librasteve Date: Wed, 24 Jun 2026 14:41:44 +0100 Subject: [PATCH 3/5] add 30-signup --- Changes | 1 + bin/30-signup.raku | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 bin/30-signup.raku diff --git a/Changes b/Changes index dd65d27..2c9bb99 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ Revision history for Air::Examples {{$NEXT}} - add 29-mailform + - add 30-signup 0.0.25 2026-06-23T17:23:18+01:00 - add Fold to baseexamples diff --git a/bin/30-signup.raku b/bin/30-signup.raku new file mode 100644 index 0000000..179b8db --- /dev/null +++ b/bin/30-signup.raku @@ -0,0 +1,47 @@ +#!/usr/bin/env raku + +use Air::Functional :BASE; +use Air::Base; +use Air::Form; +use Air::Plugin::MailForm; + +class SignupForm is Air::Plugin::MailForm { + has Str $.name is validated(%va) is required; + has Str $.nick; + has Str $.email is validated(%va) is email is required; + + method do-form-attrs { + self.form-attrs: {:submit-button-text('Register Interest')} + } + + method validate-form { + self.add-validation-error("Nick must be a single word") + if $!nick && $!nick.trim.contains(/ \s /); + } + + method mail-body { + "Name: { $.name }\n" ~ + "Nick: { $.nick || '(not provided)' }\n" ~ + "Email: { $.email }" + } +} + +my $signup = SignupForm.empty; + +my &index = &page.assuming( + title => 'Sign Up', + nav => nav( + widgets => [lightdark], + ), +); + +my $site = +site :register[$signup, LightDark.new], + index + main [ + h3 'Register Interest'; + $signup; + ] +; + +$site.serve; From 9ab66fc384f297e59753e5363698ee49c37cb1f4 Mon Sep 17 00:00:00 2001 From: librasteve Date: Wed, 24 Jun 2026 14:50:45 +0100 Subject: [PATCH 4/5] add form-routes to SignupForm --- bin/30-signup.raku | 7 +++++++ 1 file changed, 7 insertions(+) mode change 100644 => 100755 bin/30-signup.raku diff --git a/bin/30-signup.raku b/bin/30-signup.raku old mode 100644 new mode 100755 index 179b8db..34af6f0 --- a/bin/30-signup.raku +++ b/bin/30-signup.raku @@ -24,6 +24,13 @@ class SignupForm is Air::Plugin::MailForm { "Nick: { $.nick || '(not provided)' }\n" ~ "Email: { $.email }" } + + method form-routes { + self.init; + self.submit: -> SignupForm $form { + self.submit-form($form) + } + } } my $signup = SignupForm.empty; From 15a728e94cc78957122e22d0a510a1244ec8a0f4 Mon Sep 17 00:00:00 2001 From: librasteve Date: Wed, 24 Jun 2026 15:00:47 +0100 Subject: [PATCH 5/5] update SignupForm mail-message --- bin/30-signup.raku | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/30-signup.raku b/bin/30-signup.raku index 34af6f0..c9de1c4 100755 --- a/bin/30-signup.raku +++ b/bin/30-signup.raku @@ -19,10 +19,16 @@ class SignupForm is Air::Plugin::MailForm { if $!nick && $!nick.trim.contains(/ \s /); } - method mail-body { - "Name: { $.name }\n" ~ - "Nick: { $.nick || '(not provided)' }\n" ~ - "Email: { $.email }" + method mail-message(Str $from, Str $to, Str $subject --> Str) { + qq:to/END/; + From: $from + To: $to + Subject: $subject + + Name: { $.name } + Nick: { $.nick || '(not provided)' } + Email: { $.email } + END } method form-routes {