From 41947542045105aaa6f500f44de17de775e45a0b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 17 Aug 2015 02:41:12 +0000 Subject: www: simplify parameter passing to feed No need to create a new hash when we can reuse the existing one more. --- lib/PublicInbox/WWW.pm | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'lib/PublicInbox/WWW.pm') diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index 7cbfa355..be34e1cd 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -111,14 +111,10 @@ sub invalid_list_mid { sub get_atom { 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, - }) ] - ]; + [ PublicInbox::Feed->generate($ctx) ] ] } # /$LISTNAME/?r=$GIT_COMMIT -> HTML only @@ -126,16 +122,11 @@ sub get_index { 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({ - srch => $srch, - git_dir => $ctx->{git_dir}, - listname => $ctx->{listname}, - pi_config => $pi_config, - cgi => $cgi, - footer => footer($ctx), - }) ] - ]; + [ 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 = "$addr"; $desc = $desc; - join("\n", + + $ctx->{footer} = join("\n", '- ' . $desc, "A public-inbox, ' . '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}); }; } -- cgit v1.2.3-24-ge0c7