Commit Diff


commit - 9ec6c8480fc307f744f98f832f478fe8d8a27387
commit + 9d8482ab3a97d3cd0e22afbf8ae95144a0016e87
blob - 861608741a19e6e3055c976205c2f56c225c6cc2
blob + 6853d2c0a808330c3db45d2bf4042f7505356452
--- GotMArc.pm
+++ GotMArc.pm
@@ -5,7 +5,7 @@ use v5.32;
 use Exporter;
 
 our @ISA = qw(Exporter);
-our @EXPORT_OK = qw(san parse small_logo initpage endpage index_header);
+our @EXPORT_OK = qw(san parse initpage endpage index_header thread_header);
 
 sub san {
 	my $str = shift;
@@ -61,11 +61,6 @@ my $hdr = readall "head.html";
 my $foot = readall "foot.html";
 my $idxhdr = readall "index-header.html";
 
-sub small_logo {
-	my $fh = shift;
-	print $fh $small_logo;
-}
-
 sub initpage {
 	my ($fh, $title) = @_;
 	say $fh $hdr =~ s/TITLE/$title/r;
@@ -83,4 +78,30 @@ sub index_header {
 	print $fh $html;
 }
 
+sub thread_header {
+	my ($fh, $tid, $mid, $e) = @_;
+	my @entries = @$e;
+
+	print $fh "<header class='mail-header'>\n";
+
+	print $fh "<p>";
+	print $fh $small_logo;
+	print $fh "<a href='/'>Index</a>";
+	print $fh "| <a href='/thread/$tid.html#$mid'>Thread</a>"
+	    if defined $tid;
+	print $fh "</p>\n";
+
+	say $fh "<dl>";
+	foreach my $entry (@entries) {
+		my ($k, $v) = split /:/, $entry, 2;
+		say $fh "<dt>$k:</dt><dd>$v</dd>";
+	}
+	say $fh "</dl>";
+
+	say $fh "<p>Download raw <a href='/text/$mid.html'>body</a>.</p>"
+	    if defined $mid;
+
+	say $fh "</header>\n";
+};
+
 1;
blob - bd30bf3bafb6fd09ef6b4eaa4215ae9e2400f5b4
blob + 118a07527c58d6a27a2f0f2f86905a65fa439e4c
--- mexp
+++ mexp
@@ -10,7 +10,7 @@ use OpenBSD::Pledge;
 use OpenBSD::Unveil;
 
 use lib ".";
-use GotMArc qw(parse san small_logo initpage endpage);
+use GotMArc qw(parse san initpage endpage thread_header);
 
 my $outdir = $ENV{'OUTDIR'};
 die 'Set $OUTDIR' unless defined $outdir;
@@ -45,31 +45,19 @@ while (<>) {
 	open(my $text, '>', "$outdir/text/$mid.txt")
 	    or die "can't open $outdir/text/$mid.txt: $!";
 
-	print $fh "<header class='mail-header'>";
-	print $fh "<p>";
-	small_logo $fh;
-	print $fh "<a href='/'>Index</a>";
-	print $fh " | ";
-	print $fh "<a href='/thread/$tid.html#$mid'>Thread</a>";
-	print $fh "</p>";
-	print $fh "<dl>";
+	my @hdrs;
 	while (<$mshow>) {
 		chomp;
 		say $text $_;
 		last if /^$/;
-		my ($h, $v) = m/^([-A-Za-z]+): (.*)/;
-		die "bogus line? $fname : $_" unless (defined $h and defined $v);
 
 		# drop the (1 day ago) string
-		$v =~ s/\(.*\)//g if ($h eq "Date");
-
-		print $fh "<dt>", san($h), ":</dt>";
-		print $fh "<dd>", san($v), "</dd>";
+		s/\(.*\)// if /^Date:/;
+		push @hdrs, san($_);
 	}
-	print $fh "</dl>";
-	print $fh "<p>Download raw <a href='/text/$mid.txt'>body</a>.</p>";
-	print $fh "</header>";
 
+	thread_header $fh, $tid, $mid, \@hdrs;
+
 	print $fh "<pre>";
 	while (<$mshow>) {
 		print $text $_;
blob - 4f4bbeffe75dac51401f2d3b3c13921d052bd060
blob + ed1c995d39b362f9563d355356d46354a83b09b2
--- mkindex
+++ mkindex
@@ -10,7 +10,7 @@ use OpenBSD::Pledge;
 use OpenBSD::Unveil;
 
 use lib ".";
-use GotMArc qw(parse san small_logo initpage endpage index_header);
+use GotMArc qw(parse san initpage endpage index_header thread_header);
 
 my $outdir = $ENV{'OUTDIR'};
 die 'Set $OUTDIR' unless defined $outdir;
@@ -124,14 +124,7 @@ sub nextthread {
 	my $dest = "$outdir/thread/$mid.html";
 	open($tfh, '>', $dest) or die "can't open $dest: $!";
 	initpage($tfh, $subj);
-
-	print $tfh "<header class='mail-header'>";
-	print $tfh "<p>";
-	small_logo $tfh;
-	print $tfh "<a href='/'>Index</a>";
-	print $tfh "</p>";
-	print $tfh "<dl><dt>Thread:</dt><dd>$subj</dd></dl>";
-	print $tfh "</header>\n";
+	thread_header $tfh, undef, undef, ["Thread: $subj"];
 	print $tfh "<div class='thread'><ul class='mails'>\n";
 }