1 |
package Frey::Web; |
package Frey::Web; |
2 |
use Moose::Role; |
use Moose::Role; |
3 |
|
|
|
#with 'Frey::Escape'; |
|
|
|
|
4 |
use Frey::Types; |
use Frey::Types; |
5 |
|
|
6 |
use Continuity::Widget::DomNode; |
use Continuity::Widget::DomNode; |
79 |
$out .= $self->_inline_path( $path ) ? |
$out .= $self->_inline_path( $path ) ? |
80 |
qq|<!-- $path --><style type="text/css">\n| . read_file( $path ) . qq|\n</style>| : |
qq|<!-- $path --><style type="text/css">\n| . read_file( $path ) . qq|\n</style>| : |
81 |
qq|<link type="text/css" rel="stylesheet" href="/$path" media="screen">|; |
qq|<link type="text/css" rel="stylesheet" href="/$path" media="screen">|; |
82 |
|
} elsif ( $path =~ m{<.+>}s ) { |
83 |
|
$out .= $path; |
84 |
} else { |
} else { |
85 |
confess "don't know how to render $path"; |
confess "don't know how to render $path"; |
86 |
} |
} |
95 |
|
|
96 |
my $size = $o->add_head( 'path/to/external.css' ); |
my $size = $o->add_head( 'path/to/external.css' ); |
97 |
|
|
98 |
|
$o->add_head( '<!-- html content -->' ); |
99 |
|
|
100 |
=cut |
=cut |
101 |
|
|
102 |
sub add_head { |
sub add_head { |
104 |
return if ! defined $path || $path eq ''; |
return if ! defined $path || $path eq ''; |
105 |
$path =~ s!^/!!; |
$path =~ s!^/!!; |
106 |
|
|
107 |
if ( -e $path ) { |
if ( $path =~ m{<.*>}s ) { |
108 |
|
push @{ $self->head }, $path; |
109 |
|
} elsif ( -e $path ) { |
110 |
if ( $path =~ m/\.(?:js|css)$/ ) { |
if ( $path =~ m/\.(?:js|css)$/ ) { |
111 |
push @{ $self->head }, $path; |
push @{ $self->head }, $path; |
112 |
} else { |
} else { |
113 |
confess "can't add_head( $path ) it's not js or css"; |
confess "can't add_head( $path ) it's not js or css"; |
114 |
} |
} |
115 |
|
return -s $path; |
116 |
} else { |
} else { |
117 |
confess "can't find $path: $!"; |
confess "can't find $path: $!"; |
118 |
} |
} |
119 |
|
|
|
return -s $path; |
|
120 |
} |
} |
121 |
|
|
122 |
our $reload_counter = 0; |
our $reload_counter = 0; |
159 |
} |
} |
160 |
} |
} |
161 |
|
|
162 |
|
my $url = $self->request_url; |
163 |
|
$url =~ s{\?reload=\d+}{}; |
164 |
|
|
165 |
my $html = join("\n", |
my $html = join("\n", |
166 |
qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|, |
qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|, |
167 |
$self->_head_html, |
$self->_head_html, |
173 |
qq| |
qq| |
174 |
<div class="frey-status-line"> |
<div class="frey-status-line"> |
175 |
<a href="/">Frey</a> $Frey::VERSION |
<a href="/">Frey</a> $Frey::VERSION |
176 |
<a href="?reload=$reload_counter"><code>| . $self->request_url . qq|</code></a> |
<a href="?reload=$reload_counter"><code>$url</code></a> |
177 |
$status_line |
$status_line |
178 |
</div> |
</div> |
179 |
</body></html> |
</body></html> |