--- trunk/lib/Frey/Server.pm 2008/11/05 20:18:33 314 +++ trunk/lib/Frey/Server.pm 2008/11/18 12:02:57 407 @@ -1,8 +1,9 @@ package Frey::Server; use Moose; - +extends 'Frey'; with 'Frey::Web'; +with 'Frey::Config'; use Continuity; #use Continuity::REPL; @@ -11,6 +12,7 @@ #use Carp::REPL; ## XXX it would be nice, but it breaks error reporting too much use Frey::ClassLoader; use Frey::Run; +use Frey::Editor; my @messages; # Global (shared) list of messages my $got_message; # Flag to indicate that there is a new message to display @@ -36,7 +38,7 @@ sub run { my ( $self, $port ) = @_; $server = Continuity->new( - port => $port || 16001, + port => $port || $self->config->{port} || 16001, path_session => 1, cookie_session => 'sid', callback => \&main, @@ -80,6 +82,7 @@ my $f; my $run_regexp = join('|', Frey::Run->runnable ); + my $editor = Frey::Editor->new; if ( $path =~ m{/Frey[:-]+ObjectBrowser} @@ -91,18 +94,22 @@ ) { $f = Frey::ObjectDesigner->new( fey_class => $params{class} ); $f->request( $req ); + } elsif ( $path =~ $editor->url_regex ) { + $req->print( $editor->command( $path ) ); + system( $editor->command( $path ) ); + return; } elsif ( $path =~ m{/([^/]+)/($run_regexp)} ) { my $class = rest2class $1; warn "# run $class $2\n"; - $f = Frey::Run->new( class => $class, params => \%params ); + $f = Frey::Run->new( class => $class, params => \%params, run => $2, request_url => $req->request->url ); } elsif ( $path =~ m{/([^/]+)/?$} ) { my $class = rest2class $1; warn "# introspect $class"; - $f = Frey::Run->new( class => 'Frey::Introspect', params => { class => $class } ); + $f = Frey::Run->new( class => 'Frey::Introspect', params => { class => $class }, request_url => $req->request->url ); } else { $f = Frey::Run->new( class => 'Frey::ClassBrowser' ); } @@ -120,7 +127,7 @@ if ( $@ ) { warn $@; $req->conn->send_error( 404 ); # FIXME this should probably be 500, but we can't ship page with it - $req->print( qq{
$@
} );
+		$req->print( qq{
$@
} );
 #		Carp::REPL::repl;
 
 	}