Commit Diff


commit - a53202dfdbe51b361a5ea636c8922515dbfeac8f
commit + 04eab9af0be7f907e48d5952f56ab0e7436110ab
blob - /dev/null
blob + 6c35542dabd230e4576a6787e33e5537c193ab94 (mode 644)
--- /dev/null
+++ GotMArc.pm
@@ -0,0 +1,50 @@
+package GotMArc;
+use strict;
+use warnings;
+use v5.32;
+use Exporter;
+
+our @ISA = qw(Exporter);
+our @EXPORT_OK = qw($logo san initpage endpage);
+
+our $logo = <<'EOF';
+<a href="https://gameoftrees.org" target="_blank">
+  <img srcset='/got-tiny.png, /got-tiny@2x.png 2x'
+       src='/got-tiny.png'
+       width='64' height='39'
+       alt='"GOT", but the "O" is a cute, smiling sun' /></a>
+EOF
+
+sub san {
+	my $str = shift;
+	$str =~ s/&/\&amp;/g;
+	$str =~ s/</\&lt;/g;
+	$str =~ s/>/\&gt;/g;
+	return $str;
+}
+
+my $hdr = do {
+	local $/ = undef;
+	open my $fh, "<", "head.html"
+	    or die "can't open head.html: $!";
+	<$fh>;
+};
+
+sub initpage {
+	my ($fh, $title) = @_;
+	say $fh $hdr =~ s/TITLE/$title/r;
+}
+
+my $foot = do {
+	local $/ = undef;
+	open my $fh, "<", "foot.html"
+	    or die "can't open foot.html: $!";
+	<$fh>;
+};
+
+sub endpage {
+	my $fh = shift;
+	say $fh $foot;
+}
+
+1;
blob - 4d2f55404988e48ece582b77dc77191866e0b4ee
blob + e6a7fbd42ef8a84691818ec25568b2882552f37e
--- mexp
+++ mexp
@@ -6,40 +6,13 @@ use strict;
 use warnings;
 use v5.32;
 
+use lib ".";
+use GotMArc qw(san $logo initpage endpage);
+
 my $outdir = $ENV{'OUTDIR'};
 die 'Set $OUTDIR' unless defined $outdir;
 mkdir $outdir;
 
-my $hdr = do {
-	local $/ = undef;
-	open my $fh, "<", "head.html"
-	    or die "can't open head.html: $!";
-	<$fh>;
-};
-
-my $foot = do {
-	local $/ = undef;
-	open my $fh, "<", "foot.html"
-	    or die "can't open foot.html: $!";
-	<$fh>;
-};
-
-my $logo = <<EOF;
-<a href="https://gameoftrees.org" target="_blank">
-  <img srcset='/got-tiny.png, /got-tiny@2x.png 2x'
-       src='/got-tiny.png'
-       width='64' height='39'
-       alt='"GOT", but the "O" is a cute, smiling sun' /></a>
-EOF
-
-sub san {
-	my $str = shift;
-	$str =~ s/&/\&amp;/g;
-	$str =~ s/</\&lt;/g;
-	$str =~ s/>/\&gt;/g;
-	return $str;
-}
-
 my $tid;
 while (<>) {
 	chomp;
@@ -67,7 +40,7 @@ while (<>) {
 
 	open(my $fh, '>', "$dest") or die "can't open $dest: $!";
 
-	say $fh $hdr =~ s/TITLE/$subj/r;
+	initpage $fh, $subj;
 
 	# prepare the parts listing file
 	$ENV{'MESSAGE_ID'} = $mid;
@@ -127,14 +100,12 @@ while (<>) {
 	}
 	say $fh "</ul>" if $part_seen;
 
-	print $fh $foot;
+	endpage $fh;
 
 	close($text);
 	close($mshow);
 	close($parts);
 	close($fh);
-
-	# exit(0);
 }
 
 unlink "parts.html";
blob - 0a83b2df07f5a04d719d5bce25a10e102f7e2af6
blob + 84e43ccf36d9d91b4c9bfb87d1c4a1df8a266c2b
--- mkindex
+++ mkindex
@@ -6,6 +6,9 @@ use strict;
 use warnings;
 use v5.32;
 
+use lib ".";
+use GotMArc qw($logo san initpage endpage);
+
 my $outdir = $ENV{'OUTDIR'};
 die 'Set $OUTDIR' unless defined $outdir;
 mkdir $outdir;
@@ -18,39 +21,6 @@ my $last_level = 0;
 my $entries = 0;
 my $entries_per_page = 100;
 
-my $logo = <<EOF;
-<a href="https://gameoftrees.org" target="_blank">
-  <img srcset='/got-tiny.png, /got-tiny@2x.png 2x'
-       src='/got-tiny.png'
-       width='64' height='39'
-       alt='"GOT", but the "O" is a cute, smiling sun' /></a>
-EOF
-
-sub san {
-	my $str = shift;
-	$str =~ s/&/\&amp;/g;
-	$str =~ s/</\&lt;/g;
-	$str =~ s/>/\&gt;/g;
-	return $str;
-}
-
-sub initpage {
-	my ($fh, $title) = @_;
-	open(my $hdr, '<', 'head.html')
-	    or die "can't open head.html: $!";
-	while (<$hdr>) {
-		s/TITLE/$title/;
-		print $fh $_;
-	}
-}
-
-sub endpage {
-	my $fh = shift;
-	open(my $foot, '<', 'foot.html')
-	    or die "can't open foot.html: $!";
-	print $fh $_ while <$foot>;
-}
-
 sub pagename {
 	my $i = shift;
 	return $i == 0 && "index.html" || "$i.html";