Since CSS can be overridden by a static webserver on a per-inbox
basis, we need a similar pattern to deal with the instance-wide
WwwListing HTML. "/+/" probably won't conflict with any current
nor future public inbox names.
I don't think it'll cause problems with common linkifiers or URL
extractors, either (and it's unlikely anybody would want to
share URLs of just the CSS in a plain text(-like) format).
# convenience redirects order matters
} elsif ($path_info =~ m!$INBOX_RE/([^/]{2,})\z!o) {
r301($ctx, $1, $2);
# convenience redirects order matters
} elsif ($path_info =~ m!$INBOX_RE/([^/]{2,})\z!o) {
r301($ctx, $1, $2);
+ } elsif ($path_info =~ m!\A/\+/([a-zA-Z0-9_\-\.]+)\.css\z!) {
+ get_css($ctx, undef, $1); # for WwwListing
} else {
legacy_redirects($ctx, $path_info);
}
} else {
legacy_redirects($ctx, $path_info);
}
-# /$INBOX/$KEY.css endpoint
+# /$INBOX/$KEY.css and /+/$KEY.css endpoints
# CSS is configured globally for all inboxes, but we access them on
# a per-inbox basis. This allows administrators to setup per-inbox
# static routes to intercept the request before it hits PSGI
# CSS is configured globally for all inboxes, but we access them on
# a per-inbox basis. This allows administrators to setup per-inbox
# static routes to intercept the request before it hits PSGI
+# inbox == undef => top-level WwwListing
sub get_css ($$$) {
my ($ctx, $inbox, $key) = @_;
sub get_css ($$$) {
my ($ctx, $inbox, $key) = @_;
- my $r404 = invalid_inbox($ctx, $inbox);
+ my $r404 = defined($inbox) ? invalid_inbox($ctx, $inbox) : undef;
return $r404 if $r404;
my $self = $ctx->{www};
return $r404 if $r404;
my $self = $ctx->{www};
- my $css_map = $self->{-css_map} || stylesheets_prepare($self, '');
+ my $css_map = $self->{-css_map} ||
+ stylesheets_prepare($self, defined($inbox) ? '' : '+/');
my $css = $css_map->{$key};
my $css = $css_map->{$key};
- if (!defined($css) && $key eq 'userContent') {
+ if (!defined($css) && defined($inbox) && $key eq 'userContent') {
my $env = $ctx->{env};
$css = PublicInbox::UserContent::sample($ctx->{ibx}, $env);
}
my $env = $ctx->{env};
$css = PublicInbox::UserContent::sample($ctx->{ibx}, $env);
}
my $h = [ 'Content-Type', 'text/html; charset=UTF-8',
'Content-Length', undef ];
my $gzf = gzf_maybe($h, $ctx->{env});
my $h = [ 'Content-Type', 'text/html; charset=UTF-8',
'Content-Length', undef ];
my $gzf = gzf_maybe($h, $ctx->{env});
- $gzf->zmore('<html><head><title>' .
- 'public-inbox listing</title>' .
- '</head><body>');
+ $gzf->zmore('<html><head><title>public-inbox listing</title>' .
+ $ctx->{www}->style('+/') .
+ '</head><body>');
my $code = 404;
if (my $list = delete $ctx->{-list}) {
my $mset = delete $ctx->{-mset};
my $code = 404;
if (my $list = delete $ctx->{-list}) {
my $mset = delete $ctx->{-mset};