/[Frey]/branches/mojo/lib/Frey/Mojo/Run.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /branches/mojo/lib/Frey/Mojo/Run.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 240 by dpavlin, Sat Nov 1 16:44:32 2008 UTC revision 241 by dpavlin, Sun Nov 2 18:27:18 2008 UTC
# Line 19  sub markup { Line 19  sub markup {
19          warn "# ", dump( $c->match->captures );          warn "# ", dump( $c->match->captures );
20    
21          my $params = $c->request->params->to_hash;          my $params = $c->request->params->to_hash;
22          warn "# params ", dump( $params );          warn "# params ", dump( $c->request->params );
23    
24          my $class = $c->match->captures->{class} || 'Frey::ClassBrowser';          my $class = $c->match->captures->{class} || 'Frey::ClassBrowser';
25          $class =~ s{[/-]}{::}g;          $class =~ s{[/-]}{::}g;
26    
27          my $o = $class->new( %$params );          my @required =
28          $o->depends if $o->can('depends');                  grep {
29                            defined $_ && !defined( $params->{$_} )
30                    }
31                    map {
32                            my $attr = $class->meta->get_attribute($_);
33                            $attr->is_required && $_
34                    } $class->meta->get_attribute_list;
35    
36            warn "## required = ",dump( @required );
37    
38          my $html;          my $html;
39          if ( $o->can('markup') ) {  
40                  $html = eval { $o->markup };          my $values = {};
41                  if ( $@ ) {          $values = $class->config($class) if $class->can('config');
42                          warn $@;  
43                          $html .= qq{<code>$@</code>};          if ( @required ) {
44                    $html = qq|<h1>Required params for $class</h1><form method="get">|;
45                    foreach my $name ( @required ) {
46                            my $type = $name =~ m/^pass/ ? 'password' : 'text';
47                            my $value = $values ? $values->{$name} : '';
48                            $html .= qq|<label for="$name">$name</label><input type="$type" name="$name" value="$value">|;
49                  }                  }
50                    $html .= qq|<input type="submit" value="Run $class"></form>|;
51          } else {          } else {
                 warn "SKIP: $class can't markup";  
         }  
52    
53          eval {                  my $o = $class->new( %$params );
54                  # FIXME am I paranoid?                  $o->depends if $o->can('depends');
55                  package Mock::Web;  
56                  use Moose;                  if ( $o->can('markup') ) {
57                  extends 'Frey';                          $html = eval { $o->markup };
58                  with 'Frey::Web';                          if ( $@ ) {
59                                    warn $@;
60                  $html = Mock::Web->new->page(                                  $html .= qq{<code>$@</code>};
61                          title => $class,                          }
62                          body => $html,                  } else {
63                  );                          warn "SKIP: $class can't markup";
64          };                  }
65    
66                    eval {
67                            # FIXME am I paranoid?
68                            package Mock::Web;
69                            use Moose;
70                            extends 'Frey';
71                            with 'Frey::Web';
72    
73                            $html = Mock::Web->new->page(
74                                    title => $class,
75                                    body => $html,
76                            );
77                    };
78            }
79    
80      # Response objec      # Response objec
81      my $res = $c->res;      my $res = $c->res;

Legend:
Removed from v.240  
changed lines
  Added in v.241

  ViewVC Help
Powered by ViewVC 1.1.26