16 |
|
|
17 |
use Frey::SVK; |
use Frey::SVK; |
18 |
|
|
19 |
has 'head' => ( |
our @head; |
|
is => 'rw', |
|
|
isa => 'ArrayRef[Str]', |
|
|
default => sub { [ 'static/frey.css' ] }, |
|
|
); |
|
20 |
|
|
21 |
has 'request_url' => ( |
has 'request_url' => ( |
22 |
is => 'rw', |
is => 'rw', |
79 |
$dump =~ s{(\n[^\n]{$width})([^\n]+?)([^\n]{5})}{\n$1...$3}gs; |
$dump =~ s{(\n[^\n]{$width})([^\n]+?)([^\n]{5})}{\n$1...$3}gs; |
80 |
$dump = $self->html_escape( $dump ); |
$dump = $self->html_escape( $dump ); |
81 |
$dump =~ s{\Q...\E}{…}gs; |
$dump =~ s{\Q...\E}{…}gs; |
82 |
|
# $dump =~ $self->editor_links( $dump ); # FIXME include this |
83 |
return "<code>$dump</code>"; |
return "<code>$dump</code>"; |
84 |
} |
} |
85 |
|
|
95 |
|
|
96 |
$content = qq|<span>$content</span>| unless $content =~ m{^\s*<(span|a|code).+?/\1>\s*}; |
$content = qq|<span>$content</span>| unless $content =~ m{^\s*<(span|a|code).+?/\1>\s*}; |
97 |
|
|
98 |
|
$content =~ s{<span>(<code>[^<]+</code>)</span>}{$1} && $self->TODO("code wrapped in span"); |
99 |
|
|
100 |
warn "## $type [$name] = ", length( $content ), " bytes" if $self->debug; |
warn "## $type [$name] = ", length( $content ), " bytes" if $self->debug; |
101 |
|
|
102 |
if ( $name =~ m{::} && $name !~ $re_html ) { |
if ( $name =~ m{::} && $name !~ $re_html ) { |
114 |
sub _head_html { |
sub _head_html { |
115 |
my $self = shift; |
my $self = shift; |
116 |
my $out = ''; |
my $out = ''; |
117 |
foreach my $path ( @{ $self->head } ) { |
foreach my $path ( @head ) { |
118 |
$path =~ s!^/!!; |
$path =~ s!^/!!; |
119 |
if ( $path =~ m/\.js$/ ) { |
if ( $path =~ m/\.js$/ ) { |
120 |
$out .= $self->_inline_path( $path ) ? |
$out .= $self->_inline_path( $path ) ? |
150 |
$path =~ s!^/!!; |
$path =~ s!^/!!; |
151 |
|
|
152 |
if ( $path =~ $re_html ) { |
if ( $path =~ $re_html ) { |
153 |
push @{ $self->head }, $path; |
push @head, $path; |
154 |
} elsif ( -e $path ) { |
} elsif ( -e $path ) { |
155 |
if ( $path =~ m/\.(?:js|css)$/ ) { |
if ( $path =~ m/\.(?:js|css)$/ ) { |
156 |
push @{ $self->head }, $path; |
push @head, $path; |
157 |
} else { |
} else { |
158 |
confess "can't add_head( $path ) it's not js or css"; |
confess "can't add_head( $path ) it's not js or css"; |
159 |
} |
} |
164 |
|
|
165 |
} |
} |
166 |
|
|
167 |
|
sub add_css { |
168 |
|
my ($self,$css) = @_; |
169 |
|
my ( $package, $path, $line ) = caller; |
170 |
|
$self->add_head( qq| |
171 |
|
<style type="text/css"> |
172 |
|
/* via $package at $path line $line */ |
173 |
|
$css |
174 |
|
</style> |
175 |
|
| ); |
176 |
|
} |
177 |
|
|
178 |
our $reload_counter = 0; |
our $reload_counter = 0; |
179 |
|
|
180 |
|
|
203 |
|
|
204 |
my $status_line = ''; |
my $status_line = ''; |
205 |
|
|
|
unshift @status, { 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup }; |
|
|
# unshift @status, { 'Bookmarklets' => Frey::Bookmarklet->new->as_markup }; |
|
|
unshift @status, { 'INC' => Frey::INC->new->as_markup }; |
|
|
|
|
206 |
foreach my $part ( @status ) { |
foreach my $part ( @status ) { |
207 |
foreach my $name ( keys %$part ) { |
foreach my $name ( keys %$part ) { |
208 |
$status_line .= $self->popup( $name, $part->{$name} ); |
$status_line .= $self->popup( $name, $part->{$name} ); |
236 |
</span> |
</span> |
237 |
|; |
|; |
238 |
|
|
239 |
my $info = Frey::SVK->info; |
my $svk = Frey::SVK->new; |
240 |
my $revision = Frey::SVK->info->{Revision} || ''; |
my $info = $svk->info; |
241 |
|
my $revision = $svk->info->{Revision} || ''; |
242 |
$revision = $1 if $info->{'Mirrored From'} =~ m{Rev\.\s+(\d+)}; |
$revision = $1 if $info->{'Mirrored From'} =~ m{Rev\.\s+(\d+)}; |
243 |
|
|
244 |
$self->add_icon unless $icon_html; |
$self->add_icon unless $icon_html; |
302 |
$error =~ s{at\s+(\S+)\s+line\s+(\d+)} |
$error =~ s{at\s+(\S+)\s+line\s+(\d+)} |
303 |
{at <a target="editor" href="/editor+$1+$2">$1</a> line $2}gsm; |
{at <a target="editor" href="/editor+$1+$2">$1</a> line $2}gsm; |
304 |
|
|
305 |
$error =~ s{(via package ")([\w:]+)(")} |
$error =~ s{(via (?:package) "?)([\w:]+)("?)} |
306 |
{$1<a target="editor" href="/editor+$2+1">$2</a>$3}gsm; |
{$1<a target="editor" href="/editor+$2+1">$2</a>$3}gsm; |
307 |
|
|
308 |
return $error; |
return $error; |
323 |
; |
; |
324 |
} |
} |
325 |
|
|
326 |
|
=head1 Status line |
327 |
|
|
328 |
|
=head2 add_status |
329 |
|
|
330 |
|
$self->add_status( { name => { some => 'data' } } ); |
331 |
|
|
332 |
|
$self->add_status( "append to last status popup" ); |
333 |
|
|
334 |
|
=cut |
335 |
|
|
336 |
sub add_status { |
sub add_status { |
337 |
my ( $self, $data ) = @_; |
my ( $self, $data ) = @_; |
338 |
push @status, $data; |
push @status, { 'X' => [ $self->backtrace ] }; |
339 |
|
if ( ref($data) ) { |
340 |
|
push @status, $data; |
341 |
|
} else { |
342 |
|
if ( defined $status[ $#status ] ) { |
343 |
|
$status[ $#status ]->{ '+' } = $data; |
344 |
|
} else { |
345 |
|
push @status, { '+' => $data }; |
346 |
|
} |
347 |
|
} |
348 |
} |
} |
349 |
|
|
350 |
|
=head2 clean_status |
351 |
|
|
352 |
|
Called at beginning of each request |
353 |
|
|
354 |
|
$self->clean_status; |
355 |
|
|
356 |
|
=cut |
357 |
|
|
358 |
sub clean_status { |
sub clean_status { |
359 |
@status = (); |
my ($self) = shift; |
360 |
|
@head = ( 'static/frey.css' ); |
361 |
|
@status = ( |
362 |
|
{ 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup }, |
363 |
|
{ 'Bookmarklets' => Frey::Bookmarklet->new->as_markup }, |
364 |
|
{ 'INC' => Frey::INC->new->as_markup }, |
365 |
|
); |
366 |
$icon_html = ''; |
$icon_html = ''; |
367 |
} |
} |
368 |
|
|
369 |
|
=head2 status_parts |
370 |
|
|
371 |
|
Dump all status line parts |
372 |
|
|
373 |
|
$self->status_parts |
374 |
|
|
375 |
|
=cut |
376 |
|
|
377 |
sub status_parts { |
sub status_parts { |
378 |
warn "## status parts ", dump( map { keys %$_ } @status ); |
warn "## status parts ", dump( map { keys %$_ } @status ); |
379 |
} |
} |
380 |
|
|
381 |
|
=for debug |
382 |
|
|
383 |
sub DEMOLISH { |
sub DEMOLISH { |
384 |
my ( $self ) = @_; |
my ( $self ) = @_; |
385 |
warn "## $self DEMOLISH status ", $#status + 1, " elements ", dump( map { keys %$_ } @status ) if @status; |
warn "## $self DEMOLISH status ", $#status + 1, " elements ", dump( map { keys %$_ } @status ) if @status; |
386 |
} |
} |
387 |
|
|
388 |
|
=cut |
389 |
|
|
390 |
=head2 add_icon |
=head2 add_icon |
391 |
|
|
392 |
Frey::Foo->add_icon; # /static/icons/Frey/Foo.png |
Frey::Foo->add_icon; # /static/icons/Frey/Foo.png |
401 |
$icon .= "/$variant" if $variant; |
$icon .= "/$variant" if $variant; |
402 |
my $path = 'static/icons/' . $icon . '.png'; |
my $path = 'static/icons/' . $icon . '.png'; |
403 |
if ( -e $path ) { |
if ( -e $path ) { |
404 |
warn "# $class from $self icon_path $path"; |
warn "# $class from $self icon_path $path" if $self->debug; |
405 |
return $path; |
return $path; |
406 |
} else { |
} else { |
407 |
$self->TODO( "add $path icon for $class" ); |
$self->TODO( "add $path icon for $class" ); |
531 |
) = caller($_) or last; |
) = caller($_) or last; |
532 |
|
|
533 |
push @backtrace, |
push @backtrace, |
534 |
qq|via $package from $path <a target="editor" href="/editor+$path+$line">$path</a>|; |
qq|via $package at $path line $line|; |
535 |
} |
} |
536 |
warn "# backtrace: ", dump( @backtrace ) if @backtrace; |
warn "# backtrace: ", dump( @backtrace ) if @backtrace; |
537 |
return @backtrace; |
return @backtrace; |