85 |
my $url = $r->url->path; |
my $url = $r->url->path; |
86 |
|
|
87 |
# XXX LOG |
# XXX LOG |
88 |
print $r->method," ",$url,"\n",Dumper($param),"\n" if ($debug); |
print $r->method," ",$url,"\n"; |
89 |
|
print Dumper($param),"\n" if ($debug); |
90 |
|
|
91 |
# is this static page? |
# is this static page? |
92 |
if ($static_html && -f "$static_html/$url") { |
if ($static_html && -f "$static_html/$url") { |
174 |
$tpl_var->{results} = \@res if (@res); |
$tpl_var->{results} = \@res if (@res); |
175 |
$tpl_var->{total_hits} = $mws->{total_hits} || 0; |
$tpl_var->{total_hits} = $mws->{total_hits} || 0; |
176 |
|
|
177 |
|
# no hits, offer suggestions |
178 |
|
if (! $tpl_var->{results}) { |
179 |
|
@{$tpl_var->{apropos}} = $mws->apropos_index($param->{'search_fld'}, $param->{'search_val'}); |
180 |
|
} |
181 |
|
|
182 |
} |
} |
183 |
|
|
184 |
|
|
214 |
# template toolkit filter |
# template toolkit filter |
215 |
|
|
216 |
sub html_escape($) { |
sub html_escape($) { |
217 |
my $text = shift; |
my $text = shift || return; |
218 |
|
|
219 |
|
# don't re-escape html |
220 |
|
#return $text if ($text =~ /&(:?lt|gt|amp|quot);/); |
221 |
|
|
222 |
# Escape <, >, & and ", and to produce valid XML |
# Escape <, >, & and ", and to produce valid XML |
223 |
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); |
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); |
237 |
# remove quote author |
# remove quote author |
238 |
$text =~ s/[\n\r]+[^\n\r]+:\s*(:?#-q-#[\n\r*])+//gs; |
$text =~ s/[\n\r]+[^\n\r]+:\s*(:?#-q-#[\n\r*])+//gs; |
239 |
$text =~ s/^[^\n\r]+:\s*(:?#-q-#[\n\r]*)+//gs; |
$text =~ s/^[^\n\r]+:\s*(:?#-q-#[\n\r]*)+//gs; |
240 |
|
$text =~ s/#-q-#[\n\r]*//gs; |
241 |
# outlook quoting |
# outlook quoting |
242 |
$text =~ s/(\s*--+\s*Original\s+Message\s*--+.*)$//si; |
$text =~ s/(\s*--+\s*Original\s+Message\s*--+.*)$//si; |
243 |
$text =~ s/(\s*--+\s*Forwarded\s+message\s*from\s+.+\s*--+.*)$//si; |
$text =~ s/(\s*--+\s*Forwarded\s+message\s*from\s+.+\s*--+.*)$//si; |
274 |
} |
} |
275 |
|
|
276 |
# find quoted text |
# find quoted text |
277 |
$text =~ s/^([\>:\|=]+\s*.*?)$/#-#quote##$1##quote#-#/msg; |
$text =~ s/^([\>:\|=]+\s*.*?)$/#-#quote1##$1##quote1#-#/msg; |
278 |
$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*Original\s+Message\s*--+.*)$/#-#quote2##$1##quote2#-#/si; |
279 |
|
$text =~ s/(--+\s*Forwarded\s+message\s*from\s+.+\s*--+.*)$/#-#quote3##$1##quote3#-#/si; |
280 |
|
|
281 |
$text = html_escape($text . $sig); |
$text = html_escape($text . $sig); |
282 |
$text =~ s/#-#(quote|signature)##(.+?)##(\1)#-#/<span class="$1">$2<\/span>/gs; |
while ($text =~ s/#-#(quote|signature)(\d*)##(.+?)##\1\2#-#/<span class="$1">$3<\/span>/gs) { } ; |
283 |
return $text; |
return $text; |
284 |
} |
} |
285 |
|
|