1 |
package Frey::Web; |
package Frey::Web; |
2 |
use Moose::Role; |
use Moose::Role; |
3 |
|
|
4 |
|
#with 'Frey::Escape'; |
5 |
|
|
6 |
use Frey::Types; |
use Frey::Types; |
7 |
|
|
8 |
use Continuity::Widget::DomNode; |
use Continuity::Widget::DomNode; |
9 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
10 |
use Carp qw/confess cluck/; |
use Carp qw/confess/; |
11 |
use File::Slurp; |
use File::Slurp; |
12 |
|
|
13 |
has 'head' => ( |
has 'head' => ( |
26 |
] }, |
] }, |
27 |
); |
); |
28 |
|
|
29 |
has 'urequest_url' => ( |
has 'request_url' => ( |
30 |
is => 'rw', |
is => 'rw', |
31 |
isa => 'Uri', coerce => 1, |
isa => 'Uri', coerce => 1, |
32 |
default => '/', |
default => '/', |
127 |
my $status_line = ''; |
my $status_line = ''; |
128 |
foreach my $part ( @{ $self->status } ) { |
foreach my $part ( @{ $self->status } ) { |
129 |
foreach my $name ( keys %$part ) { |
foreach my $name ( keys %$part ) { |
130 |
warn "### part [$name] = ", length( $part->{name} ), " bytes" if $self->debug; |
my $content = $part->{$name}; |
131 |
$status_line .= qq|<span class="frey-popup">$name<span>| . $part->{$name} . qq|</span></span>|; |
if ( ref($content) ) { |
132 |
|
$content = '<code>' . dump($content) . '</code>'; |
133 |
|
my $l = length($content); |
134 |
|
$content = qq|<span>$l bytes</span>| if $l > 1024; |
135 |
|
} else { |
136 |
|
$content = qq|<span>$content</span>|; |
137 |
|
} |
138 |
|
warn "### part [$name] = ", length( $content ), " bytes" if $self->debug; |
139 |
|
$status_line .= qq|<span class="frey-popup">$name $content</span>\n|; |
140 |
} |
} |
141 |
} |
} |
142 |
|
|
151 |
qq| |
qq| |
152 |
<div class="frey-status-line"> |
<div class="frey-status-line"> |
153 |
<a href="/">Frey</a> $Frey::VERSION |
<a href="/">Frey</a> $Frey::VERSION |
154 |
<a href="?reload=$reload_counter"><code>| . $self->urequest_url . qq|</code></a> |
<a href="?reload=$reload_counter"><code>| . $self->request_url . qq|</code></a> |
155 |
$status_line |
$status_line |
156 |
</div> |
</div> |
157 |
</body></html> |
</body></html> |
164 |
} |
} |
165 |
|
|
166 |
sub error { |
sub error { |
167 |
my ( $self, $error ) = @_; |
my $self = shift; |
168 |
cluck $error; |
my $error = join(" ", @_); |
169 |
$error =~ s{at\s+(\S+)\s+line\s+(\d+)}{ <a href="/editor$1+$2" target="editor">$1</a> line $2}gsm; |
my ($package, $filename, $line) = caller; |
170 |
|
$error .= " at $filename line $line"; |
171 |
|
warn "WARN: $error\n"; |
172 |
|
$error =~ s{at\s+(\S+)\s+line\s+(\d+)}{at <a href="/editor$1+$2" target="editor">$1</a> line $2}gsm; |
173 |
return qq|<pre class="frey-error">$error</pre>|; |
return qq|<pre class="frey-error">$error</pre>|; |
174 |
} |
} |
175 |
|
|