8 |
#use Continuity::REPL; |
#use Continuity::REPL; |
9 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
10 |
|
|
11 |
use Carp::REPL; |
#use Carp::REPL; ## XXX it would be nice, but it breaks error reporting too much |
12 |
use Frey::ClassLoader; |
use Frey::ClassLoader; |
13 |
|
|
14 |
my @messages; # Global (shared) list of messages |
my @messages; # Global (shared) list of messages |
39 |
path_session => 1, |
path_session => 1, |
40 |
cookie_session => 'sid', |
cookie_session => 'sid', |
41 |
callback => \&main, |
callback => \&main, |
42 |
debug_level => 1, |
debug_level => 2, |
43 |
staticp => sub { $_[0]->url =~ m/\.(jpg|jpeg|gif|png|css|ico|js|html?|xml|json|ya?ml)(\?.*)?$/ }, |
staticp => sub { $_[0]->url =~ m/\.(jpg|jpeg|gif|png|css|ico|js|html?|xml|json|ya?ml)(\?.*)?$/ }, |
44 |
); |
); |
45 |
$Module::Reload::Debug = 1; |
$Module::Reload::Debug = 1; # auto if debug_level > 1 |
46 |
Frey::ClassLoader->new->load_all_classes(); |
Frey::ClassLoader->new->load_all_classes(); |
47 |
$server->loop; |
$server->loop; |
48 |
} |
} |
56 |
|
|
57 |
sub main { |
sub main { |
58 |
my ($req) = @_; |
my ($req) = @_; |
59 |
|
|
60 |
my $path = $req->request->url->path; |
my $path = $req->request->url->path; |
61 |
warn "REQUEST: $path ",dump( $req->params ),"\n"; |
warn "REQUEST: $path ",dump( $req->params ),"\n"; |
62 |
|
|
75 |
$f = Frey::ObjectBrowser->new( fey_class => $1 ); |
$f = Frey::ObjectBrowser->new( fey_class => $1 ); |
76 |
} elsif ( $path =~ m!/od/([^/]+)(.*)! ) { |
} elsif ( $path =~ m!/od/([^/]+)(.*)! ) { |
77 |
$f = Frey::ObjectDesigner->new( fey_class => $1 ); |
$f = Frey::ObjectDesigner->new( fey_class => $1 ); |
78 |
} elsif ( $path =~ m!/markup/([^/]+)(.*)! ) { |
} elsif ( $path =~ m!/(markup|html)/([^/]+)(.*)! ) { |
79 |
$f = Frey::Run->new( class => $1 ); |
$f = Frey::Run->new( class => $2 ); |
80 |
} else { |
} else { |
81 |
$f = Frey::ClassBrowser->new; |
$f = Frey::ClassBrowser->new; |
82 |
} |
} |
84 |
|
|
85 |
}; |
}; |
86 |
|
|
87 |
|
my $self = $req; |
88 |
|
|
89 |
if ( $@ ) { |
if ( $@ ) { |
90 |
warn $@; |
warn $@; |
91 |
#$req->conn->send_error( 404 ); # FIXME this should probably be 500, but we can't ship page with it |
#$req->conn->send_error( 404 ); # FIXME this should probably be 500, but we can't ship page with it |
92 |
$req->print( qq{<pre class="error">$@<pre>} ); |
$req->print( qq{<pre class="error">$@<pre>} ); |
93 |
Carp::REPL::repl; # FIXME if $self->debug |
# Carp::REPL::repl; |
94 |
|
|
95 |
} |
} |
96 |
|
|
99 |
pushstream($req); |
pushstream($req); |
100 |
} |
} |
101 |
|
|
|
if ( $path =~ m/die/ ) { |
|
|
Carp::REPL::repl; # FIXME if $self->debug |
|
|
} |
|
|
|
|
102 |
# If they are sending us a message, we give them a thread for that too |
# If they are sending us a message, we give them a thread for that too |
103 |
if($path =~ /sendmessage/) { |
if($path =~ /sendmessage/) { |
104 |
send_message($req); |
send_message($req); |