94 |
sub popup { my $self = shift; $self->popup_dropdown('popup', @_); } |
sub popup { my $self = shift; $self->popup_dropdown('popup', @_); } |
95 |
sub dropdown { my $self = shift; $self->popup_dropdown('dropdown', @_); } |
sub dropdown { my $self = shift; $self->popup_dropdown('dropdown', @_); } |
96 |
|
|
97 |
our $re_html = qr{<(?:!--.+?--|(\w+).+?/\1|[^>]+/?)>}s; # relaxed html check for one semi-valid tag |
our $re_html = qr{<(?:!--|(\w+)|[^>]+)/?>}s; # relaxed html check for one semi-valid tag |
98 |
|
|
99 |
sub popup_dropdown { |
sub popup_dropdown { |
100 |
my ( $self, $type, $name, $content, $full ) = @_; |
my ( $self, $type, $name, $content, $full ) = @_; |
116 |
} |
} |
117 |
} |
} |
118 |
|
|
119 |
sub _inline_path { |
sub _inline { |
120 |
my ( $self, $path ) = @_; |
my ( $self, $path ) = @_; |
121 |
-s $path < $self->inline_smaller_than; |
return unless defined $path; |
122 |
|
warn "# _inline $path"; |
123 |
|
-e $path && -s $path < $self->inline_smaller_than && -s $path; |
124 |
} |
} |
125 |
|
|
126 |
sub _head_html { |
sub _head_html { |
129 |
foreach my $path ( @head ) { |
foreach my $path ( @head ) { |
130 |
$path =~ s!^/!!; |
$path =~ s!^/!!; |
131 |
if ( $path =~ m/\.js$/ ) { |
if ( $path =~ m/\.js$/ ) { |
132 |
$out .= $self->_inline_path( $path ) ? |
my $size; |
133 |
qq|<script type="text/javascript">\n/* inline $path */\n\n| . read_file($path) . qq|\n</script>| : |
$out .= $size = _inline( $path ) ? |
134 |
|
qq|<script type="text/javascript">\n/* inline $path $size bytes */\n\n| . read_file($path) . qq|\n</script>| : |
135 |
qq|<script type="text/javascript" src="/$path"></script>|; |
qq|<script type="text/javascript" src="/$path"></script>|; |
136 |
} elsif ( $path =~ m/\.css$/ ) { |
} elsif ( $path =~ m/\.css$/ ) { |
137 |
$out .= $self->_inline_path( $path ) ? |
my $size; |
138 |
qq|<style type="text/css">\n/* inline $path */\n\n| . read_file( $path ) . qq|\n</style>| : |
$out .= $size = _inline( $path ) ? |
139 |
|
qq|<style type="text/css">\n/* inline $path $size bytes */\n\n| . read_file( $path ) . qq|\n</style>| : |
140 |
qq|<link type="text/css" rel="stylesheet" href="/$path" media="screen">|; |
qq|<link type="text/css" rel="stylesheet" href="/$path" media="screen">|; |
141 |
} elsif ( $path =~ m{<.+>}s ) { |
} elsif ( $path =~ m{<.+>}s ) { |
142 |
$out .= $path; |
$out .= $path; |
187 |
|
|
188 |
my ( $package, $path, $line ) = caller(1); |
my ( $package, $path, $line ) = caller(1); |
189 |
|
|
190 |
if ( $content =~ m{\.(js|css)} ) { |
$content = "/$content" if -e $content; |
191 |
$content = "/$content" if -e $content; |
if ( $content =~ $re_html ) { |
192 |
|
$head = qq| |
193 |
|
$content |
194 |
|
<!-- $type via $package at $path line $line --> |
195 |
|
|; |
196 |
|
} elsif ( $content =~ m{^(/|https?://)} ) { |
197 |
if ( $what eq 'js' ) { |
if ( $what eq 'js' ) { |
198 |
$head = qq| |
$head = qq| |
199 |
<$tag type="$type" src="$content"> |
<$tag type="$type" src="$content"> |
200 |
/* via $package at $path line $line */ |
/* $what via $package at $path line $line */ |
201 |
</$tag> |
</$tag> |
202 |
|; |
|; |
203 |
} else { |
} else { |
204 |
$head = qq| |
$head = qq| |
205 |
<link rel="stylesheet" type="$type" href="$content"> |
<link rel="stylesheet" type="$type" href="$content"> |
206 |
<!-- via $package at $path line $line --> |
<!-- $what via $package at $path line $line --> |
207 |
|; |
|; |
208 |
} |
} |
209 |
} else { |
} else { |
249 |
my $self = shift; |
my $self = shift; |
250 |
my $a = {@_}; |
my $a = {@_}; |
251 |
|
|
|
warn "## page ",dump($a); |
|
|
|
|
252 |
$reload_counter++; |
$reload_counter++; |
253 |
|
|
254 |
my $status_line = ''; |
my $status_line = ''; |