--- trunk/lib/Frey/Web.pm 2008/07/17 19:11:01 160 +++ trunk/lib/Frey/Web.pm 2008/07/17 19:33:51 161 @@ -4,6 +4,7 @@ use Continuity::Widget::DomNode; use Data::Dump qw/dump/; use Carp qw/confess/; +use File::Slurp; has 'head' => ( is => 'rw', @@ -11,20 +12,35 @@ default => sub { [ 'static/frey.css' ] }, ); +has 'inline_smaller_than' => ( + is => 'rw', + isa => 'Int', + default => 10240, +); + sub dom2html { # warn "## dom2html ",dump( @_ ); return Continuity::Widget::DomNode->create( @_ )->to_string; } +sub _inline_path { + my ( $self, $path ) = @_; + -s $path < $self->inline_smaller_than; +} + sub _head_html { my $self = shift; my $out = ''; foreach my $path ( @{ $self->head } ) { $path =~ s!^/!!; if ( $path =~ m/\.js$/ ) { - $out .= qq||; + $out .= $self->_inline_path( $path ) ? + qq|| : + qq||; } elsif ( $path =~ m/\.css$/ ) { - $out .= qq||; + $out .= $self->_inline_path( $path ) ? + qq|| : + qq||; } else { confess "don't know how to render $path"; }