X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FSearchView.pm;h=4336e4d9b2d83ed289521450b0e958e0b1f762d0;hb=d0147582e289fdd4cdd84e91d8b0f8ae9c230124;hp=9b67b045c16eb0af177bb5f833dc5239f7bd0507;hpb=1fee6f86d7ee78161cc48a00232654f13a14bb88;p=public-inbox.git diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index 9b67b045..4336e4d9 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -6,7 +6,7 @@ package PublicInbox::SearchView; use strict; use warnings; use URI::Escape qw(uri_unescape uri_escape); -use PublicInbox::SearchMsg; +use PublicInbox::Smsg; use PublicInbox::Hval qw(ascii_html obfuscate_addrs mid_href); use PublicInbox::View; use PublicInbox::WwwAtomStream; @@ -100,7 +100,7 @@ sub mset_summary { foreach my $m ($mset->items) { my $rank = sprintf("%${pad}d", $m->get_rank + 1); my $pct = get_pct($m); - my $smsg = PublicInbox::SearchMsg::from_mitem($m, $srch); + my $smsg = PublicInbox::Smsg::from_mitem($m, $srch); unless ($smsg) { eval { $m = "$m ".$m->get_docid . " expired\n"; @@ -243,8 +243,8 @@ sub search_nav_bot { sub sort_relevance { [ sort { - (eval { $b->topmost->{smsg}->{pct} } // 0) <=> - (eval { $a->topmost->{smsg}->{pct} } // 0) + (eval { $b->topmost->{pct} } // 0) <=> + (eval { $a->topmost->{pct} } // 0) } @{$_[0]} ] } @@ -260,7 +260,7 @@ sub load_msgs { my ($mset) = @_; [ map { my $mi = $_; - my $smsg = PublicInbox::SearchMsg::from_mitem($mi); + my $smsg = PublicInbox::Smsg::from_mitem($mi); $smsg->{pct} = get_pct($mi); $smsg; } ($mset->items) ] @@ -268,7 +268,8 @@ sub load_msgs { sub mset_thread { my ($ctx, $mset, $q) = @_; - my $msgs = $ctx->{-inbox}->search->retry_reopen(\&load_msgs, $mset); + my $ibx = $ctx->{-inbox}; + my $msgs = $ibx->search->retry_reopen(\&load_msgs, $mset); my $r = $q->{r}; my $rootset = PublicInbox::SearchThread::thread($msgs, $r ? \&sort_relevance : \&PublicInbox::View::sort_ds, @@ -285,7 +286,7 @@ sub mset_thread { $ctx->{s_nr} = scalar(@$msgs).'+ results'; # reduce hash lookups in skel_dump - $ctx->{-obfuscate} = $ctx->{-inbox}->{obfuscate}; + $ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef; PublicInbox::View::walk_thread($rootset, $ctx, \&PublicInbox::View::pre_thread); @@ -337,7 +338,7 @@ sub adump_i { my ($ctx) = @_; while (my $mi = shift @{$ctx->{items}}) { my $smsg = eval { - PublicInbox::SearchMsg::from_mitem($mi, $ctx->{srch}); + PublicInbox::Smsg::from_mitem($mi, $ctx->{srch}); } or next; $ctx->{-inbox}->smsg_mime($smsg) and return $smsg; } @@ -365,14 +366,10 @@ sub new { } sub qs_html { - my ($self, %over) = @_; + my ($self, %override) = @_; - if (keys %over) { - my $tmp = bless { %$self }, ref($self); - foreach my $k (keys %over) { - $tmp->{$k} = $over{$k}; - } - $self = $tmp; + if (scalar(keys(%override))) { + $self = bless { (%$self, %override) }, ref($self); } my $q = uri_escape($self->{'q'}, MID_ESC);