--- trunk/httpd.pl 2004/05/08 22:18:38 28 +++ trunk/httpd.pl 2004/05/09 00:09:32 30 @@ -85,7 +85,8 @@ my $url = $r->url->path; # XXX LOG - print $r->method," ",$url,"\n",Dumper($param),"\n" if ($debug); + print $r->method," ",$url,"\n"; + print Dumper($param),"\n" if ($debug); # is this static page? if ($static_html && -f "$static_html/$url") { @@ -173,6 +174,11 @@ $tpl_var->{results} = \@res if (@res); $tpl_var->{total_hits} = $mws->{total_hits} || 0; + # no hits, offer suggestions + if (! $tpl_var->{results}) { + @{$tpl_var->{apropos}} = $mws->apropos_index($param->{'search_fld'}, $param->{'search_val'}); + } + } @@ -208,7 +214,10 @@ # template toolkit filter sub html_escape($) { - my $text = shift; + my $text = shift || return; + + # don't re-escape html + #return $text if ($text =~ /&(:?lt|gt|amp|quot);/); # Escape <, >, & and ", and to produce valid XML my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); @@ -228,6 +237,7 @@ # remove quote author $text =~ s/[\n\r]+[^\n\r]+:\s*(:?#-q-#[\n\r*])+//gs; $text =~ s/^[^\n\r]+:\s*(:?#-q-#[\n\r]*)+//gs; + $text =~ s/#-q-#[\n\r]*//gs; # outlook quoting $text =~ s/(\s*--+\s*Original\s+Message\s*--+.*)$//si; $text =~ s/(\s*--+\s*Forwarded\s+message\s*from\s+.+\s*--+.*)$//si; @@ -264,11 +274,12 @@ } # find quoted text - $text =~ s/^([\>:\|=]+\s*.*?)$/#-#quote##$1##quote#-#/msg; - $text =~ s/(--+\s*Original\s+Message\s*--+.*)$/#-#quote##$1##quote#-#/si || $text =~ s/(--+\s*Forwarded\s+message\s*from\s+.+\s*--+.*)$/#-#quote##$1##quote#-#/si; + $text =~ s/^([\>:\|=]+\s*.*?)$/#-#quote1##$1##quote1#-#/msg; + $text =~ s/(--+\s*Original\s+Message\s*--+.*)$/#-#quote2##$1##quote2#-#/si; + $text =~ s/(--+\s*Forwarded\s+message\s*from\s+.+\s*--+.*)$/#-#quote3##$1##quote3#-#/si; $text = html_escape($text . $sig); - $text =~ s/#-#(quote|signature)##(.+?)##(\1)#-#/$2<\/span>/gs; + while ($text =~ s/#-#(quote|signature)(\d*)##(.+?)##\1\2#-#/$3<\/span>/gs) { } ; return $text; }