/[mws]/trunk/mbox2index.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/mbox2index.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (show annotations)
Thu May 6 12:40:11 2004 UTC (20 years ago) by dpavlin
Original Path: trunk/mbox2swish.pl
File MIME type: text/plain
File size: 1707 byte(s)
switch search engine to swish-e. It's stil slow, but usable.

1 #!/usr/bin/perl -w
2
3 use MWS;
4 use Data::Dumper;
5 use XML::Simple;
6 use Text::Iconv;
7
8 my $iso2utf = Text::Iconv->new('ISO-8859-2','UTF-8');
9
10 my $mws = MWS->new('global.conf');
11
12 my $debug = 1;
13
14 foreach my $mbox ($mws->{config}->Parameters('folders')) {
15 my $mbox_path = $mws->{config}->val('folders', $mbox);
16
17 print STDERR "working on $mbox [$mbox_path]\n" if ($debug);
18
19 my $folder = $mws->open_folder($mbox);
20
21 foreach my $message ($folder->messages) {
22
23 my $id = $message->messageId;
24 print STDERR "## $id\n";
25
26 my $document = {
27 id => $id,
28 folder => $mbox,
29 };
30
31 foreach my $direction (qw(to from cc bcc)) {
32 foreach my $f ($message->$direction) {
33 # print STDERR "$direction: ";
34 foreach my $part (qw(phrase address comment)) {
35 next if (! $f->$part);
36 # print STDERR "[$part]",$f->$part," ";
37 $document->{$direction.'_'.$part} .= $f->$part."\n";
38 }
39 # print STDERR "\n";
40 # push @{$document->$d.'_phrase'}, $f->phrase,
41 # push @{$document->$d.'_address'}, $f->address,
42 ## push @{$document->$d.'_comment'}, $f->comment,
43 }
44 }
45
46 $document->{'subject'} = $message->get('Subject') || 'no subject';
47 $document->{'body'} = $mws->plain_text_body($message);
48
49 # print Dumper($document);
50 # $mws->add_index("$mbox $id" => $document);
51
52 # my $xml = XMLout($document);
53
54 my $xml = qq{<message>};
55 foreach my $tag (keys %$document) {
56 $xml .= "<$tag><![CDATA[".$document->{$tag}."]]></$tag>\n";
57 }
58 $xml .= qq{</message>};
59
60 $xml = $iso2utf->convert($xml);
61 use bytes; # as opposed to chars
62 print "Path-Name: $mbox $id\n";
63 print "Content-Length: ".(length($xml)+1)."\n";
64 print "Document-Type: XML\n\n$xml\n";
65
66 }
67
68 $folder->close;
69 }
70
71 $mws->close_index;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26