Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 46 lines (35 sloc) 1.1 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#!/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;
}
Something went wrong with that request. Please try again.