14 |
|
|
15 |
use Data::Dumper; |
use Data::Dumper; |
16 |
|
|
17 |
|
my $debug = 1; |
18 |
|
|
19 |
my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 6969 ) || die; |
my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 6969 ) || die; |
20 |
my $cgi = new CGI::Lite; |
my $cgi = new CGI::Lite; |
21 |
my $mws = MWS->new('global.conf'); |
my $mws = MWS->new('global.conf'); |
23 |
INCLUDE_PATH => $mws->{config}->val('global', 'templates'), |
INCLUDE_PATH => $mws->{config}->val('global', 'templates'), |
24 |
FILTERS => { |
FILTERS => { |
25 |
'body5' => \&body5_filter, |
'body5' => \&body5_filter, |
26 |
|
'subject_search' => \&subject_search_filter, |
27 |
}, |
}, |
28 |
}); |
}); |
29 |
|
|
70 |
my $url = $r->url->path; |
my $url = $r->url->path; |
71 |
|
|
72 |
# XXX LOG |
# XXX LOG |
73 |
print $r->method," ",$url,Dumper($param); |
print $r->method," ",$url,"\n",Dumper($param),"\n" if ($debug); |
74 |
|
|
75 |
# template file name (use ?format=html as default) |
# template file name (use ?format=html as default) |
76 |
my $tpl_file = 'master.'; |
my $tpl_file = 'master.'; |
83 |
|
|
84 |
if ($param->{'search_val'} && $param->{'search_fld'} && !$param->{'search'}) { |
if ($param->{'search_val'} && $param->{'search_fld'} && !$param->{'search'}) { |
85 |
$param->{'search'} = $param->{'search_fld'}.":".$param->{'search_val'}; |
$param->{'search'} = $param->{'search_fld'}.":".$param->{'search_val'}; |
86 |
|
} elsif ($param->{'search'}) { |
87 |
|
($param->{'search_fld'}, $param->{'search_val'}) = split(/:/,$param->{'search'},2); |
88 |
} |
} |
89 |
|
|
90 |
my $tpl_var = { |
my $tpl_var = { |
101 |
my @res = $mws->fetch_all_results(); |
my @res = $mws->fetch_all_results(); |
102 |
|
|
103 |
$tpl_var->{results} = \@res; |
$tpl_var->{results} = \@res; |
104 |
|
$tpl_var->{total_hits} = $mws->{total_hits}; |
105 |
|
|
106 |
|
|
107 |
# |
# |
119 |
# |
# |
120 |
|
|
121 |
my $res = HTTP::Response->new(RC_OK); |
my $res = HTTP::Response->new(RC_OK); |
122 |
$res->header( 'Content-type' => 'text/html; charset=UTF-8' ); |
$res->header( 'Content-type' => 'text/html; charset=ISO-8859-2' ); |
123 |
$res->content($html); |
$res->content($html); |
124 |
$c->send_response($res); |
$c->send_response($res); |
125 |
|
|
137 |
$text =~ s/^\s+//gs; |
$text =~ s/^\s+//gs; |
138 |
$text =~ s/^[\>:\|=]+\s*.*?$//msg; # remove quoted text |
$text =~ s/^[\>:\|=]+\s*.*?$//msg; # remove quoted text |
139 |
$text =~ s/[\n\r]+/\n/gs; # compress cr/lf |
$text =~ s/[\n\r]+/\n/gs; # compress cr/lf |
140 |
$text =~ s,^((?:.*?[\n\r]){5}).*$,$1<span style="color:#808080">--8<--[cut]--8<--</span>,s; |
if ($text =~ s,^((?:.*?[\n\r]){5}).*$,$1,s) { |
141 |
|
$text =~ s/[\n\r]*$/ .../; |
142 |
|
} |
143 |
$text =~ s/[\n\r]+--\s*[\n\r]+.*$//s; |
$text =~ s/[\n\r]+--\s*[\n\r]+.*$//s; |
144 |
|
|
145 |
# my $context = Text::Context::EitherSide->new($text, context => 5); |
# my $context = Text::Context::EitherSide->new($text, context => 5); |
148 |
return $text; |
return $text; |
149 |
} |
} |
150 |
|
|
151 |
|
sub subject_search_filter { |
152 |
|
my $s = shift; |
153 |
|
# remove re: fdw: [list] preffixes from e-mail |
154 |
|
while ( $s =~ s/^\s*\[(?:re|fwd|fw):\s+(.+)\]\s*$/$1/ig || |
155 |
|
$s =~ s/^\s*(?:re|fwd|fw):\s+(.+?)\s*$/$1/ig || |
156 |
|
$s =~ s/^\[\S+\]\s*//ig || |
157 |
|
$s =~ s/^\[[^@]+@\w+\.\w+\s*:\s+(.+)\s*\]\s*$/$1/g |
158 |
|
) { }; |
159 |
|
return $s; |
160 |
|
} |