4 use lib $FindBin::RealBin.'/code';
5 use Web::Simple 'SDL_Perl::WebSite';
7 sub SDL_Perl::WebSite::Page::html { ${+shift} }
9 package SDL_Perl::WebSite;
14 pages_dir => $FindBin::RealBin.'/pages',
18 my ($self, $page) = @_;
19 my $file = $self->config->{pages_dir}.'/'.$page.'.html-inc';
20 return () unless -e $file;
22 \do { local (@ARGV, $/) = $file; <> },
23 'SDL_Perl::WebSite::Page'
28 sub (GET + /) { redispatch_to '/index.html' },
30 redispatch_to do { my $x = join('/','',$_[1],'index.html'); warn $x; $x };
33 filter_response { $self->render_html($_[1]) }
40 { my $DATA; sub _read_data { $DATA ||= do { local $/; <DATA>; } } }
44 $self->{layout_zoom} ||= do {
45 HTML::Zoom->from_string($self->_read_data)
50 my ($self, $data) = @_;
51 return $data if ref($data) eq 'ARRAY';
53 if ($data->isa('SDL_Perl::WebSite::Page')) {
56 -replace_content_raw => $data->html
60 die "WTF is ${data} supposed to be? A mallard?";
62 } ($self->layout_zoom);
63 $self->zoom_to_response($zoom);
66 sub zoom_to_response {
67 my ($self, $zoom) = @_;
68 open my $fh, '>', \my $out_str;
69 $zoom->render_to($fh);
72 [ 'Content-type' => 'text/html' ],
78 SDL_Perl::WebSite->run_if_script;