about summary refs log tree commit homepage
path: root/lib/PublicInbox/Feed.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-09-05 02:52:47 +0000
committerEric Wong <e@80x24.org>2015-09-05 03:02:35 +0000
commit1e7fe3de7021427f8326a5f7710347035f7a63c5 (patch)
treea536b46fafda4b1347b5907bf1dd795bfd37d76d /lib/PublicInbox/Feed.pm
parent68d0ef45113ad2761e4f065250f329a5f52eb5f0 (diff)
downloadpublic-inbox-1e7fe3de7021427f8326a5f7710347035f7a63c5.tar.gz
This hopefully makes it easier to find things without resorting
to proprietary external services.
Diffstat (limited to 'lib/PublicInbox/Feed.pm')
-rw-r--r--lib/PublicInbox/Feed.pm20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 8fcb8d82..dbb80cad 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -123,19 +123,31 @@ sub emit_html_index {
         my $title = $feed_opts->{description} || '';
         $title = PublicInbox::Hval->new_oneline($title)->as_html;
         my $atom_url = $feed_opts->{atomurl};
-        my ($footer, $param, $last, $srch);
+        my ($footer, $param, $last);
         my $state = { ctx => $ctx, seen => {}, anchor_idx => 0 };
+        my $srch = $ctx->{srch};
+
+        my $top = "<b>$title</b> (<a\nhref=\"$atom_url\">Atom feed</a>)";
+
+        if ($srch) {
+                $top = qq{<form\naction=""><tt>$top} .
+                          qq{ <input\nname=q\ntype=text />} .
+                          qq{<input\ntype=submit\nvalue=search />} .
+                          qq{</tt></form>} .
+                          PublicInbox::View::PRE_WRAP;
+        } else {
+                $top = PublicInbox::View::PRE_WRAP . $top . "\n";
+        }
 
         $fh->write("<html><head><title>$title</title>" .
                    "<link\nrel=alternate\ntitle=\"Atom feed\"\n".
                    "href=\"$atom_url\"\ntype=\"application/atom+xml\"/>" .
-                   '</head><body>' . PublicInbox::View::PRE_WRAP .
-                   "<b>$title</b> (<a\nhref=\"$atom_url\">Atom feed</a>)\n");
+                   "</head><body>$top");
 
         # if the 'r' query parameter is given, it is a legacy permalink
         # which we must continue supporting:
         my $cgi = $ctx->{cgi};
-        if ($cgi && !$cgi->param('r') && ($srch = $ctx->{srch})) {
+        if ($cgi && !$cgi->param('r') && $srch) {
                 $state->{srch} = $srch;
                 $last = PublicInbox::View::emit_index_topics($state, $fh);
                 $param = 'o';