/[mws]/trunk/httpd.pl
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/httpd.pl

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

revision 7 by dpavlin, Wed May 5 15:38:35 2004 UTC revision 13 by dpavlin, Thu May 6 16:53:40 2004 UTC
# Line 15  use MWS; Line 15  use MWS;
15  use Data::Dumper;  use Data::Dumper;
16    
17  my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 6969 ) || die;  my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 6969 ) || die;
 print "Please contact me at: <URL:", $d->url, ">\n";  
   
18  my $cgi = new CGI::Lite;  my $cgi = new CGI::Lite;
19  my $mws = MWS->new('global.conf');  my $mws = MWS->new('global.conf');
20  my $tt = Template->new({  my $tt = Template->new({
# Line 26  my $tt = Template->new({ Line 24  my $tt = Template->new({
24          },          },
25  });  });
26    
27    print "Web server ready at: ", $d->url, "\n";
28    
29    
30  while ( my $c = $d->accept ) {  while ( my $c = $d->accept ) {
31          while ( my $r = $c->get_request ) {          while ( my $r = $c->get_request ) {
# Line 78  while ( my $c = $d->accept ) { Line 78  while ( my $c = $d->accept ) {
78                  #                  #
79                  my $html;                  my $html;
80    
81                    if ($param->{'search_val'} && $param->{'search_fld'} && !$param->{'search'}) {
82                            $param->{'search'} = $param->{'search_fld'}.":".$param->{'search_val'};
83                    }
84    
85                    my $tpl_var = {
86                            param   => $param
87                    };
88    
89                  # show search results                  # show search results
90                  # ?search=foo:bar                  # ?search=foo:bar
91                  if ($param->{'search'}) {                  if ($param->{'search'}) {
# Line 87  while ( my $c = $d->accept ) { Line 95  while ( my $c = $d->accept ) {
95                          my $results = $mws->search($param->{'search'});                          my $results = $mws->search($param->{'search'});
96                          my @res = $mws->fetch_all_results();                          my @res = $mws->fetch_all_results();
97    
98                          $tt->process($tpl_file, {                          $tpl_var->{results} = \@res;
99                                  query   => $param->{'search'},  
                                 results => \@res,  
                                 param   => $param,  
                         }, \$html) || die $tt->error();  
100    
101                  #                  #
102                  # ?show_id=XXXXxxxx___message_id___xxxxXXXX                  # ?show_id=XXXXxxxx___message_id___xxxxXXXX
103                  } elsif ($param->{'show_id'}) {                  } elsif ($param->{'show_id'}) {
104                                                    
105                          my $row = $mws->fetch_result_by_id($param->{'show_id'});                          my $row = $mws->fetch_result_by_id($param->{'show_id'});
106                          $tt->process($tpl_file, {                          $tpl_var->{message} = $row;
                                 message => $row,  
                         }, \$html) || die $tt->error();  
107                  }                  }
108    
109                    $tt->process($tpl_file, $tpl_var, \$html) || die $tt->error();
110    
111                  #                  #
112                  # send HTMLto client                  # send HTMLto client
113                  #                  #
114    
115                  my $res = HTTP::Response->new(RC_OK);                  my $res = HTTP::Response->new(RC_OK);
116                  $res->header( 'Content-type' => 'text/html; charset=iso-8859-2' );                  $res->header( 'Content-type' => 'text/html; charset=UTF-8' );
117                  $res->content($html);                  $res->content($html);
118                  $c->send_response($res);                  $c->send_response($res);
119    
# Line 119  while ( my $c = $d->accept ) { Line 124  while ( my $c = $d->accept ) {
124    
125  # template toolkit filter  # template toolkit filter
126    
127    #use Text::Context::EitherSide;
128    
129  sub body5_filter {  sub body5_filter {
130          my $text = shift;          my $text = shift;
131          $text =~ s/^\s+//gs;          $text =~ s/^\s+//gs;
132          $text =~ s/[\n\r]+[\>:\|=]+\s*.*?[\n\r]+//sg;   # remove quoted text          $text =~ s/^[\>:\|=]+\s*.*?$//msg;      # remove quoted text
133            $text =~ s/[\n\r]+/\n/gs;               # compress cr/lf
134          $text =~ s,^((?:.*?[\n\r]){5}).*$,$1<span style="color:#808080">--8&lt;--[cut]--8&lt;--</span>,s;          $text =~ s,^((?:.*?[\n\r]){5}).*$,$1<span style="color:#808080">--8&lt;--[cut]--8&lt;--</span>,s;
135          $text =~ s/[\n\r]+--\s*[\n\r]+.*$//s;          $text =~ s/[\n\r]+--\s*[\n\r]+.*$//s;
136    
137    #       my $context = Text::Context::EitherSide->new($text, context => 5);
138    #       return $context->as_string("perl");
139    
140          return $text;          return $text;
141  }  }
142    

Legend:
Removed from v.7  
changed lines
  Added in v.13

  ViewVC Help
Powered by ViewVC 1.1.26