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->_layout_html)
51 my $file = $self->config->{pages_dir}.'/index.html';
53 return do { local(@ARGV, $/) = ($file); <> }
55 return $self->_read_data
60 my ($self, $data) = @_;
61 return $data if ref($data) eq 'ARRAY';
63 if ($data->isa('SDL_Perl::WebSite::Page')) {
66 -replace_content_raw => $data->html
70 die "WTF is ${data} supposed to be? A mallard?";
72 } ($self->layout_zoom);
73 $self->zoom_to_response($zoom);
76 sub zoom_to_response {
77 my ($self, $zoom) = @_;
78 open my $fh, '>', \my $out_str;
79 $zoom->render_to($fh);
82 [ 'Content-type' => 'text/html' ],
88 SDL_Perl::WebSite->run_if_script;