ClearPress
view release on metacpan or search on metacpan
lib/ClearPress/decorator.pm view on Meta::CPAN
sub header {
my ($self) = @_;
return $self->site_header();
}
sub cookie {
my ($self, @cookies) = @_;
if(scalar @cookies) {
$self->{cookie} = \@cookies;
}
return @{$self->{cookie}||[]};
}
sub site_header {
my ($self) = @_;
my $cgi = $self->cgi();
my $ss = <<"EOT";
@{[map {
qq( <link rel="stylesheet" type="text/css" href="$_" />);
} grep { $_ } @{$self->stylesheet()}]}
EOT
if($self->style()) {
$ss .= q(<style type="text/css">). $self->style() .q(</style>);
}
my $rss = <<"EOT";
@{[map {
qq( <link rel="alternate" type="application/rss+xml" title="RSS" href="$_" />\n);
} grep { $_ } @{$self->rss()}]}
EOT
my $atom = <<"EOT";
@{[map {
qq( <link rel="alternate" type="application/atom+xml" title="ATOM" href="$_" />\n);
} grep { $_ } @{$self->atom()}]}
EOT
my $js = <<"EOT";
@{[map {
qq( <script type="text/javascript" src="@{[$cgi->escapeHTML($_)]}"></script>\n);
} grep { $_ } @{$self->jsfile()}]}
EOT
my $script = <<"EOT";
@{[map {
qq( <script type="text/javascript">$_</script>\n);
} grep { $_ } @{$self->script()}]}
EOT
my $onload = (scalar $self->onload()) ? qq( onload="@{[ join q(;), $self->onload()]}") : q[];
my $onunload = (scalar $self->onunload()) ? qq( onunload="@{[join q(;), $self->onunload()]}") : q[];
my $onresize = (scalar $self->onresize()) ? qq( onresize="@{[join q(;), $self->onresize()]}") : q[];
return <<"EOT";
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="@{[join q[,], @{$self->lang}]}" lang="@{[join q[,], @{$self->lang}]}">
<head>
<meta http-equiv="Content-Type" content="@{[$self->meta_content_type() || $self->defaults('meta_content_type')]}" />
@{[(scalar $self->meta_cookie())?(map { qq( <meta http-equiv="Set-Cookie" content="$_" />\n) } $self->meta_cookie()):q[]]}@{[$self->meta_refresh()?qq(<meta http-equiv="Refresh" content="@{[$self->meta_refresh()]}" />):q[]]}@{[$self->meta_expires()?qq...
<meta name="version" content="@{[$self->meta_version() || $self->defaults('meta_version')]}" />
<meta name="description" content="@{[$self->meta_description() || $self->defaults('meta_description')]}" />
<meta name="keywords" content="@{[$self->meta_keywords() || $self->defaults('meta_keywords')]}" />
<title>@{[$self->title || 'ClearPress Application']}</title>
$ss$rss$atom$js$script </head>
<body$onload$onunload$onresize>
EOT
}
sub footer {
return <<'EOT';
</body>
</html>
EOT
}
sub cgi {
my ($self, $cgi) = @_;
if($cgi) {
$self->{cgi} = $cgi;
} elsif(!$self->{cgi}) {
$self->{cgi} = CGI->new();
}
return $self->{cgi};
}
sub session {
return {};
}
sub save_session {
return;
}
1;
__END__
=head1 NAME
ClearPress::decorator - HTML site-wide header & footer handling
=head1 VERSION
$LastChangeRevision$
=head1 SYNOPSIS
=head1 DESCRIPTION
=head1 SUBROUTINES/METHODS
=head2 new
( run in 1.399 second using v1.01-cache-2.11-cpan-39bf76dae61 )