lib/PublicInbox/SearchMsg.pm | 30 ++++++++++++++++++++++++++++-- lib/PublicInbox/View.pm | 87 +++++++++++++++++++++++++++++++++++++++++++++++++---- lib/PublicInbox/WWW.pm | 20 +++++++++++++++++--- diff --git a/lib/PublicInbox/SearchMsg.pm b/lib/PublicInbox/SearchMsg.pm index 619a19d4d76e2749f672c592621e760485ab17e9..550521aaed7fdf27fe7bf38599a28db8a16ef3af 100644 --- a/lib/PublicInbox/SearchMsg.pm +++ b/lib/PublicInbox/SearchMsg.pm @@ -6,9 +6,12 @@ use strict; use warnings; use Search::Xapian; use Email::Address qw//; +use Email::Simple qw//; use POSIX qw//; use Date::Parse qw/str2time/; use PublicInbox::MID qw/mid_clean mid_compressed/; +use Encode qw/find_encoding/; +my $enc_utf8 = find_encoding('UTF-8'); our $PFX2TERM_RE = undef; sub new { @@ -26,7 +29,9 @@ } sub load_doc { my ($class, $doc) = @_; - my ($mid, $subj, $from, $date) = split(/\n/, $doc->get_data); + my $data = $doc->get_data; + $data = $enc_utf8->decode($data); + my ($mid, $subj, $from, $date) = split(/\n/, $data); bless { doc => $doc, mid => $mid, @@ -52,11 +57,11 @@ my $from = $self->mime->header('From') || ''; my @from; if ($from) { + $from =~ tr/\n/ /; @from = Email::Address->parse($from); $self->{from} = $from[0]; $from = $from[0]->name; } - $from =~ tr/\n/ /; $self->{from_name} = $from; $self->{from}; } @@ -120,6 +125,27 @@ $self->{$field} = $val; } } } +} + +# for threading only +sub mini_mime { + my ($self) = @_; + $self->ensure_metadata; + my @h = ( + Subject => $self->subject, + 'X-PI-From' => $self->from_name, + 'X-PI-Date' => $self->date, + 'X-PI-TS' => $self->ts, + 'Message-ID' => "<$self->{mid}>", + ); + if (my $refs = $self->{references}) { + push @h, References => '<' . join('> <', @$refs) . '>'; + } + if (my $irt = $self->{inreplyto}) { + push @h, 'In-Reply-To' => "<$irt>"; + } + + Email::MIME->create(header_str => \@h); } sub mid { diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index c2dbb7ed42fd9d1048fd3491e6c2fbf705e4447f..fcc98ab80b60adf0f4dfd39ddcd408e44ff1bb15 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -22,7 +22,7 @@ my $enc_utf8 = find_encoding('UTF-8'); # public functions: sub msg_html { - my ($class, $mime, $full_pfx, $footer) = @_; + my ($class, $mime, $full_pfx, $footer, $srch) = @_; if (defined $footer) { $footer = "\n" . $footer; } else { @@ -31,7 +31,7 @@ } headers_to_html_header($mime, $full_pfx) . multipart_text_as_html($mime, $full_pfx) . '