]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/View.pm
wwwstream: shorten cloneurl uniquification
[public-inbox.git] / lib / PublicInbox / View.pm
index 5acd565a743543ef9db41e4716f1338a4dec71c8..d88b34da431f0975282993f885a6ab0ee44fa443 100644 (file)
@@ -16,7 +16,7 @@ use PublicInbox::Address;
 use PublicInbox::WwwStream;
 use PublicInbox::Reply;
 use PublicInbox::ViewDiff qw(flush_diff);
-require POSIX;
+use POSIX qw(strftime);
 use Time::Local qw(timegm);
 use PublicInbox::SearchMsg qw(subject_normalized);
 use constant COLS => 72;
@@ -208,6 +208,9 @@ sub nr_to_s ($$$) {
        $nr == 1 ? "$nr $singular" : "$nr $plural";
 }
 
+# human-friendly format
+sub fmt_ts ($) { strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
+
 # this is already inside a <pre>
 sub index_entry {
        my ($smsg, $ctx, $more) = @_;
@@ -272,7 +275,7 @@ sub index_entry {
        # scan through all parts, looking for displayable text
        $ctx->{mhref} = $mhref;
        $ctx->{rv} = \$rv;
-       msg_iter($mime, \&add_text_body, $ctx);
+       msg_iter($mime, \&add_text_body, $ctx, 1);
        delete $ctx->{rv};
 
        # add the footer
@@ -503,12 +506,12 @@ sub thread_html_i { # PublicInbox::WwwStream::getline callback
 }
 
 sub multipart_text_as_html {
-       my ($mime, $mhref, $ctx) = @_;
+       my (undef, $mhref, $ctx) = @_; # $mime = $_[0]
        $ctx->{mhref} = $mhref;
        $ctx->{rv} = \(my $rv = '');
 
        # scan through all parts, looking for displayable text
-       msg_iter($mime, \&add_text_body, $ctx);
+       msg_iter($_[0], \&add_text_body, $ctx, 1);
        ${delete $ctx->{rv}};
 }
 
@@ -926,8 +929,6 @@ sub missing_thread {
        PublicInbox::ExtMsg::ext_msg($ctx);
 }
 
-sub fmt_ts { POSIX::strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
-
 sub dedupe_subject {
        my ($prev_subj, $subj, $val) = @_;
 
@@ -1159,10 +1160,8 @@ sub dump_topics {
        200;
 }
 
-sub ts2str ($) {
-       my ($ts) = @_;
-       POSIX::strftime('%Y%m%d%H%M%S', gmtime($ts));
-}
+# only for the t= query parameter passed to overview DB
+sub ts2str ($) { strftime('%Y%m%d%H%M%S', gmtime($_[0])) };
 
 sub str2ts ($) {
        my ($yyyy, $mon, $dd, $hh, $mm, $ss) = unpack('A4A2A2A2A2A2', $_[0]);