--- trunk/httpd.pl 2004/05/07 11:25:01 17 +++ trunk/httpd.pl 2004/05/07 23:35:39 20 @@ -25,6 +25,7 @@ 'body5' => \&body5_filter, 'subject_search' => \&subject_search_filter, }, + EVAL_PERL => 1, }); print "Web server ready at: ", $d->url, "\n"; @@ -76,6 +77,23 @@ my $tpl_file = 'master.'; $tpl_file .= $param->{'format'} || 'html'; + # parse date from url + my ($yyyy,$mm,$dd) = $mws->yyyymmdd; + + my $yyyymm; + + my $date_limit; + + if ($url =~ m,^/(\d{4})[/-](\d+)[/-](\d+),) { + ($yyyy, $mm, $dd) = $mws->fmtdate($1,$2,$3); + $date_limit = "$yyyy-$mm-$dd"; + } elsif ($url =~ m,^/(\d{4})[/-](\d+),) { + ($yyyy,$mm) = $mws->fmtdate($1,$2); + $date_limit = "$yyyy-$mm"; + } elsif ($url =~ m,^/(\d{4}),) { + $date_limit = $mws->fmtdate($1); + } + # # implement functionality and generate HTML # @@ -88,9 +106,17 @@ } my $tpl_var = { - param => $param + param => $param, + yyyy => $yyyy, + mm => $mm, + dd => $dd, }; + if ($date_limit) { + $param->{'search'} .= "and " if ($param->{'search'}); + $param->{'search'} .= $date_limit; + } + # show search results # ?search=foo:bar if ($param->{'search'}) { @@ -100,18 +126,34 @@ my $results = $mws->search($param->{'search'}); my @res = $mws->fetch_all_results(); - $tpl_var->{results} = \@res; + $tpl_var->{results} = \@res if (@res); $tpl_var->{total_hits} = $mws->{total_hits}; # # ?show_id=XXXXxxxx___message_id___xxxxXXXX } elsif ($param->{'show_id'}) { - + + $mws->reset_counters; my $row = $mws->fetch_result_by_id($param->{'show_id'}); $tpl_var->{message} = $row; } +print Dumper($mws->{counter}); + + # push counters to template + foreach my $f (qw(from to cc bcc)) { + my $h = $mws->counter($f) || next; + my @a; + foreach my $k (sort { $h->{$b}->{usage} <=> $h->{$a}->{usage} } keys %$h) { + push @a, $h->{$k}; + } + $tpl_var->{counters}->{$f} = [ @a ] if (@a); + } + + # push calendar in template + $tpl_var->{calendar} = $mws->counter('calendar'); + $tt->process($tpl_file, $tpl_var, \$html) || die $tt->error(); # @@ -154,7 +196,9 @@ while ( $s =~ s/^\s*\[(?:re|fwd|fw):\s+(.+)\]\s*$/$1/ig || $s =~ s/^\s*(?:re|fwd|fw):\s+(.+?)\s*$/$1/ig || $s =~ s/^\[\S+\]\s*//ig || - $s =~ s/^\[[^@]+@\w+\.\w+\s*:\s+(.+)\s*\]\s*$/$1/g + $s =~ s/^\[[^@]+@\w+\.\w+\s*:\s+(.+)\s*\]\s*$/$1/g || + $s =~ s/\(fwd\)\s*$//ig || + $s =~ s/\"//g ) { }; return $s; }