commit 9d8482ab3a97d3cd0e22afbf8ae95144a0016e87 from: Omar Polo date: Sat Aug 27 08:02:12 2022 UTC refactor the "thread header" into a separate function 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 "
\n"; + + print $fh "

"; + print $fh $small_logo; + print $fh "Index"; + print $fh "| Thread" + if defined $tid; + print $fh "

\n"; + + say $fh "
"; + foreach my $entry (@entries) { + my ($k, $v) = split /:/, $entry, 2; + say $fh "
$k:
$v
"; + } + say $fh "
"; + + say $fh "

Download raw body.

" + if defined $mid; + + say $fh "
\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 "
"; - print $fh "

"; - small_logo $fh; - print $fh "Index"; - print $fh " | "; - print $fh "Thread"; - print $fh "

"; - print $fh "
"; + 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 "
", san($h), ":
"; - print $fh "
", san($v), "
"; + s/\(.*\)// if /^Date:/; + push @hdrs, san($_); } - print $fh "
"; - print $fh "

Download raw body.

"; - print $fh "
"; + thread_header $fh, $tid, $mid, \@hdrs; + print $fh "
";
 	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 "
"; - print $tfh "

"; - small_logo $tfh; - print $tfh "Index"; - print $tfh "

"; - print $tfh "
Thread:
$subj
"; - print $tfh "
\n"; + thread_header $tfh, undef, undef, ["Thread: $subj"]; print $tfh "
    \n"; }