Commit Diff


commit - 469be48e163a66d38ef3e063007b3ca90d552606
commit + 789a106aad27ab1178f8b2420738e39aae6bdf10
blob - feb031a358a861abdd888ae5b25bd3c1417004b8
blob + 9289bc39e41cda915f55fe1ec281b329cfc60a2c
--- GotMArc.pm
+++ GotMArc.pm
@@ -11,7 +11,7 @@ use File::Basename;
 
 our @ISA = qw(Exporter);
 our @EXPORT_OK = qw(san urlencode parse initpage endpage index_header
-    thread_header threntry thrslice thrnav);
+    search thread_header threntry thrslice thrnav);
 
 sub san {
 	my $str = shift;
@@ -75,6 +75,7 @@ my $small_logo = readall "$templates/logo-small.html";
 my $hdr = readall "$templates/head.html";
 my $foot = readall "$templates/foot.html";
 my $idxhdr = readall "$templates/index-header.html";
+my $search = readall "$templates/search.html";
 
 sub initpage {
 	my ($fh, $title) = @_;
@@ -93,6 +94,12 @@ sub index_header {
 	print $fh $html;
 }
 
+sub search {
+	my $fh = shift;
+	my $html = $search =~ s/QUERY//r;
+	print $fh $html;
+}
+
 sub thread_header {
 	my ($fh, $e, $mail, $p, $n) = @_;
 
blob - cff6fe0167118e0c7d107285b0fa797efc285ad9
blob + ff5cece36c866d7184bec2d2bf88229d45621408
--- gotmarc.1
+++ gotmarc.1
@@ -61,6 +61,10 @@ is replaced with the page number and
 with the date range.
 .It Pa /etc/gotmarc/logo-small.html
 Small version of the logo, included in the thread header.
+.It Pa /etc/gotmarc/search.html
+Template for the search form.
+.Ev QUERY
+is replaced with the search query.
 .It Pa /var/www/gotmarc
 Default output directory.
 .It Pa ~/.cache/gotmarc
blob - d659ee67cdec71fd62bf3467e94662909d08c354
blob + 7fa6de77fdc0b86eb068b53484f86eb3e4b5a73b
--- mkindex
+++ mkindex
@@ -16,7 +16,7 @@ use OpenBSD::Unveil;
 
 use lib ".";
 use GotMArc qw(parse san urlencode initpage endpage index_header
-    thread_header threntry);
+    search thread_header threntry);
 
 my $outdir = $ENV{'OUTDIR'};
 die 'Set $OUTDIR' unless defined $outdir;
@@ -86,17 +86,6 @@ sub nav {
 	say $pfh "</nav>";
 }
 
-sub search {
-	my $pfh = shift;
-
-	say $pfh <<'EOF' ;
-<form method="get" action="/search">
-  <label>Search: <input type="search" name="q" /></label>
-  <button type="submit">search</button>
-</form>
-EOF
-}
-
 sub copyfrom {
 	my ($path, $fh) = @_;
 
blob - /dev/null
blob + 6da5e45d9aa4b148c0944889014bdf4aa3f0e707 (mode 644)
--- /dev/null
+++ templates/search.html
@@ -0,0 +1,4 @@
+<form method="get" action="/search">
+  <label>Search: <input type="search" name="q" value="QUERY" /></label>
+  <button type="submit">search</button>
+</form>