]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwListing.pm
wwwstream: use parent.pm and no warnings
[public-inbox.git] / lib / PublicInbox / WwwListing.pm
index a416d24f0e446e27ae3c3148b061be9128ca7350..5f85e3464bc84d9b76986ddedd313cb30347f168 100644 (file)
@@ -10,6 +10,7 @@ use PublicInbox::Hval qw(ascii_html prurl);
 use PublicInbox::Linkify;
 use PublicInbox::View;
 use PublicInbox::Inbox;
+use PublicInbox::GzipFilter qw(gzf_maybe);
 use bytes (); # bytes::length
 use HTTP::Date qw(time2str);
 use Digest::SHA ();
@@ -104,13 +105,15 @@ sub ibx_entry {
 
 sub html ($$) {
        my ($env, $list) = @_;
-       my $title = 'public-inbox';
-       my $out = '';
+       my $h = [ 'Content-Type', 'text/html; charset=UTF-8',
+                       'Content-Length', undef ];
+       my $gzf = gzf_maybe($h, $env);
+       $gzf->zmore('<html><head><title>' .
+                               'public-inbox listing</title>' .
+                               '</head><body><pre>');
        my $code = 404;
        if (@$list) {
-               $title .= ' - listing';
                $code = 200;
-
                # Schwartzian transform since Inbox->modified is expensive
                @$list = sort {
                        $b->[0] <=> $a->[0]
@@ -118,13 +121,14 @@ sub html ($$) {
 
                my $tmp = join("\n", map { ibx_entry(@$_, $env) } @$list);
                my $l = PublicInbox::Linkify->new;
-               $out = '<pre>'.$l->to_html($tmp).'</pre><hr>';
+               $gzf->zmore($l->to_html($tmp));
+       } else {
+               $gzf->zmore('no inboxes, yet');
        }
-       $out = "<html><head><title>$title</title></head><body>" . $out;
-       $out .= '<pre>'. PublicInbox::WwwStream::code_footer($env) .
-               '</pre></body></html>';
-
-       my $h = [ 'Content-Type', 'text/html; charset=UTF-8' ];
+       my $out = $gzf->zflush('</pre><hr><pre>'.
+                               PublicInbox::WwwStream::code_footer($env) .
+                               '</pre></body></html>');
+       $h->[3] = bytes::length($out);
        [ $code, $h, [ $out ] ];
 }
 
@@ -157,10 +161,10 @@ sub manifest_add ($$;$$) {
 
        chomp(my $owner = $git->qx('config', 'gitweb.owner'));
        chomp(my $desc = try_cat("$git_dir/description"));
+       utf8::decode($owner);
+       utf8::decode($desc);
        $owner = undef if $owner eq '';
        $desc = 'Unnamed repository' if $desc eq '';
-       utf8::decode($desc);
-       utf8::decode($owner);
 
        # templates/hooks--update.sample and git-multimail in git.git
        # only match "Unnamed repository", not the full contents of