Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 46 lines (35 sloc) 1.1 kb
a2615ed @ranguard Multiple roots example (TT and Static)
authored
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5 use lib qw(lib);
6
7 use Path::Class;
f636db2 @ranguard Switch to P::MW::TemplateToolkit
authored
8 use Plack::Middleware::TemplateToolkit;
a2615ed @ranguard Multiple roots example (TT and Static)
authored
9 use Plack::Builder;
10 use Plack::Middleware::ErrorDocument;
11 use Plack::Middleware::Static;
12
c8ddc99 @ranguard Rename static directories as we want plack not ngix to handle on dotc…
authored
13 my $base = dir( 'base' )->stringify();
14 my $custom = dir( 'custom' )->stringify();
2636194 @ranguard Tweeks to can deplyo to dotcloud
authored
15
a2615ed @ranguard Multiple roots example (TT and Static)
authored
16 # Create our TT app, specifying the root and file extensions
f636db2 @ranguard Switch to P::MW::TemplateToolkit
authored
17 my $app = Plack::Middleware::TemplateToolkit->new(
a2615ed @ranguard Multiple roots example (TT and Static)
authored
18 root => [ ( $custom, $base ) ], # required
19 # extension => '.html', # optional
20 )->to_app;
21
22 # Plack::Middleware::Deflater might be good to use here
23
24 $app = Plack::Middleware::ErrorDocument->wrap( $app,
25 404 => "$base/page_not_found.html", );
26
27 # Binary files can be served directly
28 $app = Plack::Middleware::Static->wrap(
29 $app,
30 path => qr{[gif|png|jpg|swf|ico|mov|mp3|pdf|js|css]$},
31 root => $base
32 );
33
34 $app = Plack::Middleware::Static->wrap(
35 $app,
36 path => qr{[gif|png|jpg|swf|ico|mov|mp3|pdf|js|css]$},
37 root => $custom,
38 pass_through => 1, # So the 'base' static can pick it up
39 );
40
41
42 return builder {
f636db2 @ranguard Switch to P::MW::TemplateToolkit
authored
43 enable "Debug";
a2615ed @ranguard Multiple roots example (TT and Static)
authored
44 $app;
45 }
Something went wrong with that request. Please try again.