--- trunk/lib/Frey/Web.pm 2008/07/17 18:00:28 157 +++ trunk/lib/Frey/Web.pm 2008/07/17 19:33:51 161 @@ -4,11 +4,18 @@ use Continuity::Widget::DomNode; use Data::Dump qw/dump/; use Carp qw/confess/; +use File::Slurp; has 'head' => ( is => 'rw', isa => 'ArrayRef[Str]', - default => sub { [] }, + default => sub { [ 'static/frey.css' ] }, +); + +has 'inline_smaller_than' => ( + is => 'rw', + isa => 'Int', + default => 10240, ); sub dom2html { @@ -16,15 +23,24 @@ 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"; }