package My::PageBase;

use strict;
use Apache::Constants qw(:common);

sub new {
    my $class = shift;
    bless {@_}, $class;
}

sub handler ($$) {
    my($self, $r) = @_;
    unless (ref($self)) {
	$self = $self->new;
    }
    for my $meth (qw(header top body bottom)) {
	$self->$meth($r);
    }
    return OK;
}

sub header {
    my($self, $r) = @_;
    $r->content_type($self->{type} || "text/html");
    $r->send_http_header;
}

sub top {
    my($self, $r) = @_;
    my $title = $self->{title} || "untitled document";
    $r->print(<<EOF);
<html>
<head>
<title>$title</title>
</head>
<body>
<h1>$title</h1>
<hr>
EOF
}

sub bottom {
    my($self, $r) = @_;
    my $admin = $r->server->server_admin;
    $r->print(<<EOF);
<hr>
<i><a href="mailto:$admin">$admin</a></i>
</body>
</html>
EOF
}

sub body {
    my($self, $r) = @_;
    $r->print("<p>This is the document Body<p>");
}

1;
__END__
