about summary refs log tree commit homepage
path: root/lib/PublicInbox/WWW.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-05-15 01:18:07 +0000
committerEric Wong <e@80x24.org>2019-05-15 01:18:52 +0000
commit70caf43a131fc5bdf7104f82f2acee9d5353d6a8 (patch)
tree54691cbe7b16adf0fd8406d2a3a514bbd19741ce /lib/PublicInbox/WWW.pm
parente981538130dd6d285392f4316328edbadab0d330 (diff)
downloadpublic-inbox-70caf43a131fc5bdf7104f82f2acee9d5353d6a8.tar.gz
www: use Inbox->over where appropriate
We don't need to rely on Xapian search functionality for the
majority of the WWW code, even.  subject_normalized is moved to
SearchMsg, where it (probably) makes more sense, anyways.
Diffstat (limited to 'lib/PublicInbox/WWW.pm')
-rw-r--r--lib/PublicInbox/WWW.pm32
1 files changed, 9 insertions, 23 deletions
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index 1f3ca157..0f963dcb 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -168,7 +168,6 @@ sub r404 {
         my ($ctx) = @_;
         if ($ctx && $ctx->{mid}) {
                 require PublicInbox::ExtMsg;
-                searcher($ctx);
                 return PublicInbox::ExtMsg::ext_msg($ctx);
         }
         r(404, 'Not Found');
@@ -239,7 +238,6 @@ sub get_new {
 sub get_index {
         my ($ctx) = @_;
         require PublicInbox::Feed;
-        searcher($ctx);
         if ($ctx->{env}->{QUERY_STRING} =~ /(?:\A|[&;])q=/) {
                 require PublicInbox::SearchView;
                 PublicInbox::SearchView::sres_top_html($ctx);
@@ -259,14 +257,13 @@ sub get_mid_txt {
 sub get_mid_html {
         my ($ctx) = @_;
         require PublicInbox::View;
-        searcher($ctx);
         PublicInbox::View::msg_page($ctx) || r404($ctx);
 }
 
 # /$INBOX/$MESSAGE_ID/t/
 sub get_thread {
         my ($ctx, $flat) = @_;
-        searcher($ctx) or return need_search($ctx);
+        $ctx->{-inbox}->over or return need($ctx, 'Overview');
         $ctx->{flat} = $flat;
         require PublicInbox::View;
         PublicInbox::View::thread_html($ctx);
@@ -303,21 +300,11 @@ sub ctx_get {
         $val;
 }
 
-# search support is optional, returns undef if Xapian is not installed
-# or not configured for the given GIT_DIR
-sub searcher {
-        my ($ctx) = @_;
-        eval {
-                require PublicInbox::Search;
-                $ctx->{srch} = $ctx->{-inbox}->search;
-        };
-}
-
-sub need_search {
-        my ($ctx) = @_;
+sub need {
+        my ($ctx, $extra) = @_;
         my $msg = <<EOF;
-<html><head><title>Search not available for this
-public-inbox</title><body><pre>Search is not available for this public-inbox
+<html><head><title>$extra not available for this
+public-inbox</title><body><pre>$extra is not available for this public-inbox
 <a href="../">Return to index</a></pre></body></html>
 EOF
         [ 501, [ 'Content-Type' => 'text/html; charset=UTF-8' ], [ $msg ] ];
@@ -330,16 +317,16 @@ EOF
 # especially on older systems.  Stick to zlib since that's what git uses.
 sub get_thread_mbox {
         my ($ctx, $sfx) = @_;
-        my $srch = searcher($ctx) or return need_search($ctx);
+        my $over = $ctx->{-inbox}->over or return need($ctx, 'Overview');
         require PublicInbox::Mbox;
-        PublicInbox::Mbox::thread_mbox($ctx, $srch, $sfx);
+        PublicInbox::Mbox::thread_mbox($ctx, $over, $sfx);
 }
 
 
 # /$INBOX/$MESSAGE_ID/t.atom                  -> thread as Atom feed
 sub get_thread_atom {
         my ($ctx) = @_;
-        searcher($ctx) or return need_search($ctx);
+        $ctx->{-inbox}->over or return need($ctx, 'Overview');
         require PublicInbox::Feed;
         PublicInbox::Feed::generate_thread_atom($ctx);
 }
@@ -453,7 +440,7 @@ sub serve_git {
 sub mbox_results {
         my ($ctx) = @_;
         if ($ctx->{env}->{QUERY_STRING} =~ /(?:\A|[&;])q=/) {
-                searcher($ctx) or return need_search($ctx);
+                $ctx->{-inbox}->search or return need($ctx, 'search');
                 require PublicInbox::SearchView;
                 return PublicInbox::SearchView::mbox_results($ctx);
         }
@@ -464,7 +451,6 @@ sub serve_mbox_range {
         my ($ctx, $inbox, $range) = @_;
         invalid_inbox($ctx, $inbox) || eval {
                 require PublicInbox::Mbox;
-                searcher($ctx);
                 PublicInbox::Mbox::emit_range($ctx, $range);
         }
 }