ASP4
view release on metacpan or search on metacpan
sbin/asphelper view on Meta::CPAN
unless( -f "www/conf/httpd.conf" )
{
warn "www/conf/httpd.conf\n";
open my $ofh, '>', "www/conf/httpd.conf"
or die "Cannot open 'www/conf/httpd.conf' for writing: $!";
my $conf = generic_httpconf();
$conf =~ s/\%CWD\%/$cwd/igs;
$conf =~ s/\%domain\%/$domain/igs;
$conf =~ s/\%appName\%/$appName/igs;
$conf =~ s/\%dbName\%/$dbName/igs;
$conf =~ s/\%dbHost\%/$dbHost/igs;
$conf =~ s/\%dbUser\%/$dbUser/igs;
$conf =~ s/\%dbPass\%/$dbPass/igs;
$conf =~ s/\%email\%/$email/igs;
print $ofh $conf;
close($ofh);
}# end unless()
# Test page:
make_path("www/htdocs");
unless( -f "www/htdocs/index.asp" )
{
warn "www/htdocs/index.asp\n";
open my $ofh, '>', "www/htdocs/index.asp"
or die "Cannot open 'www/htdocs/index.asp' for writing: $!";
print $ofh <<'ASP';
<html>
<body>
<h1>ASP4 Test Page</h1>
<p>
The date and time is <%= scalar(localtime()) %>.
</p>
<p>
You have visited this page <%= $Session->{count}++ %> time(s) recently.
</p>
</body>
</html>
ASP
close($ofh);
}# end unless()
(my $hPath = lc($appName)) =~ s/::/\//g;
my $hClass = lc($appName);
make_path("www/handlers/$hPath/www");
unless( -f "www/handlers/$hClass/www/echo.pm" )
{
open my $ofh, '>', "www/handlers/$hPath/www/echo.pm"
or die "Cannot open 'www/handlers/$hPath/www/echo.pm' for writing: $!";
print $ofh <<"CODE";
package $hClass\::www::echo;
use strict;
use warnings 'all';
use base 'ASP4::FormHandler';
use vars __PACKAGE__->VARS;
use Data::Dumper;
sub run
{
my (\$s, \$context) = \@_;
\$Response->Write("<h1>Form Contents:</h1><pre>" . Dumper(\$Form) . "</pre>");
}# end run()
1;# return true:
CODE
close($ofh);
}# end unless()
# Only write the base Model class if we have Class::DBI::Lite
my $CDBIL_Version = 0;
eval {
require Class::DBI::Lite;
$CDBIL_Version = $Class::DBI::Lite::VERSION = $Class::DBI::Lite::VERSION;
};
if( $dbName && $Class::DBI::Lite::VERSION )
{
unless( -f "common/lib/$appFolder/db/model.pm" )
{
warn "common/lib/$appFolder/db/model.pm\n";
open my $ofh, '>', "common/lib/$appFolder/db/model.pm"
or die "Cannot open 'common/lib/$appFolder/db/model.pm' for writing: $!";
print $ofh <<"CODE";
@{[ 'package' ]} @{['']} $appFolder\::db::model;
use strict;
use warnings 'all';
use base 'Class::DBI::Lite::mysql';
use ASP4::ConfigLoader;
my \$Config = ASP4::ConfigLoader->load();
my \$conn = \$Config->data_connections->main;
__PACKAGE__->connection(
\$conn->dsn,
\$conn->username,
\$conn->password
);
1;# return true:
\=pod
\=head1 NAME
$appName\::db::model - Base class for all $appName entity classes.
\=head1 SYNOPSIS
# In your class:
package $appName\::db::thing;
use strict;
use warnings 'all';
( run in 1.001 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )