--- trunk/lib/Frey/Introspect.pm 2008/07/05 15:19:55 53 +++ trunk/lib/Frey/Introspect.pm 2008/07/08 12:19:04 59 @@ -11,6 +11,7 @@ use List::Util; use Continuity::Widget::DomNode; +use lib 'lib'; extends 'Frey'; @@ -45,8 +46,10 @@ my @roles_to_apply; $rmeta->add_method("apply", sub{push(@roles_to_apply, [@_])}); #load the package with the hacked Moose::Meta::Role - eval { Class::MOP::load_class($package); }; - confess "Failed to load package ${package} $@" if $@; + + #eval { Class::MOP::load_class($package); }; + #confess "Failed to load package ${package} $@" if $@; + Class::MOP::load_class($package); my $meta = $package->meta; @@ -115,7 +118,7 @@ $out .= "\t\t},\n\t\tmeta: Frey.HTML, classMethods: { renderHTML: function () { - return new Joose.SimpleRequest().getText(\"inspect?module=$m;class=$c\") + return new Joose.SimpleRequest().getText(\"/~/${m}::${c}\") },\n"; $out .= "\t\t},\n"; @@ -177,43 +180,78 @@ while (1) { - my $js = [ map { - ( script => { type => 'text/javascript', src => $_ } ) - } @javascript ]; - warn "# js = ",dump( $js ); + my $js = Continuity::Widget::DomNode->create( + map { + ( script => { type => 'text/javascript', src => $_ } ) + } @javascript + )->to_string; + + $js .= << '__END_OF_JS__'; + +__END_OF_JS__ - my $o; + warn "# >>> js\n$js\n"; + + my $methods; + + my ( $class, $meta, $is_role ); + eval { ( $class, $meta, $is_role ) = $self->load_package(); }; + if ( $@ ) { + warn "ERROR: $@"; + $request->conn->send_status_line( 500, $@ ); + $request->print( $@ ); + $request->next; + return; + } - my ( $class, $meta, $is_role ) = $self->load_package(); if ( $class->can('meta') ) { - $o = Continuity::Widget::DomNode->create( + $methods = Continuity::Widget::DomNode->create( ul => [ map { ( - li => [ a => { href => $_ } => [ $_ ] ] + li => [ a => { href => '/~/' . $self->package . '/' . $_ } => [ $_ ] ] ) } $self->methods ] )->to_string; } else { - $o = 'not introspectable'; + $methods = 'not introspectable'; } - warn "# o = ",dump( $o ); - + my $attributes = Continuity::Widget::DomNode->create( + ul => [ + map { + my $attr = $class->get_attribute($_); + warn "## $_ ", $attr->is_required ? 'required' : 'optional'; + ( li => [ a => { href => '/~/' . $self->package . '/' . $_ } => [ $_ ], ( $attr->is_required ? ' required' : '' ) ] ) + } $class->get_attribute_list + ], + )->to_string; + my $doc = Continuity::Widget::DomNode->create( html => [ head => [ link => { rel=>"stylesheet", href=>"/static/app.css", type=>"text/css", media=>"screen" }, -# $js, + $js, + title => [ 'Introspect ', $self->package ], ], body => [ - h1 => [ 'Introspect ', $self->package ], - $o, + h1 => [ $self->package ], + h2 => [ 'Methods' ], + $methods, + h2 => [ 'Atrributes' ], + $attributes, ], ] ); $request->print($doc->to_string); - warn "# html = ", $doc->to_string; + warn "# >>> html\n", $doc->to_string, "\n"; $request->next; } warn "# exit html";