Apache2-ASP

 view release on metacpan or  search on metacpan

sbin/asphelper  view on Meta::CPAN

    SetHandler  perl-script
    PerlResponseHandler Apache2::ASP::ModPerl
  </Files>
  
  # !IMPORTANT! Prevent anyone from viewing your GlobalASA.pm
  <Files ~ (\.pm\$)>
    Order allow,deny
    Deny from all
  </Files>
  
  # All requests to /handlers/* will be handled by their respective handler:
  <Location /handlers>
    SetHandler  perl-script
    PerlResponseHandler Apache2::ASP::ModPerl
  </Location>
  
</VirtualHost>

CONF
close($conf_ofh);

open my $asa_ofh, '>', "$args->{domain}/htdocs/GlobalASA.pm";
print $asa_ofh <<"ASA";

package @{[ $args->{application_name} ]}::GlobalASA;

use strict;
use warnings 'all';
use base 'Apache2::ASP::GlobalASA';
use vars __PACKAGE__->VARS;

# sub Server_OnStart;
# sub Application_OnStart;
# sub Session_OnStart;
# sub Script_OnStart;
# sub Script_OnEnd;

1;# return true:

ASA
close($asa_ofh);

warn "\nSetup is almost complete.
Make sure to add the following lines to your main httpd.conf:

  # Unless you've already done this:
  NameVirtualHost *:80
  
  # And this (unless you already have):
  AddModule perl_module modules/mod_perl.so
  
  # And *Don't* forget about this line:
  Include @{[ cwd() ]}/@{[ $args->{domain} ]}/conf/httpd.conf
";

open my $asp_ofh, '>', "$args->{domain}/htdocs/index.asp";
print $asp_ofh <<'ASP';
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 Test Page</title>
</head>
<body>
<h1>Congratulations</h1>
<p>You have successfully installed Apache2::ASP.</p>
<p>
  Visit your <a href="/examples/contact.asp">example contact form</a> to see 
  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">&nbsp;</span>
  <input type="submit" value="Submit Form" />
</div>

</form>



( run in 3.172 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )