Apache2-ASP
view release on metacpan or search on metacpan
sbin/asphelper view on Meta::CPAN
several concepts in action.
</p>
</body>
</html>
ASP
close($asp_ofh);
open my $props_ofh, '>', "$args->{domain}/etc/properties.yaml";
print $props_ofh <<"YAML";
---
contact_form:
first_name:
is_missing: Required
last_name:
is_missing: Required
email:
is_missing: Required
is_invalid: Invalid
message:
is_missing: Required
YAML
close($props_ofh);
open my $data_ofh, '>', "$args->{domain}/etc/test_fixtures.yaml";
print $data_ofh <<"YAML";
---
contact_form:
first_name: John
last_name: Doe
email: john.doe\@test.com
message: This is a test message...just a test.
YAML
close($data_ofh);
mkdir "$args->{domain}/htdocs/examples" or die "CANNOT MKDIR examples: $!";
open my $contact_asp, '>', "$args->{domain}/htdocs/examples/contact.asp";
print $contact_asp <<"ASP";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
# Make a "sticky form":
if( my \$args = \$Session->{__lastArgs} )
{
\$Form->{\$_} = \$args->{\$_} foreach keys(\%\$args);
}# end if()
my \$errors = \$Session->{validation_errors} || { };
my \$err = sub {
my \$name = shift;
return unless \$errors->{\$name};
%><span class="field_error"><%= \$Server->HTMLEncode( \$errors->{\$name} ) %></span><%
};
%>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Apache2::ASP Example Contact Form</title>
<style type="text/css">
.field_error {
color: #FF0000;
font-weight: bold;
}
.label {
display: block;
float: left;
width: 150px;
text-align: right;
padding-right: 5px;
margin-right: 5px;
position: relative;
top: 2px;
}
.required {
border-right: solid 6px #FF0000;
}
.optional {
border-right: solid 6px transparent;
}
</style>
</head>
<body>
<form method="post" action="/handlers/examples.contact">
<div>
<span class="label required">First Name:</span>
<input type="text" name="first_name" value="<%= \$Server->HTMLEncode( \$Form->{first_name} ) %>" />
<% \$err->('first_name'); %>
</div>
<div>
<span class="label required">Last Name:</span>
<input type="text" name="last_name" value="<%= \$Server->HTMLEncode( \$Form->{last_name} ) %>" />
<% \$err->('last_name'); %>
</div>
<div>
<span class="label required">Email Address:</span>
<input type="text" name="email_address" value="<%= \$Server->HTMLEncode( \$Form->{email_address} ) %>" />
<% \$err->('email_address'); %>
</div>
<div>
<span class="label required">Your Message:</span>
<textarea rows="6" cols="40" name="message"><%= \$Server->HTMLEncode( \$Form->{message} ) %></textarea>
<% \$err->('email_address'); %>
</div>
<div>
<span class="label optional"> </span>
<input type="submit" value="Submit Form" />
</div>
</form>
</body>
</html>
<%
map { delete( \$Session->{\$_} ) } qw/
validation_errors
( run in 1.476 second using v1.01-cache-2.11-cpan-39bf76dae61 )