24 |
isa => 'ArrayRef[HashRef[Str]]', |
isa => 'ArrayRef[HashRef[Str]]', |
25 |
lazy => 1, |
lazy => 1, |
26 |
default => sub { [ |
default => sub { [ |
|
{ 'Bookmarklets' => Frey::Bookmarklet->new->as_markup }, |
|
27 |
{ 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup }, |
{ 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup }, |
28 |
|
{ 'Bookmarklets' => Frey::Bookmarklet->new->as_markup }, |
29 |
] }, |
] }, |
30 |
); |
); |
31 |
|
|
49 |
is => 'rw', |
is => 'rw', |
50 |
isa => 'Str', |
isa => 'Str', |
51 |
default => 'text/html', |
default => 'text/html', |
52 |
|
documentation => 'Content-type header', |
53 |
|
); |
54 |
|
|
55 |
|
has 'dump_max_bytes' => ( |
56 |
|
is => 'rw', |
57 |
|
isa => 'Int', |
58 |
|
default => 4096, |
59 |
|
documentation => 'Maximum dump size sent to browser before truncation', |
60 |
); |
); |
61 |
|
|
62 |
=head2 inline_smaller_than |
=head2 inline_smaller_than |
166 |
if ( ref($content) ) { |
if ( ref($content) ) { |
167 |
$content = '<code>' . dump($content) . '</code>'; |
$content = '<code>' . dump($content) . '</code>'; |
168 |
my $l = length($content); |
my $l = length($content); |
169 |
$content = qq|<span>$l bytes</span>| if $l > 1024; |
$content = qq|<span>$l bytes</span>| if $l > $self->dump_max_bytes; |
170 |
} else { |
} else { |
171 |
$content = qq|<span>$content</span>|; |
$content = qq|<span>$content</span>|; |
172 |
} |
} |
188 |
$body = '<!-- no body -->'; |
$body = '<!-- no body -->'; |
189 |
} |
} |
190 |
|
|
191 |
|
my $warn_colors = { |
192 |
|
'#' => '#444', |
193 |
|
'##' => '#888', |
194 |
|
}; |
195 |
|
|
196 |
$status_line |
$status_line |
197 |
.= qq|<span class="frey-popup">warn<code>| |
.= qq|<span class="frey-popup">warn<span>| |
198 |
. $self->editor_links( join("", $self->warnings ) ) |
. $self->editor_links( |
199 |
. qq|</code></span>| |
join("", map { |
200 |
|
warn "# $_"; |
201 |
|
my $style = ''; |
202 |
|
$style = $warn_colors->{$1} |
203 |
|
? ' style="color:' . $warn_colors->{$1} . '"' |
204 |
|
: '' |
205 |
|
if m{^(#+)}; |
206 |
|
qq|<tt$style>$_</tt><br/>|; # XXX <tt> should be <code> but CSS hates me |
207 |
|
} $self->warnings ) |
208 |
|
) |
209 |
|
. qq|</span></span>| |
210 |
if $self->warnings; |
if $self->warnings; |
211 |
|
|
212 |
|
my ($exit,$description) = ('exit','stop server'); |
213 |
|
($exit,$description) = ('restart','restart server') |
214 |
|
if $ENV{FREY_RESTART}; # tune labels on exit link |
215 |
|
|
216 |
|
my $right = |
217 |
|
qq| |
218 |
|
<span class="right"> |
219 |
|
<a title="reload" href="/reload$url"><code>$url</code></a> |
220 |
|
<a title="$description" href="/exit$url">$exit</a> |
221 |
|
</span> |
222 |
|
|; |
223 |
|
|
224 |
my $html = join("\n", |
my $html = join("\n", |
225 |
qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|, |
qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|, |
226 |
$self->_head_html, |
$self->_head_html, |
232 |
$body |
$body |
233 |
<div class="frey-status-line"> |
<div class="frey-status-line"> |
234 |
<a href="/">Frey</a> $Frey::VERSION |
<a href="/">Frey</a> $Frey::VERSION |
|
<a href="?reload=$reload_counter"><code>$url</code></a> |
|
235 |
$status_line |
$status_line |
236 |
|
$right |
237 |
</div> |
</div> |
238 |
</body></html> |
</body></html> |
239 |
|, |
|, |
244 |
return $html; |
return $html; |
245 |
} |
} |
246 |
|
|
247 |
|
=head2 editor |
248 |
|
|
249 |
|
Create HTML editor link with optional line and title |
250 |
|
|
251 |
|
my $html = $self->editor( $class, $line, $title ); |
252 |
|
|
253 |
|
=cut |
254 |
|
|
255 |
|
sub editor { |
256 |
|
my ( $self, $class, $line, $title ) = @_; |
257 |
|
confess "need class" unless $class; |
258 |
|
$line ||= 1; |
259 |
|
qq|<a target="editor" href="/editor+$class+$line"| . |
260 |
|
( $title ? qq| title="$title"| : '' ) . |
261 |
|
qq|>$class</a>|; |
262 |
|
} |
263 |
|
|
264 |
|
=head2 editor_links |
265 |
|
|
266 |
|
Create HTML links to editor for perl error message |
267 |
|
|
268 |
|
my $html = $self->editor_links( $error ) |
269 |
|
|
270 |
|
=cut |
271 |
|
|
272 |
sub editor_links { |
sub editor_links { |
273 |
my ( $self, $error ) = @_; |
my ( $self, $error ) = @_; |
274 |
|
|