69 |
# XXX LOG |
# XXX LOG |
70 |
print $r->method," ",$url,Dumper($param); |
print $r->method," ",$url,Dumper($param); |
71 |
|
|
72 |
# generate HTML |
# template file name (use ?format=html as default) |
73 |
|
my $tpl_file = 'master.'; |
74 |
|
$tpl_file .= $param->{'format'} || 'html'; |
75 |
|
|
76 |
|
# |
77 |
|
# implement functionality and generate HTML |
78 |
|
# |
79 |
my $html; |
my $html; |
80 |
|
|
81 |
my $s=$param->{'search'}; |
# show search results |
82 |
|
# ?search=foo:bar |
83 |
|
if ($param->{'search'}) { |
84 |
|
|
85 |
if ($s) { |
print STDERR "search: ",$param->{'search'},"\n"; |
|
|
|
|
print STDERR "search: $s\n"; |
|
|
|
|
|
my $results = $mws->search($s); |
|
86 |
|
|
87 |
|
my $results = $mws->search($param->{'search'}); |
88 |
my @res = $mws->fetch_all_results(); |
my @res = $mws->fetch_all_results(); |
89 |
|
|
|
my $tpl_file = 'master.'; |
|
|
$tpl_file .= $param->{'format'} || 'html'; |
|
|
|
|
90 |
$tt->process($tpl_file, { |
$tt->process($tpl_file, { |
91 |
query => $s, |
query => $param->{'search'}, |
92 |
results => \@res, |
results => \@res, |
93 |
param => $param, |
param => $param, |
94 |
}, \$html) || die $tt->error(); |
}, \$html) || die $tt->error(); |
95 |
|
|
96 |
|
# |
97 |
|
# ?show_id=XXXXxxxx___message_id___xxxxXXXX |
98 |
|
} elsif ($param->{'show_id'}) { |
99 |
|
|
100 |
|
my $row = $mws->fetch_result_by_id($param->{'show_id'}); |
101 |
|
$tt->process($tpl_file, { |
102 |
|
message => $row, |
103 |
|
}, \$html) || die $tt->error(); |
104 |
} |
} |
105 |
|
|
106 |
|
# |
107 |
|
# send HTMLto client |
108 |
|
# |
109 |
|
|
110 |
my $res = HTTP::Response->new(RC_OK); |
my $res = HTTP::Response->new(RC_OK); |
111 |
$res->header( 'Content-type' => 'text/html; charset=iso-8859-2' ); |
$res->header( 'Content-type' => 'text/html; charset=iso-8859-2' ); |
112 |
$res->content($html); |
$res->content($html); |
122 |
sub body5_filter { |
sub body5_filter { |
123 |
my $text = shift; |
my $text = shift; |
124 |
$text =~ s/^\s+//gs; |
$text =~ s/^\s+//gs; |
125 |
$text =~ s/^(.*?[\n\r]+){5}.*$/$1/s; |
$text =~ s/[\n\r]+[\>:\|=]+\s*.*?[\n\r]+//sg; # remove quoted text |
126 |
|
$text =~ s,^((?:.*?[\n\r]){5}).*$,$1<span style="color:#808080">--8<--[cut]--8<--</span>,s; |
127 |
|
$text =~ s/[\n\r]+--\s*[\n\r]+.*$//s; |
128 |
return $text; |
return $text; |
129 |
} |
} |
130 |
|
|