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',
15 layout_file => $FindBin::RealBin.'/../layout.html',
19 my ($self, $page) = @_;
20 my $file = $self->config->{pages_dir}.'/'.$page.'.html-inc';
21 return () unless -e $file;
23 \do { local (@ARGV, $/) = $file; <> },
24 'SDL_Perl::WebSite::Page'
29 sub (GET + /) { redispatch_to '/index.html' },
31 redispatch_to join('/','',$_[1],'index.html');
34 filter_response { $self->render_html($_[1]) }
41 { my $DATA; sub _read_data { $DATA ||= do { local $/; <DATA>; } } }
45 $self->{layout_zoom} ||= do {
46 HTML::Zoom->from_string($self->_layout_html)
52 my $file = $self->config->{layout_file};
54 return do { local(@ARGV, $/) = ($file); <> }
56 return $self->_read_data
61 my ($self, $data) = @_;
62 return $data if ref($data) eq 'ARRAY';
64 if ($data->isa('SDL_Perl::WebSite::Page')) {
67 -replace_content_raw => $data->html
71 die "WTF is ${data} supposed to be? A mallard?";
73 } ($self->layout_zoom);
74 $self->zoom_to_response($zoom);
77 sub zoom_to_response {
78 my ($self, $zoom) = @_;
79 open my $fh, '>', \my $out_str;
80 $zoom->render_to($fh);
83 [ 'Content-type' => 'text/html' ],
89 SDL_Perl::WebSite->run_if_script;