1 |
package Frey::Run; |
package Frey::Run; |
2 |
use Moose; |
use Moose; |
3 |
#extends 'Frey::ClassLoader'; |
#extends 'Frey::Class::Loader'; |
4 |
extends 'Frey::Action'; |
extends 'Frey::Action'; |
5 |
with 'Frey::Session'; |
with 'Frey::Session'; |
6 |
|
|
57 |
default => 'html', |
default => 'html', |
58 |
); |
); |
59 |
|
|
60 |
|
has 'request_url' => ( |
61 |
|
documentation => 'Take url from params if not specified', |
62 |
|
is => 'rw', |
63 |
|
isa => 'Uri', coerce => 1, |
64 |
|
lazy => 1, |
65 |
|
default => sub { |
66 |
|
my $self = shift; |
67 |
|
$self->params->{request_url}; |
68 |
|
}, |
69 |
|
); |
70 |
|
|
71 |
sub html { |
sub html { |
72 |
my ( $self ) = @_; |
my ( $self ) = @_; |
73 |
|
|
117 |
$body .= '</table>'; |
$body .= '</table>'; |
118 |
} |
} |
119 |
} elsif ( $self->run =~ m{as_data} ) { |
} elsif ( $self->run =~ m{as_data} ) { |
120 |
$data = $o->{$self->run}(); |
my $run = $self->run; |
121 |
warn "no data from ", $self->run; |
$data = $o->$run; |
122 |
$data ||= $o->as_data(); |
confess "no data for $class->$run" unless defined $data; |
|
confess "no data for $class->" . $self->run . " from " . $self->html_dump( $data ) unless $data; |
|
123 |
$self->add_status( { $self->run => $data } ); |
$self->add_status( { $self->run => $data } ); |
124 |
} else { |
} else { |
125 |
$body = $self->error( "IGNORE: $class ", $o->dump ); |
$body = $self->error( "IGNORE: $class ", $o->dump ); |
134 |
$body .= Frey::View::Dumper->new( data => $data )->as_markup if defined $data; |
$body .= Frey::View::Dumper->new( data => $data )->as_markup if defined $data; |
135 |
} |
} |
136 |
|
|
137 |
$self->title( $class ); |
$o->title( $class ); |
138 |
|
|
139 |
$html = $o->page( body => $body ) if $body && !$html; |
$html = $o->page( body => $body ) if $body && !$html; |
140 |
|
$self->content_type( $o->content_type ); |
141 |
|
|
142 |
confess "no html output for $class ", $o->dump unless defined $html; |
confess "no html output for $class ", $o->dump unless defined $html; |
143 |
}; |
}; |
144 |
|
|
147 |
$self->status_parts; |
$self->status_parts; |
148 |
|
|
149 |
if ( $@ ) { |
if ( $@ ) { |
150 |
|
my $error = $@; |
151 |
my $o = Frey->new; |
my $o = Frey->new; |
152 |
|
$o->{request_url} = $self->request_url; # sigh, this is dynamic languge, right? |
153 |
Frey::Web->meta->apply( $o ); |
Frey::Web->meta->apply( $o ); |
154 |
$html = $o->page( body => $self->error( $@ ) ); |
$html = $o->page( body => $self->error( $error ) ); |
155 |
} |
} |
156 |
|
|
157 |
warn $self->class, " produced ", length($html), " bytes"; |
warn $self->class, " produced ", length($html), " bytes of ", $self->content_type; |
158 |
|
|
159 |
return $html; |
return $html; |
160 |
} |
} |