--- trunk/lib/Frey/Web.pm 2008/11/26 00:45:52 524
+++ trunk/lib/Frey/Web.pm 2008/11/26 18:02:38 540
@@ -12,6 +12,8 @@
use Frey::Bookmarklet;
use Frey::ClassBrowser;
+use Frey::INC;
+
use Frey::SVK;
has 'head' => (
@@ -50,19 +52,34 @@
documentation => 'Maximum dump size sent to browser before truncation',
);
-=head2 inline_smaller_than
-
-Inline JavaScript and CSS smaller than this size into page reducing
-round-trips to server.
-
-=cut
-
has 'inline_smaller_than' => (
is => 'rw',
isa => 'Int',
default => 10240,
+ documentation => 'Inline JavaScript and CSS to reduce round-trips',
+);
+
+has 'chop_warning' => (
+ is => 'rw',
+ isa => 'Int',
+ default => 80,
+ documentation => 'Crop lines longer',
);
+my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"');
+my $escape_re = join '|' => keys %escape;
+
+sub html_escape {
+ my ( $self, $html ) = @_;
+ $html =~ s/($escape_re)/$escape{$1}/g;
+ return $html;
+}
+
+sub html_dump {
+ my $self = shift;
+ $self->html_escape( dump( @_ ) );
+}
+
sub dom2html {
# warn "## dom2html ",dump( @_ );
return Continuity::Widget::DomNode->create( @_ )->to_string;
@@ -142,6 +159,23 @@
our @status;
sub status { @status };
+our $icon_html;
+
+sub popup {
+ my ( $self, $name, $content, $full ) = @_;
+
+ if ( ref($content) ) {
+ $content = '' . dump($content) . '
';
+ my $l = length($content);
+ $content = qq|$l bytes| if ! $full && $l > $self->dump_max_bytes;
+ } else {
+ $content = qq|$content|;
+ }
+
+ warn "## popup [$name] = ", length( $content ), " bytes" if $self->debug;
+ return qq|$name $content\n|;
+}
+
sub page {
my $self = shift;
my $a = {@_};
@@ -153,20 +187,12 @@
my $status_line = '';
unshift @status, { 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup };
- unshift @status, { 'Bookmarklets' => Frey::Bookmarklet->new->as_markup };
+# unshift @status, { 'Bookmarklets' => Frey::Bookmarklet->new->as_markup };
+ unshift @status, { 'INC' => Frey::INC->new->as_markup };
foreach my $part ( @status ) {
foreach my $name ( keys %$part ) {
- my $content = $part->{$name};
- if ( ref($content) ) {
- $content = '' . dump($content) . '
';
- my $l = length($content);
- $content = qq|$l bytes| if $l > $self->dump_max_bytes;
- } else {
- $content = qq|$content|;
- }
- warn "### part [$name] = ", length( $content ), " bytes" if $self->debug;
- $status_line .= qq|$name $content\n|;
+ $status_line .= $self->popup( $name, $part->{$name} );
}
}
@@ -183,26 +209,7 @@
$body = '';
}
- my $warn_colors = {
- '#' => '#444',
- '##' => '#888',
- };
-
- $status_line
- .= qq|warn|
- . $self->editor_links(
- join("", map {
- warn "# $_";
- my $style = '';
- $style = $warn_colors->{$1}
- ? ' style="color:' . $warn_colors->{$1} . '"'
- : ''
- if m{^(#+)};
- qq|$_
|; # XXX should be but CSS hates me
- } $self->warnings )
- )
- . qq|
|
- if $self->warnings;
+ $status_line .= $self->warnings_html;
my ($exit,$description) = ('exit','stop server');
($exit,$description) = ('restart','restart server')
@@ -220,13 +227,14 @@
my $revision = Frey::SVK->info->{Revision} || '';
$revision = $1 if $info->{'Mirrored From'} =~ m{Rev\.\s+(\d+)};
- $self->add_icon;
+ $self->add_icon unless $icon_html;
my $html = join("\n",
qq|
but CSS hates me
+ }
}
+ close($log) || die "can't close $path: $!";
+
+ return
+ qq|warn|
+ . $self->editor_links( $warnings )
+ . qq||
+ ;
}
1;