X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWWW.pm;h=30a7a436df3d12ecce2bb96c980b058e38132975;hb=1761fba7befab2681276ac8f123593610ad27e58;hp=c7fbc7fd7dbe5409d3bb3005e747275a62b5f17b;hpb=afee3af86cd4c93e4d9bcdf1b2e34750bcff9a96;p=public-inbox.git diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index c7fbc7fd..30a7a436 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -53,10 +53,9 @@ sub run { } 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); + } elsif ($path_info =~ m!$LISTNAME_RE/t/(\S+)\.mbox\.gz!o) { + my $sfx = $3; + invalid_list_mid(\%ctx, $1, $2) || get_thread_mbox(\%ctx, $cgi); } elsif ($path_info =~ m!$LISTNAME_RE/f/\S+\.txt\z!o) { invalid_list_mid(\%ctx, $1, $2) || @@ -78,10 +77,16 @@ sub preload { require PublicInbox::Feed; require PublicInbox::View; require PublicInbox::Thread; + require PublicInbox::GitCatFile; require Email::MIME; require Digest::SHA; require POSIX; - require XML::Atom::SimpleFeed; + + eval { + require PublicInbox::Search; + require PublicInbox::Mbox; + require IO::Compress::Gzip; + }; } # private functions below @@ -114,11 +119,10 @@ sub invalid_list_mid { # /$LISTNAME/atom.xml -> Atom feed, includes replies 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($ctx) ] ] + require PublicInbox::Feed; + PublicInbox::Feed::generate($ctx); } # /$LISTNAME/?r=$GIT_COMMIT -> HTML only @@ -129,8 +133,7 @@ sub get_index { $ctx->{pi_config} = $pi_config; $ctx->{cgi} = $cgi; footer($ctx); - [ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ], - [ PublicInbox::Feed->generate_html_index($ctx) ] ] + PublicInbox::Feed::generate_html_index($ctx); } # just returns a string ref for the blob in the current ctx @@ -196,23 +199,7 @@ sub get_thread { my $srch = searcher($ctx) or return need_search($ctx); require PublicInbox::View; my $foot = footer($ctx); - my $body = PublicInbox::View->thread_html($ctx, $foot, $srch) or - return r404(); - [ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ], - [ $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 ] ]; + PublicInbox::View::thread_html($ctx, $foot, $srch); } sub self_url { @@ -308,7 +295,6 @@ sub footer { } $addr = "$addr"; - $desc = $desc; $ctx->{footer} = join("\n", '- ' . $desc, @@ -345,4 +331,15 @@ sub msg_pfx { "../f/$href.html"; } +# /$LISTNAME/t/$MESSAGE_ID.mbox.gz -> search results as gzipped mbox +# note: I'm not a big fan of other compression formats since they're +# significantly more expensive on CPU than gzip and less-widely available, +# especially on older systems. Stick to zlib since that's what git uses. +sub get_thread_mbox { + my ($ctx, $cgi) = @_; + my $srch = searcher($ctx) or return need_search($ctx); + require PublicInbox::Mbox; + PublicInbox::Mbox::thread_mbox($ctx, $srch); +} + 1;