} 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) {
} elsif ($path_info =~ m!$LISTNAME_RE/t/(\S+)\.html\z!o) {
invalid_list_mid(\%ctx, $1, $2) || get_thread(\%ctx, $cgi);
+ # subject_path display
+ } elsif ($path_info =~ m!$LISTNAME_RE/s/(\S+)\.html\z!o) {
+ my $sp = $2;
+ invalid_list(\%ctx, $1) || get_subject_path(\%ctx, $cgi, $sp);
+
# convenience redirects, order matters
- } elsif ($path_info =~ m!$LISTNAME_RE/(m|f|t)/(\S+)\z!o) {
+ } elsif ($path_info =~ m!$LISTNAME_RE/(m|f|t|s)/(\S+)\z!o) {
my $pfx = $2;
invalid_list_mid(\%ctx, $1, $3) ||
redirect_mid(\%ctx, $cgi, $2);
# /$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
sub mid2blob {
my ($ctx) = @_;
- my $hex = $ctx->{mid};
- my ($x2, $x38) = ($hex =~ /\A([a-f0-9]{2})([a-f0-9]{38})\z/);
-
- unless (defined $x38) {
- # compatibility with old links
- require Digest::SHA;
- $hex = Digest::SHA::sha1_hex($hex);
- ($x2, $x38) = ($hex =~ /\A([a-f0-9]{2})([a-f0-9]{38})\z/);
- defined $x38 or die "BUG: not a SHA-1 hex: $hex";
- }
-
+ require PublicInbox::MID;
+ my $path = PublicInbox::MID::mid2path($ctx->{mid});
my @cmd = ('git', "--git-dir=$ctx->{git_dir}",
- qw(cat-file blob), "HEAD:$x2/$x38");
+ qw(cat-file blob), "HEAD:$path");
my $cmd = join(' ', @cmd);
my $pid = open my $fh, '-|';
defined $pid or die "fork failed: $!\n";
[ $body ] ];
}
+# /$LISTNAME/s/$SUBJECT_PATH.html
+sub get_subject_path {
+ my ($ctx, $cgi, $sp) = @_;
+ $ctx->{subject_path} = $sp;
+ my $srch = searcher($ctx) or return need_search($ctx);
+ require PublicInbox::View;
+ my $foot = footer($ctx);
+ my $body = PublicInbox::View->subject_path_html($ctx, $foot, $srch) or
+ return r404();
+ [ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ],
+ [ $body ] ];
+}
+
sub self_url {
my ($cgi) = @_;
ref($cgi) eq 'CGI' ? $cgi->self_url : $cgi->uri->as_string;
my $footer = try_cat("$git_dir/public-inbox/footer.html");
if (defined $footer) {
chomp $footer;
+ $ctx->{footer} = $footer;
return $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):',
my ($ctx) = @_;
eval {
require PublicInbox::Search;
- PublicInbox::Search->new($ctx->{git_dir});
+ $ctx->{srch} = PublicInbox::Search->new($ctx->{git_dir});
};
}