/[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 13 by dpavlin, Thu May 6 16:53:40 2004 UTC revision 17 by dpavlin, Fri May 7 11:25:01 2004 UTC
# Line 14  use MWS; Line 14  use MWS;
14    
15  use Data::Dumper;  use Data::Dumper;
16    
17    my $debug = 1;
18    
19  my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 6969 ) || die;  my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 6969 ) || die;
20  my $cgi = new CGI::Lite;  my $cgi = new CGI::Lite;
21  my $mws = MWS->new('global.conf');  my $mws = MWS->new('global.conf');
# Line 21  my $tt = Template->new({ Line 23  my $tt = Template->new({
23          INCLUDE_PATH => $mws->{config}->val('global', 'templates'),          INCLUDE_PATH => $mws->{config}->val('global', 'templates'),
24          FILTERS => {          FILTERS => {
25                  'body5' => \&body5_filter,                  'body5' => \&body5_filter,
26                    'subject_search' => \&subject_search_filter,
27          },          },
28  });  });
29    
# Line 67  while ( my $c = $d->accept ) { Line 70  while ( my $c = $d->accept ) {
70                  my $url = $r->url->path;                  my $url = $r->url->path;
71    
72                  # XXX LOG                  # XXX LOG
73                  print $r->method," ",$url,Dumper($param);                  print $r->method," ",$url,"\n",Dumper($param),"\n" if ($debug);
74    
75                  # template file name (use ?format=html as default)                  # template file name (use ?format=html as default)
76                  my $tpl_file = 'master.';                  my $tpl_file = 'master.';
# Line 80  while ( my $c = $d->accept ) { Line 83  while ( my $c = $d->accept ) {
83    
84                  if ($param->{'search_val'} && $param->{'search_fld'} && !$param->{'search'}) {                  if ($param->{'search_val'} && $param->{'search_fld'} && !$param->{'search'}) {
85                          $param->{'search'} = $param->{'search_fld'}.":".$param->{'search_val'};                          $param->{'search'} = $param->{'search_fld'}.":".$param->{'search_val'};
86                    } elsif ($param->{'search'}) {
87                            ($param->{'search_fld'}, $param->{'search_val'}) = split(/:/,$param->{'search'},2);
88                  }                  }
89    
90                  my $tpl_var = {                  my $tpl_var = {
# Line 96  while ( my $c = $d->accept ) { Line 101  while ( my $c = $d->accept ) {
101                          my @res = $mws->fetch_all_results();                          my @res = $mws->fetch_all_results();
102    
103                          $tpl_var->{results} = \@res;                          $tpl_var->{results} = \@res;
104                            $tpl_var->{total_hits} = $mws->{total_hits};
105    
106    
107                  #                  #
# Line 113  while ( my $c = $d->accept ) { Line 119  while ( my $c = $d->accept ) {
119                  #                  #
120    
121                  my $res = HTTP::Response->new(RC_OK);                  my $res = HTTP::Response->new(RC_OK);
122                  $res->header( 'Content-type' => 'text/html; charset=UTF-8' );                  $res->header( 'Content-type' => 'text/html; charset=ISO-8859-2' );
123                  $res->content($html);                  $res->content($html);
124                  $c->send_response($res);                  $c->send_response($res);
125    
# Line 131  sub body5_filter { Line 137  sub body5_filter {
137          $text =~ s/^\s+//gs;          $text =~ s/^\s+//gs;
138          $text =~ s/^[\>:\|=]+\s*.*?$//msg;      # remove quoted text          $text =~ s/^[\>:\|=]+\s*.*?$//msg;      # remove quoted text
139          $text =~ s/[\n\r]+/\n/gs;               # compress cr/lf          $text =~ s/[\n\r]+/\n/gs;               # compress cr/lf
140          $text =~ s,^((?:.*?[\n\r]){5}).*$,$1<span style="color:#808080">--8&lt;--[cut]--8&lt;--</span>,s;          if ($text =~ s,^((?:.*?[\n\r]){5}).*$,$1,s) {
141                    $text =~ s/[\n\r]*$/ .../;
142            }
143          $text =~ s/[\n\r]+--\s*[\n\r]+.*$//s;          $text =~ s/[\n\r]+--\s*[\n\r]+.*$//s;
144    
145  #       my $context = Text::Context::EitherSide->new($text, context => 5);  #       my $context = Text::Context::EitherSide->new($text, context => 5);
# Line 140  sub body5_filter { Line 148  sub body5_filter {
148          return $text;          return $text;
149  }  }
150    
151    sub subject_search_filter {
152            my $s = shift;
153            # remove re: fdw: [list] preffixes from e-mail
154            while ( $s =~ s/^\s*\[(?:re|fwd|fw):\s+(.+)\]\s*$/$1/ig ||
155                    $s =~ s/^\s*(?:re|fwd|fw):\s+(.+?)\s*$/$1/ig ||
156                    $s =~ s/^\[\S+\]\s*//ig ||
157                    $s =~ s/^\[[^@]+@\w+\.\w+\s*:\s+(.+)\s*\]\s*$/$1/g
158            ) { };
159            return $s;
160    }

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

  ViewVC Help
Powered by ViewVC 1.1.26