2 |
|
|
3 |
use Moose; |
use Moose; |
4 |
extends 'Frey'; |
extends 'Frey'; |
|
with 'Frey::Web'; |
|
5 |
with 'Frey::Config'; |
with 'Frey::Config'; |
6 |
|
|
7 |
use Continuity; |
use Continuity; |
34 |
|
|
35 |
=cut |
=cut |
36 |
|
|
37 |
|
our $editor = Frey::Editor->new; |
38 |
|
our $port; |
39 |
|
|
40 |
sub run { |
sub run { |
41 |
my ( $self, $port ) = @_; |
my ( $self ) = @_; |
42 |
|
|
43 |
|
$port = $ENV{FREY_PORT} || $self->config->{port} || 16001; |
44 |
|
|
45 |
$server = Continuity->new( |
$server = Continuity->new( |
46 |
port => $port || $self->config->{port} || 16001, |
port => $port, |
47 |
path_session => 1, |
path_session => 1, |
48 |
cookie_session => 'sid', |
cookie_session => 'sid', |
49 |
callback => \&main, |
callback => \&main, |
54 |
); |
); |
55 |
$Module::Reload::Debug = 1; # auto if debug_level > 1 |
$Module::Reload::Debug = 1; # auto if debug_level > 1 |
56 |
Frey::ClassLoader->new->load_all_classes(); |
Frey::ClassLoader->new->load_all_classes(); |
57 |
|
$editor->switch_screen if $ENV{FREY_SWITCH_SCREEN}; |
58 |
$server->loop; |
$server->loop; |
59 |
} |
} |
60 |
|
|
72 |
|
|
73 |
my $path = $req->request->url->path; |
my $path = $req->request->url->path; |
74 |
|
|
75 |
eval { |
# eval { |
76 |
|
{ |
77 |
|
|
78 |
if ( $path =~ m{/reload(.*)} ) { |
if ( $path =~ m{/reload(.*)} ) { |
79 |
|
|
118 |
|
|
119 |
my $f; |
my $f; |
120 |
|
|
|
my $editor = Frey::Editor->new; |
|
|
|
|
121 |
# shared run params |
# shared run params |
122 |
my $run = { |
my $run = { |
123 |
request_url => $req->request->url, |
request_url => $req->request->url, |
124 |
debug => 1, |
# debug => 1, |
125 |
}; |
}; |
126 |
|
|
127 |
if ( |
if ( |
136 |
$f->request( $req ); |
$f->request( $req ); |
137 |
} elsif ( $path =~ $editor->url_regex ) { |
} elsif ( $path =~ $editor->url_regex ) { |
138 |
$req->print( $editor->command( $path ) ); |
$req->print( $editor->command( $path ) ); |
|
system( $editor->command( $path ) ); |
|
139 |
return; |
return; |
140 |
} elsif ( |
} elsif ( |
141 |
$path =~ m{/([^/]+)/(\w*as_\w+)/?([^/]+)?} |
$path =~ m{/([^/]+)/(\w*as_\w+)/?([^/]+)?} |
145 |
$run->{format} = $3 if $3; |
$run->{format} = $3 if $3; |
146 |
$params{request_url} = $req->request->url; |
$params{request_url} = $req->request->url; |
147 |
$req->print( "\r\n\r\n" ); # send something to browser so we don't time-out |
$req->print( "\r\n\r\n" ); # send something to browser so we don't time-out |
148 |
$f = Frey::Run->new( class => $class, params => \%params, run => $2, %$run ); |
$run->{$_} = $params{$_} foreach keys %params; |
149 |
|
$f = Frey::Run->new( class => $class, params => $run, run => $2, request_url => $req->request->url ); |
150 |
} elsif ( |
} elsif ( |
151 |
$path =~ m{/([^/]+)/?$} |
$path =~ m{/([^/]+)/?$} |
152 |
) { |
) { |
153 |
my $class = rest2class $1; |
my $class = rest2class $1; |
154 |
warn "# introspect $class"; |
warn "# introspect $class"; |
155 |
$f = Frey::Run->new( class => 'Frey::Introspect', params => { class => $class }, %$run ); |
$run->{class} ||= $class; |
156 |
|
$f = Frey::Run->new( class => 'Frey::Introspect', params => $run, request_url => $req->request->url ); |
157 |
} else { |
} else { |
158 |
$f = Frey::Run->new( class => 'Frey::ClassBrowser', %$run ); |
$f = Frey::Run->new( class => 'Frey::ClassBrowser', params => $run, request_url => $req->request->url ); |
159 |
} |
} |
160 |
|
|
161 |
if ( $f ) { |
if ( $f ) { |