11 |
use File::Slurp; |
use File::Slurp; |
12 |
|
|
13 |
use Frey::Bookmarklet; |
use Frey::Bookmarklet; |
14 |
use Frey::ClassBrowser; |
use Frey::Class::Browser; |
15 |
use Frey::INC; |
use Frey::INC; |
16 |
|
|
17 |
use Frey::SVK; |
use Frey::SVK; |
93 |
sub popup { my $self = shift; $self->popup_dropdown('popup', @_); } |
sub popup { my $self = shift; $self->popup_dropdown('popup', @_); } |
94 |
sub dropdown { my $self = shift; $self->popup_dropdown('dropdown', @_); } |
sub dropdown { my $self = shift; $self->popup_dropdown('dropdown', @_); } |
95 |
|
|
96 |
our $re_html = qr{<(?:!--.+?--|(\w+).+?/\1|[^>]+/)>}s; # relaxed html check for one semi-valid tag |
our $re_html = qr{<(?:!--.+?--|(\w+).+?/\1|[^>]+/?)>}s; # relaxed html check for one semi-valid tag |
97 |
|
|
98 |
sub popup_dropdown { |
sub popup_dropdown { |
99 |
my ( $self, $type, $name, $content, $full ) = @_; |
my ( $self, $type, $name, $content, $full ) = @_; |
184 |
| ); |
| ); |
185 |
} |
} |
186 |
|
|
187 |
|
sub add_js { |
188 |
|
my ($self,$css) = @_; |
189 |
|
my ( $package, $path, $line ) = caller; |
190 |
|
$self->add_head( qq| |
191 |
|
<script type="text/javascript"> |
192 |
|
/* via $package at $path line $line */ |
193 |
|
$css |
194 |
|
</script> |
195 |
|
| ); |
196 |
|
} |
197 |
|
|
198 |
our $reload_counter = 0; |
our $reload_counter = 0; |
199 |
|
|
200 |
|
|
371 |
if ( $error !~ m{\n$} ) { |
if ( $error !~ m{\n$} ) { |
372 |
if ( my @backtrace = $self->backtrace ) { |
if ( my @backtrace = $self->backtrace ) { |
373 |
$error .= "\n\t" . join( "\n\t", @backtrace ); |
$error .= "\n\t" . join( "\n\t", @backtrace ); |
374 |
$fatal = qq| class="fatal"|; |
$fatal = qq| frey-fatal|; |
375 |
} |
} |
376 |
} |
} |
377 |
|
|
419 |
my ($self) = shift; |
my ($self) = shift; |
420 |
@head = ( 'static/frey.css' ); |
@head = ( 'static/frey.css' ); |
421 |
@status = ( |
@status = ( |
422 |
{ 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup }, |
{ 'ClassBrowser' => Frey::Class::Browser->new( usage_on_top => 0 )->as_markup }, |
423 |
{ 'Bookmarklets' => Frey::Bookmarklet->new->as_markup }, |
{ 'Bookmarklets' => Frey::Bookmarklet->new->as_markup }, |
424 |
{ 'INC' => Frey::INC->new->as_markup }, |
{ 'INC' => Frey::INC->new->as_markup }, |
425 |
); |
); |
457 |
sub icon_path { |
sub icon_path { |
458 |
my ($self,$class,$variant) = @_; |
my ($self,$class,$variant) = @_; |
459 |
my $icon = $class; |
my $icon = $class; |
460 |
|
$icon ||= $self->title; |
461 |
$icon =~ s{::}{/}g; |
$icon =~ s{::}{/}g; |
462 |
$icon .= "/$variant" if $variant; |
$icon .= "/$variant" if $variant; |
463 |
my $path = 'static/icons/' . $icon . '.png'; |
my $path = 'static/icons/' . $icon . '.png'; |
660 |
return @backtrace; |
return @backtrace; |
661 |
} |
} |
662 |
|
|
663 |
|
=head2 checkbox |
664 |
|
|
665 |
|
Generate checkbox html markup from some attribute |
666 |
|
|
667 |
|
my $html = $self->checkbox('attribute_name', $value); |
668 |
|
|
669 |
|
=cut |
670 |
|
|
671 |
|
sub checkbox { |
672 |
|
my ($self,$name,$value) = @_; |
673 |
|
my $checked = ''; |
674 |
|
my $all_checkboxes = eval { $self->$name }; |
675 |
|
warn "ERROR tried to get checkbox value for '$name' which is unknown: $@" if $@; |
676 |
|
$all_checkboxes = [ $all_checkboxes ] unless ref($all_checkboxes) eq 'ARRAY'; # sigh, too chatty |
677 |
|
$checked = ' checked' if grep { defined $_ && $_ eq $value } @$all_checkboxes; |
678 |
|
warn "# checkbox $name $value $checked\t", $self->dump( $self->$name ); |
679 |
|
qq|<input name="$name" value="$value" type="checkbox"$checked>|; |
680 |
|
} |
681 |
|
|
682 |
|
=head2 strip |
683 |
|
|
684 |
|
Strip whitespace around content |
685 |
|
|
686 |
|
my $stripped = strip(' no more whitespace around this '); |
687 |
|
|
688 |
|
=cut |
689 |
|
|
690 |
|
sub strip { |
691 |
|
my $t = shift; |
692 |
|
$t =~ s{^\s+}{}gs; |
693 |
|
$t =~ s{>\s+<}{><}gs; |
694 |
|
$t =~ s{\s+$}{}gs; |
695 |
|
return $t; |
696 |
|
} |
697 |
|
|
698 |
1; |
1; |