17 |
use vars qw( $repl $server ); |
use vars qw( $repl $server ); |
18 |
|
|
19 |
#$repl = Continuity::REPL->new; |
#$repl = Continuity::REPL->new; |
|
$server = Continuity->new( |
|
|
port => 16001, |
|
|
path_session => 1, |
|
|
cookie_session => 'sid', |
|
|
callback => \&main, |
|
|
debug_level => 1, |
|
|
staticp => sub { $_[0]->url =~ m/\.(jpg|jpeg|gif|png|css|ico|js|html?)$/ }, |
|
|
); |
|
20 |
|
|
21 |
sub run { |
sub run { |
22 |
|
$server = Continuity->new( |
23 |
|
port => 16001, |
24 |
|
path_session => 1, |
25 |
|
cookie_session => 'sid', |
26 |
|
callback => \&main, |
27 |
|
debug_level => 1, |
28 |
|
staticp => sub { $_[0]->url =~ m/\.(jpg|jpeg|gif|png|css|ico|js|html?)$/ }, |
29 |
|
); |
30 |
$server->loop; |
$server->loop; |
31 |
} |
} |
32 |
|
|
42 |
warn $req->request->header('User_Agent'); |
warn $req->request->header('User_Agent'); |
43 |
#warn dump( $req ); |
#warn dump( $req ); |
44 |
|
|
45 |
if ( $path =~ m!/~/([^/]+)(?:/([^/]*))?! ) { |
eval { |
|
my $f = Frey::Introspect->new( package => $1 ); |
|
|
$f->html( $req ); |
|
|
} |
|
46 |
|
|
47 |
if ( $path =~ m!/ob/([^/]+)(?:/([^/]*))?! ) { |
if ( $path =~ m!/~/([^/]+)(?:/([^/]*))?! ) { |
48 |
my $f = Frey::ObjectBrowser->new; |
my $f = Frey::Introspect->new( package => $1 ); |
49 |
$f->html( $req ); |
$f->html( $req ); |
50 |
} |
} |
51 |
# If this is a request for the pushtream, then give them that |
|
52 |
if($path =~ /pushstream/) { |
if ( $path =~ m!/ob/([^/]+)(?:/([^/]*))?! ) { |
53 |
pushstream($req); |
my $f = Frey::ObjectBrowser->new; |
54 |
} |
$f->html( $req ); |
55 |
|
} |
56 |
# If they are sending us a message, we give them a thread for that too |
|
57 |
if($path =~ /sendmessage/) { |
}; |
58 |
send_message($req); |
|
59 |
} |
if ( $@ ) { |
60 |
|
warn $@; |
61 |
|
#$req->conn->send_error( 404 ); # FIXME this should probably be 500, but we can't ship page with it |
62 |
|
$req->print( qq{<pre class="error">$@<pre>} ); |
63 |
|
|
64 |
|
} else { |
65 |
|
|
|
while ( 1 ) { |
|
66 |
my $f = Frey->new; |
my $f = Frey->new; |
67 |
my $classes = Continuity::Widget::DomNode->create( |
my $classes = Continuity::Widget::DomNode->create( |
68 |
ul => [ |
ul => [ |
69 |
map { |
map { |
70 |
warn dump( $_ ); |
warn dump( $_ ); |
71 |
my ( $package, $path ) = %$_; |
my ( $package, $path ) = %$_; |
72 |
( li => [ a => { href => '/~/' . $package . '/' } => [ $package ], " <tt>$path</tt>" ] ) |
( li => [ |
73 |
|
a => { href => '/~/' . $package . '/' } => [ $package ], |
74 |
|
' ', |
75 |
|
a => { href => '/ob/' . $package } => [ 'browse' ], |
76 |
|
" <tt>$path</tt>" |
77 |
|
] ) |
78 |
} @{ $f->classes } |
} @{ $f->classes } |
79 |
], |
], |
80 |
)->to_string; |
)->to_string; |
81 |
$req->print( $classes ); |
$req->print( $classes ); |
82 |
$req->next; |
|
83 |
|
} |
84 |
|
|
85 |
|
# If this is a request for the pushtream, then give them that |
86 |
|
if($path =~ /pushstream/) { |
87 |
|
pushstream($req); |
88 |
} |
} |
89 |
|
|
90 |
|
# If they are sending us a message, we give them a thread for that too |
91 |
|
if($path =~ /sendmessage/) { |
92 |
|
send_message($req); |
93 |
|
} |
94 |
|
|
95 |
} |
} |
96 |
|
|
97 |
# Here we accept a connection to the browser, and keep it open. Meanwhile we |
# Here we accept a connection to the browser, and keep it open. Meanwhile we |