71 |
default => 250, |
default => 250, |
72 |
); |
); |
73 |
|
|
74 |
|
has 'wrap_in_page' => ( |
75 |
|
documentation => 'wrap full html page with status bar around content', |
76 |
|
is => 'rw', |
77 |
|
isa => 'Bool', |
78 |
|
default => 1, |
79 |
|
); |
80 |
|
|
81 |
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); |
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); |
82 |
my $escape_re = join '|' => keys %escape; |
my $escape_re = join '|' => keys %escape; |
83 |
|
|
84 |
sub html_escape { |
sub html_escape { |
85 |
my ( $self, $html ) = @_; |
my ( $self, $html ) = @_; |
86 |
|
return '' unless defined $html; |
87 |
$html =~ s/($escape_re)/$escape{$1}/g; |
$html =~ s/($escape_re)/$escape{$1}/g; |
88 |
return $html; |
return $html; |
89 |
} |
} |
209 |
$content |
$content |
210 |
<!-- $type via $package at $path line $line --> |
<!-- $type via $package at $path line $line --> |
211 |
|; |
|; |
212 |
} elsif ( $content =~ m{^(/|https?://)} ) { |
} elsif ( $content =~ m{^(/\w+|https?://)} && $content !~ m{[\n\r]} ) { |
213 |
if ( $what eq 'js' ) { |
if ( $what eq 'js' ) { |
214 |
$head = qq| |
$head = qq| |
215 |
<$tag type="$type" src="$content"> |
<$tag type="$type" src="$content"> |
246 |
our $reload_counter = 0; |
our $reload_counter = 0; |
247 |
|
|
248 |
|
|
249 |
=head2 page |
=head2 html_page |
250 |
|
|
251 |
$self->page( |
$self->html_page( |
252 |
title => 'page title', |
title => 'page title', |
253 |
head => '<!-- optional head markup -->', |
head => '<!-- optional head markup -->', |
254 |
body => '<b>Page Body</b>', |
body => '<b>Page Body</b>', |
261 |
|
|
262 |
our $icon_html; |
our $icon_html; |
263 |
|
|
264 |
sub page { |
sub html_page { |
265 |
my $self = shift; |
my $self = shift; |
266 |
my $a = {@_}; |
my $a = {@_}; |
267 |
|
|
284 |
warn "# no body, invoke $self->$run on ", ref($self); |
warn "# no body, invoke $self->$run on ", ref($self); |
285 |
$body = $self->$run; |
$body = $self->$run; |
286 |
} |
} |
287 |
if ( $self->content_type !~ m{html} ) { |
if ( $self->content_type !~ m{html} || ! $self->wrap_in_page ) { |
288 |
warn "# return only $self body ", $self->content_type; |
warn "# return only $self body ", $self->content_type; |
289 |
return $body |
return $body |
290 |
} elsif ( ! defined $body ) { |
} elsif ( ! defined $body ) { |