--- trunk/httpd.pl 2004/05/05 13:42:27 6 +++ trunk/httpd.pl 2004/05/05 15:38:35 7 @@ -69,29 +69,44 @@ # XXX LOG print $r->method," ",$url,Dumper($param); - # generate HTML + # template file name (use ?format=html as default) + my $tpl_file = 'master.'; + $tpl_file .= $param->{'format'} || 'html'; + + # + # implement functionality and generate HTML + # my $html; - my $s=$param->{'search'}; + # show search results + # ?search=foo:bar + if ($param->{'search'}) { - if ($s) { - - print STDERR "search: $s\n"; - - my $results = $mws->search($s); + print STDERR "search: ",$param->{'search'},"\n"; + my $results = $mws->search($param->{'search'}); my @res = $mws->fetch_all_results(); - my $tpl_file = 'master.'; - $tpl_file .= $param->{'format'} || 'html'; - $tt->process($tpl_file, { - query => $s, + query => $param->{'search'}, results => \@res, param => $param, }, \$html) || die $tt->error(); + + # + # ?show_id=XXXXxxxx___message_id___xxxxXXXX + } elsif ($param->{'show_id'}) { + + my $row = $mws->fetch_result_by_id($param->{'show_id'}); + $tt->process($tpl_file, { + message => $row, + }, \$html) || die $tt->error(); } + # + # send HTMLto client + # + my $res = HTTP::Response->new(RC_OK); $res->header( 'Content-type' => 'text/html; charset=iso-8859-2' ); $res->content($html); @@ -107,6 +122,9 @@ sub body5_filter { my $text = shift; $text =~ s/^\s+//gs; - $text =~ s/^(.*?[\n\r]+){5}.*$/$1/s; + $text =~ s/[\n\r]+[\>:\|=]+\s*.*?[\n\r]+//sg; # remove quoted text + $text =~ s,^((?:.*?[\n\r]){5}).*$,$1--8<--[cut]--8<--,s; + $text =~ s/[\n\r]+--\s*[\n\r]+.*$//s; return $text; } +