/[Sack]/trunk/lib/Sack/Server.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Sack/Server.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 212 by dpavlin, Sat Nov 21 16:34:12 2009 UTC revision 213 by dpavlin, Sun Nov 22 15:31:38 2009 UTC
# Line 16  use Cwd qw(abs_path); Line 16  use Cwd qw(abs_path);
16  use lib '/srv/Sack/lib';  use lib '/srv/Sack/lib';
17  use Sack::Merge;  use Sack::Merge;
18  use Sack::Server::HTTP;  use Sack::Server::HTTP;
19    use Sack::Server::HTML;
20    
21  my @cloud;  my @cloud;
22  my $cloud_path = $ENV{CLOUD} || "etc/cloud";  my $cloud_path = $ENV{CLOUD} || "etc/cloud";
# Line 92  while (1) { Line 93  while (1) {
93                  } elsif ( $sock == $www ) {                  } elsif ( $sock == $www ) {
94                          my $client = $www->accept;                          my $client = $www->accept;
95                          Sack::Server::HTTP::request( $client, sub {                          Sack::Server::HTTP::request( $client, sub {
 warn "XXX callback ",dump( @_ );  
96                                  my ( $send, $method, $param ) = @_;                                  my ( $send, $method, $param ) = @_;
97    
98                                  if ( $method =~ m{views} ) {                                  if ( $method =~ m{views} ) {
# Line 101  warn "XXX callback ",dump( @_ ); Line 101  warn "XXX callback ",dump( @_ );
101                                          Sack::Merge->clean;                                          Sack::Merge->clean;
102                                          to_all { view => $code, path => $method };                                          to_all { view => $code, path => $method };
103                                          print $send "HTTP/1.0 302 $method\r\nLocation: /\r\n\r\n";                                          print $send "HTTP/1.0 302 $method\r\nLocation: /\r\n\r\n";
104                                          return;                                          return 1;
105                                  } elsif ( $method =~ m{^/tmp/sack} ) {                                  } elsif ( $method =~ m{^/tmp/sack} ) {
106                                          @shard_paths = glob "$method/*";                                          @shard_paths = glob "$method/*";
107                                          warn "loading shard $method from ", dump( @shard_paths );                                          warn "loading shard $method from ", dump( @shard_paths );
108                                          to_all { load => $method };                                          to_all { load => $method };
109                                          print $send "HTTP/1.0 302 $method\r\nLocation: /\r\n\r\n";                                          print $send "HTTP/1.0 302 $method\r\nLocation: /\r\n\r\n";
110                                          return;                                          return 1;
111                                    } elsif ( $method =~ m{^/out/(.+)} ) {
112                                            print $send "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n";
113                                            Sack::Server::HTML::send_out( $send, Sack::Merge->out, $1, $param );
114                                            return 1;
115                                  }                                  }
116    
117                                  print $send "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n";                                  print $send "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n";
# Line 117  warn "XXX callback ",dump( @_ ); Line 121  warn "XXX callback ",dump( @_ );
121                                          , qq|</ul>|                                          , qq|</ul>|
122                                          ;                                          ;
123    
124                                    my $out = Sack::Merge->out;    
125                                    print $send qq|<h1>Results</h1><ul>|
126                                            , join("\n", map { qq|<li><a href="/out/$_" target="$_">$_</a>| } keys %$out )
127                                            , qq|</ul>|
128                                            ;
129    
130                                  print $send '<h1>Info</h1><pre>' . dump( $info ) . '</pre>';                                  print $send '<h1>Info</h1><pre>' . dump( $info ) . '</pre>';
131    
132                                  print $send qq|<h1>Data</h1><ul>|                                  print $send qq|<h1>Data</h1><ul>|

Legend:
Removed from v.212  
changed lines
  Added in v.213

  ViewVC Help
Powered by ViewVC 1.1.26