X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=lib%2FPublicInbox%2FView.pm;h=fa96cca337d87f9113425a209c5b78aafa2b6dfa;hp=f4f6da1128cb7591c971baa6483a73deea52c16e;hb=4eee5af6011cc8cdefb66c9729952c7eff5c0b0b;hpb=a5968dc059f655a9ac62f1b8bf0bed2b90080b02 diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index f4f6da11..fa96cca3 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -5,8 +5,7 @@ # See Documentation/design_www.txt for this. package PublicInbox::View; use strict; -use warnings; -use bytes (); # only for bytes::length +use v5.10.1; use List::Util qw(max); use PublicInbox::MsgTime qw(msg_datestamp); use PublicInbox::Hval qw(ascii_html obfuscate_addrs prurl mid_href @@ -22,6 +21,7 @@ use PublicInbox::ViewDiff qw(flush_diff); use PublicInbox::Eml; use Time::Local qw(timegm); use PublicInbox::Smsg qw(subject_normalized); +use PublicInbox::ContentHash qw(content_hash); use constant COLS => 72; use constant INDENT => ' '; use constant TCHILD => '` '; @@ -31,13 +31,17 @@ sub msg_page_i { my ($ctx, $eml) = @_; if ($eml) { # called by WwwStream::async_eml or getline my $smsg = $ctx->{smsg}; - $ctx->{smsg} = $ctx->{over}->next_by_mid(@{$ctx->{next_arg}}); + my $over = $ctx->{ibx}->over; + $ctx->{smsg} = $over ? $over->next_by_mid(@{$ctx->{next_arg}}) + : $ctx->gone('over'); $ctx->{mhref} = ($ctx->{nr} || $ctx->{smsg}) ? "../${\mid_href($smsg->{mid})}/" : ''; my $obuf = $ctx->{obuf} = _msg_page_prepare_obuf($eml, $ctx); - multipart_text_as_html($eml, $ctx); + if (length($$obuf)) { + multipart_text_as_html($eml, $ctx); + $$obuf .= '
WARNING: multiple messages have this Message-ID\n"; $rv .= '
'; } else { $ctx->{first_hdr} = $eml->header_obj; - if ($ctx->{smsg}) { - $rv .= -"WARNING: multiple messages have this Message-ID\n"; - } + $ctx->{chash} = content_hash($eml) if $ctx->{smsg}; # reused MID $rv .= ""; # anchor for body start } $ctx->{-upfx} = '../' if $over; @@ -694,7 +712,7 @@ sub _msg_page_prepare_obuf { for my $v ($eml->header('Date')) { $v = ascii_html($v); obfuscate_addrs($obfs_ibx, $v) if $obfs_ibx; # possible :P - $rv .= "Date: $v\n"; + $rv .= qq{Date: $v\t[thread overview]\n}; } if (!$nr) { # first (and only) message, common case $ctx->{-title_html} = join(' - ', @title); @@ -739,7 +757,8 @@ sub thread_skel ($$$) { $$skel .= SKEL_EXPAND."\n "; $$skel .= ghost_parent('../', $parent) . "\n"; } else { - $$skel .= '[no followups] '.SKEL_EXPAND."\n"; + $$skel .= "[no followups] ". + SKEL_EXPAND."\n"; } $ctx->{next_msg} = undef; $ctx->{parent_msg} = $parent; @@ -860,11 +879,6 @@ sub linkify_ref_no_over { "<$html>"; } -sub anchor_for { - my ($msgid) = @_; - 'm' . id_compress($msgid, 1); -} - sub ghost_parent { my ($upfx, $mid) = @_; @@ -966,7 +980,7 @@ sub skel_dump { # walk_thread callback $$skel .= delete($ctx->{sl_note}) || ''; } - my $f = ascii_html($smsg->{from_name}); + my $f = ascii_html(delete $smsg->{from_name}); my $obfs_ibx = $ctx->{-obfs_ibx}; obfuscate_addrs($obfs_ibx, $f) if $obfs_ibx; @@ -1061,10 +1075,10 @@ sub _skel_ghost { } sub sort_ds { - [ sort { + @{$_[0]} = sort { (eval { $a->topmost->{ds} } || 0) <=> (eval { $b->topmost->{ds} } || 0) - } @{$_[0]} ]; + } @{$_[0]}; } # accumulate recent topics if search is supported @@ -1142,10 +1156,8 @@ sub dump_topics { $anchor = '#t'; # thread skeleton } - my $mbox = qq(mbox.gz); - my $atom = qq(Atom); my $s = "$top_subj\n" . - " $ds UTC $n - $mbox / $atom\n"; + " $ds UTC $n\n"; for (my $i = 0; $i < scalar(@extra); $i += 2) { my $level = $extra[$i]; my $subj = $extra[$i + 1]; # already normalized @@ -1265,7 +1277,7 @@ sub thread_adj_level { sub ghost_index_entry { my ($ctx, $level, $node) = @_; my ($beg, $end) = thread_adj_level($ctx, $level); - $beg . ''. ghost_parent($ctx->{-upfx}, $node->{mid}) + $beg . ''. ghost_parent($ctx->{-upfx}, $node->{mid} // '?') . '' . $end; }