if (!defined($rec) && defined($inbox) && $key eq 'userContent') {
$rec = [ PublicInbox::UserContent::sample($ctx) ];
}
- $rec // return r404();
+ srv_css_rec($rec);
+}
+
+sub srv_css_rec { # $_[0] may be ctx->{www}
+ my $rec = $_[-1] // return r404();
my ($css, undef) = @$rec; # TODO: Last-Modified + If-Modified-Since
my $h = [ 'Content-Length', length($css), 'Content-Type', 'text/css' ];
PublicInbox::GitHTTPBackend::cache_one_year($h);
$qsp->psgi_yield($ctx->{env}, undef, \&_refs_parse_hdr, $ctx);
}
+sub _get_css ($$) {
+ my ($ctx, $key) = @_;
+ $ctx->{www}->{-css_map} // $ctx->{www}->stylesheets_prepare('');
+ PublicInbox::WWW::srv_css_rec $ctx->{www}->{-css_map}->{$key};
+}
+
sub srv { # endpoint called by PublicInbox::WWW
my ($self, $ctx) = @_;
my $path_info = $ctx->{env}->{PATH_INFO};
} elsif ($path_info =~ m!\A/(.+?)/(refs/(?:heads|tags))/\z! and
($ctx->{git} = $pi_cfg->get_coderepo($1))) {
refs_foo($self, $ctx, $2);
+ } elsif ($path_info =~ m!\A/(.+?)/([a-zA-Z0-9_\-\.]+)\.css\z! &&
+ $pi_cfg->get_coderepo($1)) {
+ _get_css $ctx, $2;
} elsif ($path_info =~ m!\A/(.*?\*.*?)/*\z!) {
my $re = PublicInbox::Config::glob2re($1);
PublicInbox::RepoList::html($self, $ctx, qr!$re\z!) // r(404);