Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
46 lines (35 sloc) 1.1 kb
#!/usr/bin/env perl
use strict;
use warnings;
use lib qw(lib);
use Path::Class;
use Plack::Middleware::TemplateToolkit;
use Plack::Builder;
use Plack::Middleware::ErrorDocument;
use Plack::Middleware::Static;
my $base = dir( 'base' )->stringify();
my $custom = dir( 'custom' )->stringify();
# Create our TT app, specifying the root and file extensions
my $app = Plack::Middleware::TemplateToolkit->new(
root => [ ( $custom, $base ) ], # required
# extension => '.html', # optional
)->to_app;
# Plack::Middleware::Deflater might be good to use here
$app = Plack::Middleware::ErrorDocument->wrap( $app,
404 => "$base/page_not_found.html", );
# Binary files can be served directly
$app = Plack::Middleware::Static->wrap(
$app,
path => qr{[gif|png|jpg|swf|ico|mov|mp3|pdf|js|css]$},
root => $base
);
$app = Plack::Middleware::Static->wrap(
$app,
path => qr{[gif|png|jpg|swf|ico|mov|mp3|pdf|js|css]$},
root => $custom,
pass_through => 1, # So the 'base' static can pick it up
);
return builder {
enable "Debug";
$app;
}
Jump to Line
Something went wrong with that request. Please try again.