Permalink
Browse files

Start using Template toolkit to show the empty pages

  • Loading branch information...
szabgab committed Oct 20, 2014
1 parent 94db292 commit 0ce8f29b47e3f6fbebecbe904fd148bed7898904
Showing with 36 additions and 1 deletion.
  1. +3 −0 Makefile.PL
  2. +25 −1 lib/MetaCPAN/SCO.pm
  3. +2 −0 tt/incl/footer.tt
  4. +5 −0 tt/incl/header.tt
  5. +1 −0 tt/index.tt
View
@@ -7,7 +7,10 @@ my %conf = (
AUTHOR => 'Gabor Szabo <szabgab@cpan.org>',
VERSION_FROM => 'lib/MetaCPAN/SCO.pm',
PREREQ_PM => {
'Cwd' => '0',
'File::Basename' => '0',
'Plack::Request' => '0',
'Template' => '0',
},
);
View
@@ -2,7 +2,10 @@ package MetaCPAN::SCO;
use strict;
use warnings;
use Cwd qw(abs_path);
use File::Basename qw(dirname);
use Plack::Request;
use Template;
our $VERSION = '0.01';
@@ -18,13 +21,34 @@ sub run {
my $request = Plack::Request->new($env);
if ($request->path_info eq '/') {
return [ '200', [ 'Content-Type' => 'text/plain' ], ['Hello'], ];
return template('index');
}
return [ '404', [ 'Content-Type' => 'text/html' ], ['404 Not Found'], ];
};
}
sub template {
my ( $file ) = @_;
my $root = dirname(dirname(dirname( abs_path(__FILE__) )));
my $tt = Template->new(
INCLUDE_PATH => "$root/tt",
INTERPOLATE => 0,
POST_CHOMP => 1,
EVAL_PERL => 1,
START_TAG => '<%',
END_TAG => '%>',
PRE_PROCESS => 'incl/header.tt',
POST_PROCESS => 'incl/footer.tt',
);
my $out;
$tt->process( "$file.tt", {}, \$out )
|| die $tt->error();
return [ '200', [ 'Content-Type' => 'text/html' ], [$out], ];
}
1;
View
@@ -0,0 +1,2 @@
</body>
</html>
View
@@ -0,0 +1,5 @@
<html>
<head>
<title>The CPAN Search Site - search.cpan.org</title>
</head>
<body>
View
@@ -0,0 +1 @@
MetaCPAN::SCO

0 comments on commit 0ce8f29

Please sign in to comment.