Commit Diff
Commit:
9ec6c8480fc307f744f98f832f478fe8d8a27387
From:
Omar Polo <op@omarpolo.com>
Date:
Sat Aug 27 07:20:21 2022 UTC
Message:
move index header to separate file and behind a function
commit - 4ad24540ab5194cdb4b7bd90d56d14c258629faa
commit + 9ec6c8480fc307f744f98f832f478fe8d8a27387
blob - badf5fee6fc3764161b6bda537b33b0b2726b108
blob + 861608741a19e6e3055c976205c2f56c225c6cc2
--- GotMArc.pm
+++ GotMArc.pm
@@ -5,7 +5,7 @@ our @EXPORT_OK = qw(san parse small_logo initpage endp
use Exporter;
our @ISA = qw(Exporter);
-our @EXPORT_OK = qw(san parse small_logo initpage endpage);
+our @EXPORT_OK = qw(san parse small_logo initpage endpage index_header);
sub san {
my $str = shift;
@@ -59,6 +59,7 @@ my $foot = readall "foot.html";
my $small_logo = readall "logo-small.html";
my $hdr = readall "head.html";
my $foot = readall "foot.html";
+my $idxhdr = readall "index-header.html";
sub small_logo {
my $fh = shift;
@@ -75,4 +76,11 @@ sub endpage {
say $fh $foot;
}
+sub index_header {
+ my ($fh, $page, $subtitle) = @_;
+ my $html = $idxhdr =~ s/PAGE/$page/r;
+ $html =~ s/SUBTITLE/$subtitle/;
+ print $fh $html;
+}
+
1;
blob - /dev/null
blob + 89cdb2b7cb2933dac1ee6aeacd61c2bbccb49a9d (mode 644)
--- /dev/null
+++ index-header.html
@@ -0,0 +1,10 @@
+<header class='index-header'>
+ <a href="https://gameoftrees.org" target="_blank">
+ <img src='/got.png'
+ srcset='/got.png, /got@2x.png 2x'
+ alt='"GOT" where the "O" is a cute smiling sun.' />
+ </a>
+ <h1>Game of Trees Mail Archive</h1>
+ <p>Page PAGE</p>
+ <p>SUBTITLE</p>
+</header>
blob - b97eae00c4b3d12047fd9c18de9b0c2fc12feef9
blob + 4f4bbeffe75dac51401f2d3b3c13921d052bd060
--- mkindex
+++ mkindex
@@ -10,7 +10,7 @@ use GotMArc qw(parse san small_logo initpage endpage);
use OpenBSD::Unveil;
use lib ".";
-use GotMArc qw(parse san small_logo initpage endpage);
+use GotMArc qw(parse san small_logo initpage endpage index_header);
my $outdir = $ENV{'OUTDIR'};
die 'Set $OUTDIR' unless defined $outdir;
@@ -91,34 +91,20 @@ sub renderpages {
or die "can't open $dest for writing: $!";
my $title = "Game of Trees Mail Archive | page $i";
- initpage($pfh, $title);
-
my $subtitle = $pages[$i-1];
- my $hdr = <<EOF;
-<header class='index-header'>
- <a href="https://gameoftrees.org" target="_blank">
- <img src='/got.png'
- srcset='/got.png, /got@2x.png 2x'
- alt='"GOT" where the "O" is a cute smiling sun.' />
- </a>
- <h1>Game of Trees Mail Archive</h1>
- <p>Page $i</p>
- <p>$subtitle</p>
-</header>
-<main>
-EOF
- say $pfh $hdr;
+ initpage($pfh, $title);
+ index_header $pfh, $i, $subtitle;
+ say $pfh "<main>";
nav $pfh, $i if $page > 1;
copyfrom($path, $pfh);
nav $pfh, $i if $page > 1;
say $pfh "</main>";
-
endpage($pfh);
- close($pfh);
+ close($pfh);
unlink $path;
}
}
Omar Polo