]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: simplify eml_entry callers further
authorEric Wong <e@yhbt.net>
Sun, 5 Jul 2020 23:27:54 +0000 (23:27 +0000)
committerEric Wong <e@yhbt.net>
Mon, 6 Jul 2020 20:01:15 +0000 (20:01 +0000)
This simplifies the primary callers of eml_entry while only making
mknews.perl worse.

Documentation/mknews.perl
lib/PublicInbox/Feed.pm
lib/PublicInbox/SearchView.pm
lib/PublicInbox/View.pm

index 4a5d0e563bc425a9539349c761059cbc12aa48f9..f053e2bfb9e558541778762a4d6b3b79bd0b633d 100755 (executable)
@@ -105,7 +105,8 @@ sub mime2html {
        my ($out, $eml, $ctx) = @_;
        my $smsg = $ctx->{smsg} = bless {}, 'PublicInbox::Smsg';
        $smsg->populate($eml);
-       print $out PublicInbox::View::eml_entry($ctx, $eml, 1) or die;
+       $ctx->{msgs} = [ 1 ]; # for <hr> in eml_entry
+       print $out PublicInbox::View::eml_entry($ctx, $eml) or die;
 }
 
 sub html_start {
index 476d946f515d2882e881d61ab3c0117c38042721..bf095a2cc8e3f7540e4baa66a792781956617431 100644 (file)
@@ -51,8 +51,7 @@ sub new_html_i {
        my ($ctx, $eml) = @_;
        $ctx->zmore($ctx->html_top) if exists $ctx->{-html_tip};
 
-       $eml and return PublicInbox::View::eml_entry($ctx, $eml,
-                                               scalar @{$ctx->{msgs}});
+       $eml and return PublicInbox::View::eml_entry($ctx, $eml);
        my $smsg = shift @{$ctx->{msgs}} or
                $ctx->zmore(PublicInbox::View::pagination_footer(
                                                $ctx, './new.html'));
index 623b16fb22cd0d6282d01d001a16dd367531080e..84c04c6c4713923d73f5ed5cb856e8720d19c3df 100644 (file)
@@ -294,8 +294,7 @@ sub mset_thread {
 sub mset_thread_i {
        my ($ctx, $eml) = @_;
        $ctx->zmore($ctx->html_top) if exists $ctx->{-html_tip};
-       $eml and return PublicInbox::View::eml_entry($ctx, $eml,
-                                               scalar @{$ctx->{msgs}});
+       $eml and return PublicInbox::View::eml_entry($ctx, $eml);
        my $smsg = shift @{$ctx->{msgs}} or
                $ctx->zmore(${delete($ctx->{skel})});
        $smsg;
index 60dad6bac0ec96679c0fb81b91f4f4a6824b73e9..d7ec4eb0a1a63f2500b911eaa4638bd7565e21a3 100644 (file)
@@ -176,7 +176,7 @@ sub fmt_ts ($) { strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
 # Displays the text of of the message for /$INBOX/$MSGID/[Tt]/ endpoint
 # this is already inside a <pre>
 sub eml_entry {
-       my ($ctx, $eml, $more) = @_;
+       my ($ctx, $eml) = @_;
        my $smsg = delete $ctx->{smsg};
        my $subj = delete $smsg->{subject};
        my $mid_raw = $smsg->{mid};
@@ -267,7 +267,8 @@ sub eml_entry {
                $hr = $ctx->{-hr};
        }
 
-       $rv .= $more ? '</pre><hr><pre>' : '</pre>' if $hr;
+       # do we have more messages? start a new <pre> if so
+       $rv .= scalar(@{$ctx->{msgs}}) ? '</pre><hr><pre>' : '</pre>' if $hr;
        $rv;
 }
 
@@ -368,7 +369,7 @@ sub pre_thread  { # walk_thread callback
 sub thread_eml_entry {
        my ($ctx, $eml) = @_;
        my ($beg, $end) = thread_adj_level($ctx, $ctx->{level});
-       $beg . '<pre>' . eml_entry($ctx, $eml, 0) . '</pre>' . $end;
+       $beg . '<pre>' . eml_entry($ctx, $eml) . '</pre>' . $end;
 }
 
 sub next_in_queue ($$) {
@@ -463,7 +464,7 @@ sub thread_html_i { # PublicInbox::WwwStream::getline callback
                        $ctx->{-title_html} = ascii_html($smsg->{subject});
                        $ctx->zmore($ctx->html_top);
                }
-               return eml_entry($ctx, $eml, scalar @{$ctx->{msgs}});
+               return eml_entry($ctx, $eml);
        } else {
                while (my $smsg = shift @{$ctx->{msgs}}) {
                        return $smsg if exists($smsg->{blob});