X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=lib%2FPublicInbox%2FView.pm;h=fa96cca337d87f9113425a209c5b78aafa2b6dfa;hp=c80a675efedca05e527fa8c6cf536b0675aab7a5;hb=4eee5af6011cc8cdefb66c9729952c7eff5c0b0b;hpb=7057307e044b0b63e2517e125c0f971630966072 diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index c80a675e..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 @@ -32,7 +31,9 @@ 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); @@ -71,7 +72,7 @@ sub msg_page { my ($ctx) = @_; my $ibx = $ctx->{ibx}; $ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef; - my $over = $ctx->{over} = $ibx->over or return no_over_html($ctx); + my $over = $ibx->over or return no_over_html($ctx); my ($id, $prev); my $next_arg = $ctx->{next_arg} = [ $ctx->{mid}, \$id, \$prev ]; @@ -141,6 +142,9 @@ $info $se_url $link + + Be sure your reply has a Subject: header at the top and a blank line + before the message body. EOF } @@ -259,7 +263,6 @@ sub eml_entry { } elsif ($mapping) { my $nested = 'nested'; my $flat = 'flat'; - my $end = ''; if ($ctx->{flat}) { $hr = 1; $flat = "$flat"; @@ -433,6 +436,7 @@ sub stream_thread ($$) { # /$INBOX/$MSGID/t/ and /$INBOX/$MSGID/T/ sub thread_html { my ($ctx) = @_; + $ctx->{-upfx} = '../../'; my $mid = $ctx->{mid}; my $ibx = $ctx->{ibx}; my ($nr, $msgs) = $ibx->over->get_thread($mid); @@ -456,7 +460,6 @@ EOF $skel .= " (download: mbox.gz"; $skel .= " / follow: Atom feed)\n"; $skel .= "-- links below jump to the message on this page --\n"; - $ctx->{-upfx} = '../../'; $ctx->{cur_level} = 0; $ctx->{skel} = \$skel; $ctx->{prev_attr} = ''; @@ -531,7 +534,8 @@ sub attach_link ($$$$;$) { return unless $part->{bdy}; my $nl = $idx eq '1' ? '' : "\n"; # like join("\n", ...) - my $size = bytes::length($part->body); + my $size = length($part->body); + delete $part->{bdy}; # save memory # hide attributes normally, unless we want to aid users in # spotting MUA problems: @@ -584,7 +588,7 @@ sub add_text_body { # callback for each_part # makes no difference to browsers, and don't screw up filename # link generation in diffs with the extra '%0D' - $s =~ s/\r\n/\n/sg; + $s =~ s/\r+\n/\n/sg; # will be escaped to `•' in HTML obfuscate_addrs($ibx, $s, "\x{2022}") if $ibx->{obfuscate}; @@ -623,9 +627,6 @@ sub add_text_body { # callback for each_part $ctx->{-spfx} = $spfx; }; - # some editors don't put trailing newlines at the end: - $s .= "\n" unless $s =~ /\n\z/s; - # split off quoted and unquoted blocks: my @sections = PublicInbox::MsgIter::split_quotes($s); undef $s; # free memory @@ -634,6 +635,7 @@ sub add_text_body { # callback for each_part attach_link($ctx, $ct, $p, $fn, $err); $$rv .= "\n"; } + delete $part->{bdy}; # save memory foreach my $cur (@sections) { if ($cur =~ /\A>/) { # we use a here to allow users to specify @@ -978,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; @@ -1073,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 @@ -1154,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