22 |
isa => 'ArrayRef[HashRef[Str]]', |
isa => 'ArrayRef[HashRef[Str]]', |
23 |
lazy => 1, |
lazy => 1, |
24 |
default => sub { [ |
default => sub { [ |
25 |
{ 'Bookmarklets' => Frey::Bookmarklet->new->markup }, |
{ 'Bookmarklets' => Frey::Bookmarklet->new->as_markup }, |
26 |
{ 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->markup }, |
{ 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup }, |
27 |
] }, |
] }, |
28 |
); |
); |
29 |
|
|
43 |
}, |
}, |
44 |
); |
); |
45 |
|
|
46 |
|
has 'content_type' => ( |
47 |
|
is => 'rw', |
48 |
|
isa => 'Str', |
49 |
|
default => 'text/html', |
50 |
|
); |
51 |
|
|
52 |
=head2 inline_smaller_than |
=head2 inline_smaller_than |
53 |
|
|
54 |
Inline JavaScript and CSS smaller than this size into page reducing |
Inline JavaScript and CSS smaller than this size into page reducing |
85 |
$out .= $self->_inline_path( $path ) ? |
$out .= $self->_inline_path( $path ) ? |
86 |
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>| : |
87 |
qq|<link type="text/css" rel="stylesheet" href="/$path" media="screen">|; |
qq|<link type="text/css" rel="stylesheet" href="/$path" media="screen">|; |
88 |
} elsif ( $path =~ m{<.+>} ) { |
} elsif ( $path =~ m{<.+>}s ) { |
89 |
$out .= $path; |
$out .= $path; |
90 |
} else { |
} else { |
91 |
confess "don't know how to render $path"; |
confess "don't know how to render $path"; |
110 |
return if ! defined $path || $path eq ''; |
return if ! defined $path || $path eq ''; |
111 |
$path =~ s!^/!!; |
$path =~ s!^/!!; |
112 |
|
|
113 |
if ( $path =~ m{<.*>} ) { |
if ( $path =~ m{<.*>}s ) { |
114 |
push @{ $self->head }, $path; |
push @{ $self->head }, $path; |
115 |
} elsif ( -e $path ) { |
} elsif ( -e $path ) { |
116 |
if ( $path =~ m/\.(?:js|css)$/ ) { |
if ( $path =~ m/\.(?:js|css)$/ ) { |
168 |
my $url = $self->request_url; |
my $url = $self->request_url; |
169 |
$url =~ s{\?reload=\d+}{}; |
$url =~ s{\?reload=\d+}{}; |
170 |
|
|
171 |
|
my $body = $a->{body}; |
172 |
|
$body ||= $self->as_markup if $self->can('as_markup'); |
173 |
|
if ( $self->content_type !~ m{html} ) { |
174 |
|
warn "# return only $self body ", $self->content_type; |
175 |
|
return $body |
176 |
|
} elsif ( ! defined $body ) { |
177 |
|
warn "# no body"; |
178 |
|
$body = '<!-- no body -->'; |
179 |
|
} |
180 |
|
|
181 |
my $html = join("\n", |
my $html = join("\n", |
182 |
qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|, |
qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|, |
183 |
$self->_head_html, |
$self->_head_html, |
184 |
'<title>' . ( $self->title || $a->{title} || ref($self) ) . '</title>', |
'<title>' . ( $self->title || $a->{title} || ref($self) ) . '</title>', |
185 |
'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">', |
'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">', |
186 |
( $a->{head} || '' ), |
( $a->{head} || '' ), |
|
'</head><body>', |
|
|
( $a->{body} || $self->markup || '<!-- no body -->' ), |
|
187 |
qq| |
qq| |
188 |
|
</head><body> |
189 |
|
$body |
190 |
<div class="frey-status-line"> |
<div class="frey-status-line"> |
191 |
<a href="/">Frey</a> $Frey::VERSION |
<a href="/">Frey</a> $Frey::VERSION |
192 |
<a href="?reload=$reload_counter"><code>$url</code></a> |
<a href="?reload=$reload_counter"><code>$url</code></a> |
204 |
sub error { |
sub error { |
205 |
my $self = shift; |
my $self = shift; |
206 |
my $error = join(" ", @_); |
my $error = join(" ", @_); |
207 |
my ($package, $filename, $line) = caller; |
|
208 |
$error .= " at $filename line $line" if $error !~ m{ at }; |
my @backtrace; |
209 |
warn "WARN: $error\n"; |
foreach ( 0 .. 5 ) { |
210 |
|
my @caller = caller($_) or last; |
211 |
|
my @description = ( qw/ |
212 |
|
package filename line |
213 |
|
subroutine hasargs |
214 |
|
wantarray evaltext is_require |
215 |
|
hints bitmask hinthash |
216 |
|
/); |
217 |
|
push @backtrace, join(' ', |
218 |
|
map { |
219 |
|
$description[$_] . ': ' . dump $caller[$_] |
220 |
|
} ( 0 .. $#caller ) |
221 |
|
); |
222 |
|
} |
223 |
|
if ( @backtrace ) { |
224 |
|
warn "# append backtrace: ", dump( @backtrace ); |
225 |
|
$error .= "\n\t" . join( "\n\t", @backtrace ); |
226 |
|
} |
227 |
|
|
228 |
|
warn "ERROR: $error\n"; |
229 |
$error =~ s{at\s+(\S+)\s+line\s+(\d+)}{at <a target="editor" href="/editor+$1+$2">$1</a> line $2}gsm; |
$error =~ s{at\s+(\S+)\s+line\s+(\d+)}{at <a target="editor" href="/editor+$1+$2">$1</a> line $2}gsm; |
230 |
$error =~ s{(via package ")([\w:]+)(")}{$1<a target="editor" href="/editor+$2+1">$2</a>$3}gsm; |
$error =~ s{(via package ")([\w:]+)(")}{$1<a target="editor" href="/editor+$2+1">$2</a>$3}gsm; |
231 |
return qq|<pre class="frey-error">$error</pre>|; |
return qq|<pre class="frey-error">$error</pre>|; |