diff options
author | Eric Wong <e@80x24.org> | 2019-12-25 07:51:02 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-12-27 20:00:38 +0000 |
commit | bc23e3dc4b252dc7e9b6f3824afe74d85456b689 (patch) | |
tree | 7bf915d6a2425d3de3b0076a7b164d590cd5a001 /lib | |
parent | 40f250660b42caa69f5533da5501f8d3f31f30ac (diff) | |
download | public-inbox-bc23e3dc4b252dc7e9b6f3824afe74d85456b689.tar.gz |
No need to create a new sub for every HTML page we render with our VCS viewer.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/ViewVCS.pm | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm index 7618b198..a6dbb9a9 100644 --- a/lib/PublicInbox/ViewVCS.pm +++ b/lib/PublicInbox/ViewVCS.pm @@ -31,14 +31,17 @@ my %QP_MAP = ( A => 'oid_a', B => 'oid_b', a => 'path_a', b => 'path_b' ); our $MAX_SIZE = 1024 * 1024; # TODO: configurable my $BIN_DETECT = 8000; # same as git +sub html_i { # WwwStream::getline callback + my ($nr, $ctx) = @_; + $nr == 1 ? ${delete $ctx->{rv}} : undef; +} + sub html_page ($$$) { my ($ctx, $code, $strref) = @_; my $wcb = delete $ctx->{-wcb}; $ctx->{-upfx} = '../../'; # from "/$INBOX/$OID/s/" - my $res = PublicInbox::WwwStream->response($ctx, $code, sub { - my ($nr, undef) = @_; - $nr == 1 ? $$strref : undef; - }); + $ctx->{rv} = $strref; + my $res = PublicInbox::WwwStream->response($ctx, $code, \&html_i); $wcb ? $wcb->($res) : $res; } |