/[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 20 by dpavlin, Fri May 7 23:35:39 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                  };                  };
114    
115                    if ($date_limit) {
116                            $param->{'search'} .= "and " if ($param->{'search'});
117                            $param->{'search'} .= $date_limit;
118                    }
119    
120                  # show search results                  # show search results
121                  # ?search=foo:bar                  # ?search=foo:bar
122                  if ($param->{'search'}) {                  if ($param->{'search'}) {
# Line 100  while ( my $c = $d->accept ) { Line 126  while ( my $c = $d->accept ) {
126                          my $results = $mws->search($param->{'search'});                          my $results = $mws->search($param->{'search'});
127                          my @res = $mws->fetch_all_results();                          my @res = $mws->fetch_all_results();
128    
129                          $tpl_var->{results} = \@res;                          $tpl_var->{results} = \@res if (@res);
130                          $tpl_var->{total_hits} = $mws->{total_hits};                          $tpl_var->{total_hits} = $mws->{total_hits};
131    
132    
# Line 125  print Dumper($mws->{counter}); Line 151  print Dumper($mws->{counter});
151                          $tpl_var->{counters}->{$f} = [ @a ] if (@a);                          $tpl_var->{counters}->{$f} = [ @a ] if (@a);
152                  }                  }
153    
154                    # push calendar in template
155                    $tpl_var->{calendar} = $mws->counter('calendar');
156    
157                  $tt->process($tpl_file, $tpl_var, \$html) || die $tt->error();                  $tt->process($tpl_file, $tpl_var, \$html) || die $tt->error();
158    
159                  #                  #

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

  ViewVC Help
Powered by ViewVC 1.1.26