3 |
|
|
4 |
with 'Frey::Session'; |
with 'Frey::Session'; |
5 |
|
|
|
#use Continuity::Widget::DomNode; |
|
6 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
7 |
use Carp qw/confess cluck carp/; |
use Carp qw/confess cluck carp/; |
8 |
use File::Slurp; |
use File::Slurp; |
70 |
default => 250, |
default => 250, |
71 |
); |
); |
72 |
|
|
73 |
|
has 'wrap_in_page' => ( |
74 |
|
documentation => 'wrap full html page with status bar around content', |
75 |
|
is => 'rw', |
76 |
|
isa => 'Bool', |
77 |
|
default => 1, |
78 |
|
); |
79 |
|
|
80 |
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); |
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); |
81 |
my $escape_re = join '|' => keys %escape; |
my $escape_re = join '|' => keys %escape; |
82 |
|
|
83 |
sub html_escape { |
sub html_escape { |
84 |
my ( $self, $html ) = @_; |
my ( $self, $html ) = @_; |
85 |
|
return '' unless defined $html; |
86 |
$html =~ s/($escape_re)/$escape{$1}/g; |
$html =~ s/($escape_re)/$escape{$1}/g; |
87 |
return $html; |
return $html; |
88 |
} |
} |
245 |
our $reload_counter = 0; |
our $reload_counter = 0; |
246 |
|
|
247 |
|
|
248 |
=head2 page |
=head2 html_page |
249 |
|
|
250 |
$self->page( |
$self->html_page( |
251 |
title => 'page title', |
title => 'page title', |
252 |
head => '<!-- optional head markup -->', |
head => '<!-- optional head markup -->', |
253 |
body => '<b>Page Body</b>', |
body => '<b>Page Body</b>', |
260 |
|
|
261 |
our $icon_html; |
our $icon_html; |
262 |
|
|
263 |
sub page { |
sub html_page { |
264 |
my $self = shift; |
my $self = shift; |
265 |
my $a = {@_}; |
my $a = {@_}; |
266 |
|
|
283 |
warn "# no body, invoke $self->$run on ", ref($self); |
warn "# no body, invoke $self->$run on ", ref($self); |
284 |
$body = $self->$run; |
$body = $self->$run; |
285 |
} |
} |
286 |
if ( $self->content_type !~ m{html} ) { |
if ( $self->content_type !~ m{html} || ! $self->wrap_in_page ) { |
287 |
warn "# return only $self body ", $self->content_type; |
warn "# return only $self body ", $self->content_type; |
288 |
return $body |
return $body |
289 |
} elsif ( ! defined $body ) { |
} elsif ( ! defined $body ) { |
320 |
|
|
321 |
# $title =~ s{(\w)\w+::}{$1:}g; # XXX compress names of classes |
# $title =~ s{(\w)\w+::}{$1:}g; # XXX compress names of classes |
322 |
|
|
323 |
|
$self->add_css(qq| |
324 |
|
body { |
325 |
|
padding-bottom: 3em; /* don't overlap status line */ |
326 |
|
} |
327 |
|
|); |
328 |
|
|
329 |
my $html = join("\n", |
my $html = join("\n", |
330 |
qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|, |
qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|, |
331 |
$self->_head_html, |
$self->_head_html, |