/[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 19 by dpavlin, Fri May 7 20:52:34 2004 UTC revision 21 by dpavlin, Sat May 8 00:54:16 2004 UTC
# Line 25  my $tt = Template->new({ Line 25  my $tt = Template->new({
25                  'body5' => \&body5_filter,                  'body5' => \&body5_filter,
26                  'subject_search' => \&subject_search_filter,                  'subject_search' => \&subject_search_filter,
27          },          },
28            EVAL_PERL => 1,
29  });  });
30    
31  print "Web server ready at: ", $d->url, "\n";  print "Web server ready at: ", $d->url, "\n";
# Line 76  while ( my $c = $d->accept ) { Line 77  while ( my $c = $d->accept ) {
77                  my $tpl_file = 'master.';                  my $tpl_file = 'master.';
78                  $tpl_file .= $param->{'format'} || 'html';                  $tpl_file .= $param->{'format'} || 'html';
79    
80                    # parse date from url
81                    my ($yyyy,$mm,$dd) = $mws->yyyymmdd;
82    
83                    my $yyyymm;
84    
85                    my $date_limit;
86    
87                    if ($url =~ m,^/(\d{4})[/-](\d+)[/-](\d+),) {
88                            ($yyyy, $mm, $dd) = $mws->fmtdate($1,$2,$3);
89                             $date_limit = "$yyyy-$mm-$dd";
90                    } elsif ($url =~ m,^/(\d{4})[/-](\d+),) {
91                            ($yyyy,$mm) = $mws->fmtdate($1,$2);
92                            $date_limit = "$yyyy-$mm";
93                    } elsif ($url =~ m,^/(\d{4}),) {
94                            $date_limit = $mws->fmtdate($1);
95                    }
96    
97                  #                  #
98                  # implement functionality and generate HTML                  # implement functionality and generate HTML
99                  #                  #
# Line 88  while ( my $c = $d->accept ) { Line 106  while ( my $c = $d->accept ) {
106                  }                  }
107    
108                  my $tpl_var = {                  my $tpl_var = {
109                          param   => $param                          param   => $param,
110                            yyyy    => $yyyy,
111                            mm      => $mm,
112                            dd      => $dd,
113                            date_limit => $date_limit,
114                  };                  };
115    
                 # show search results  
                 # ?search=foo:bar  
                 if ($param->{'search'}) {  
   
                         print STDERR "search: ",$param->{'search'},"\n";  
   
                         my $results = $mws->search($param->{'search'});  
                         my @res = $mws->fetch_all_results();  
   
                         $tpl_var->{results} = \@res;  
                         $tpl_var->{total_hits} = $mws->{total_hits};  
   
   
116                  #                  #
117                  # ?show_id=XXXXxxxx___message_id___xxxxXXXX                  # ?show_id=XXXXxxxx___message_id___xxxxXXXX
118                  } elsif ($param->{'show_id'}) {                  if ($param->{'show_id'}) {
119    
120                          $mws->reset_counters;                          $mws->reset_counters;
121                          my $row = $mws->fetch_result_by_id($param->{'show_id'});                          my $row = $mws->fetch_result_by_id($param->{'show_id'});
122                          $tpl_var->{message} = $row;                          $tpl_var->{message} = $row;
123                    } elsif ($param->{'search'} || $date_limit) {
124    
125                            # show search results
126                            # ?search=foo:bar
127    
128                            my @search = ( $param->{'search'} );
129    
130                            if ($date_limit) {
131                                    push @search, "and" if (@search);
132                                    push @search, "date:\"$date_limit\"";
133                            }
134    
135                            print STDERR "search: ",join(" ",@search),"\n";
136    
137                            my $results = $mws->search(@search);
138                            my @res = $mws->fetch_all_results();
139    
140                            $tpl_var->{results} = \@res if (@res);
141                            $tpl_var->{total_hits} = $mws->{total_hits};
142    
143                  }                  }
144    
 print Dumper($mws->{counter});  
145    
146                  # push counters to template                  # push counters to template
147                  foreach my $f (qw(from to cc bcc)) {                  foreach my $f (qw(from to cc bcc)) {
# Line 125  print Dumper($mws->{counter}); Line 153  print Dumper($mws->{counter});
153                          $tpl_var->{counters}->{$f} = [ @a ] if (@a);                          $tpl_var->{counters}->{$f} = [ @a ] if (@a);
154                  }                  }
155    
156                    # push calendar in template
157                    $tpl_var->{calendar} = $mws->counter('calendar');
158    
159                  $tt->process($tpl_file, $tpl_var, \$html) || die $tt->error();                  $tt->process($tpl_file, $tpl_var, \$html) || die $tt->error();
160    
161                  #                  #

Legend:
Removed from v.19  
changed lines
  Added in v.21

  ViewVC Help
Powered by ViewVC 1.1.26