]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WWW.pm
www: simplify parameter passing to feed
[public-inbox.git] / lib / PublicInbox / WWW.pm
index bbd438a2d939bc1d42d9fbbcc83b1634ec74d0e8..be34e1cd544d742de593859ab9b0a7c37ea68a22 100644 (file)
@@ -35,9 +35,9 @@ sub run {
        } elsif ($path_info =~ m!$LISTNAME_RE\z!o) {
                invalid_list(\%ctx, $1) || redirect_list_index(\%ctx, $cgi);
        } elsif ($path_info =~ m!$LISTNAME_RE(?:/|/index\.html)?\z!o) {
-               invalid_list(\%ctx, $1) || get_index(\%ctx, $cgi, 0);
+               invalid_list(\%ctx, $1) || get_index(\%ctx, $cgi);
        } elsif ($path_info =~ m!$LISTNAME_RE/atom\.xml\z!o) {
-               invalid_list(\%ctx, $1) || get_atom(\%ctx, $cgi, 0);
+               invalid_list(\%ctx, $1) || get_atom(\%ctx, $cgi);
 
        # single-message pages
        } elsif ($path_info =~ m!$LISTNAME_RE/m/(\S+)\.txt\z!o) {
@@ -109,33 +109,24 @@ sub invalid_list_mid {
 
 # /$LISTNAME/atom.xml                       -> Atom feed, includes replies
 sub get_atom {
-       my ($ctx, $cgi, $top) = @_;
+       my ($ctx, $cgi) = @_;
        require PublicInbox::Feed;
+       $ctx->{pi_config} = $pi_config;
+       $ctx->{cgi} = $cgi;
        [ 200, [ 'Content-Type' => 'application/xml' ],
-         [ PublicInbox::Feed->generate({
-                       git_dir => $ctx->{git_dir},
-                       listname => $ctx->{listname},
-                       pi_config => $pi_config,
-                       cgi => $cgi,
-                       top => $top,
-               }) ]
-       ];
+         [ PublicInbox::Feed->generate($ctx) ] ]
 }
 
 # /$LISTNAME/?r=$GIT_COMMIT                 -> HTML only
 sub get_index {
-       my ($ctx, $cgi, $top) = @_;
+       my ($ctx, $cgi) = @_;
        require PublicInbox::Feed;
+       my $srch = searcher($ctx);
+       $ctx->{pi_config} = $pi_config;
+       $ctx->{cgi} = $cgi;
+       footer($ctx);
        [ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ],
-         [ PublicInbox::Feed->generate_html_index({
-                       git_dir => $ctx->{git_dir},
-                       listname => $ctx->{listname},
-                       pi_config => $pi_config,
-                       cgi => $cgi,
-                       footer => footer($ctx),
-                       top => $top,
-               }) ]
-       ];
+         [ PublicInbox::Feed->generate_html_index($ctx) ] ]
 }
 
 # just returns a string ref for the blob in the current ctx
@@ -275,6 +266,7 @@ sub footer {
        my $footer = try_cat("$git_dir/public-inbox/footer.html");
        if (defined $footer) {
                chomp $footer;
+               $ctx->{footer} = $footer;
                return $footer;
        }
 
@@ -304,7 +296,8 @@ sub footer {
 
        $addr = "<a\nhref=\"mailto:$addr\">$addr</a>";
        $desc =  $desc;
-       join("\n",
+
+       $ctx->{footer} = join("\n",
                '- ' . $desc,
                "A <a\nhref=\"" . PI_URL .  '">public-inbox</a>, ' .
                        'anybody may post in plain-text (not HTML):',
@@ -319,7 +312,7 @@ sub searcher {
        my ($ctx) = @_;
        eval {
                require PublicInbox::Search;
-               PublicInbox::Search->new($ctx->{git_dir});
+               $ctx->{srch} = PublicInbox::Search->new($ctx->{git_dir});
        };
 }