3 |
extends 'Frey'; |
extends 'Frey'; |
4 |
with 'Frey::Web'; |
with 'Frey::Web'; |
5 |
with 'Frey::Config'; |
with 'Frey::Config'; |
6 |
|
with 'Frey::Escape'; |
7 |
|
|
8 |
=head1 NAME |
=head1 NAME |
9 |
|
|
12 |
=head1 DESCRIPTION |
=head1 DESCRIPTION |
13 |
|
|
14 |
This object will try to run other Moose objects from your application. It |
This object will try to run other Moose objects from your application. It |
15 |
will try to invoke C<html> or C<markup> method on the. |
will try to invoke C<data>, C<html> or C<markup> method on the. |
16 |
|
|
17 |
=cut |
=cut |
18 |
|
|
19 |
|
sub execute { qw/data markup request/ } |
20 |
|
|
21 |
has 'class' => ( |
has 'class' => ( |
22 |
is => 'rw', |
is => 'rw', |
23 |
isa => 'Str', |
isa => 'Str', |
45 |
warn "## params = ",dump( %params ); |
warn "## params = ",dump( %params ); |
46 |
|
|
47 |
my $html; |
my $html; |
48 |
|
my $values = $self->config($class); |
49 |
|
$values = {} if $@; |
50 |
|
|
51 |
if ( @required ) { |
if ( @required ) { |
52 |
$html = qq|<h1>Required params for $class</h1><form method="post">|; |
$html = qq|<h1>Required params for $class</h1><form method="post">|; |
53 |
foreach my $name ( @required ) { |
foreach my $name ( @required ) { |
54 |
my $type = $name =~ m/^pass/ ? 'password' : 'text'; |
my $type = $name =~ m/^pass/ ? 'password' : 'text'; |
55 |
my $value = $self->config($class)->{$name}; |
my $value = $values ? $values->{$name} : ''; |
56 |
$html .= qq|<label for="$name">$name</label><input type="$type" name="$name" value="$value">|; |
$html .= qq|<label for="$name">$name</label><input type="$type" name="$name" value="$value">|; |
57 |
} |
} |
58 |
$html .= qq|<input type="submit" value="Run $class"></form>|; |
$html .= qq|<input type="submit" value="Run $class"></form>|; |
63 |
warn "## turning over to $o->request"; |
warn "## turning over to $o->request"; |
64 |
$o->request( $req ); |
$o->request( $req ); |
65 |
} elsif ( $o->can('markup') ) { |
} elsif ( $o->can('markup') ) { |
66 |
warn "## using $o->markup"; |
warn "## using ",ref($o), "->markup"; |
67 |
$html = $o->markup; |
$html = $o->markup; |
68 |
warn ">>> markup $class ",length( $html ), " bytes\n"; |
warn ">>> markup $class ",length( $html ), " bytes\n"; |
69 |
|
} elsif ( $o->can('data') ) { |
70 |
|
$html = '<code>' . $self->html_escape( dump( $o->data ) ) . '</code>'; |
71 |
} else { |
} else { |
72 |
$html = "IGNORE: $class ", $o->dump; |
$html = "IGNORE: $class ", $o->dump; |
73 |
warn $html; |
warn $html; |