3 use open ":std", ":encoding(UTF-8)";
9 my $outdir = $ENV{'OUTDIR'};
10 die 'Set $OUTDIR' unless defined $outdir;
16 <img srcset='/got-tiny.png, /got-tiny@2x.png 2x'
18 alt='"GOT", but the "O" is a cute, smiling sun' />
30 my ($fh, $title) = @_;
31 open(my $hdr, '<', 'head.html')
32 or die "can't open head.html: $!";
41 open(my $foot, '<', 'foot.html')
42 or die "can't open foot.html: $!";
43 print $fh $_ while <$foot>;
47 endthread() if defined($tfh);
48 my ($mid, $subj) = @_;
49 my $dest = "$outdir/thread/$mid.html";
50 open($tfh, '>', $dest) or die "can't open $dest: $!";
51 initpage($tfh, $subj);
53 print $tfh "<header class='mail-header'>";
56 print $tfh "<a href='/'>‹ Back to the index</a>";
58 print $tfh "<dl><dt>Thread:</dt><dd>$subj</dd>";
59 print $tfh "</header>\n";
60 print $tfh "<div class='thread'>\n";
64 print $tfh "</div>\n";
70 my ($fh, $mid, $level, $date, $from, $subj) = @_;
73 $class = "reply indent-$level" unless $level == 0;
74 print $fh "<div id='$mid' class='mail $class'>";
75 print $fh "<p class='mail-meta'>";
76 print $fh "<time>$date</time> ";
77 print $fh "<span class='from'>$from</span>";
78 print $fh "<span class='colon'>:</span>";
79 if ($fh != $tfh && $level == 0) {
80 print $fh " (<a href='/thread/$mid.html'>thread</a>)";
83 print $fh "<p class='subject'>";
84 print $fh "<a href='/$mid.html'>$subj</a>";
90 entry_raw(\*STDOUT, @_);
94 initpage(\*STDOUT, "Game of Trees Mail Archive");
96 <header class='index-header'>
97 <a href="https://gameoftrees.org" target="_blank">
99 srcset='/got.png, /got@2x.png 2x'
100 alt='"GOT" where the "O" is a cute smiling sun.' />
102 <h1>Game of Trees Mail Archive</h1>
107 my $threads_seen = 0;
110 m/^[^ ]+ <([^>]+)> (.+)(\d{4}-\d{2}-\d{2} \d{2}:\d{2}) <([^>]+)> (.*)/;
111 die "woops; $_\n" unless defined $1;
113 my ($mid, $indent, $date, $from, $subj) = ($1, $2, $3, $4, $5);
118 my $level = length($indent) - 1;
119 $level = 10 if $indent =~ m/\.\.\d{2}\.\./;
127 my $new_thread = $indent eq " ";
128 say "</section> <hr />" if $threads_seen && $new_thread;
130 nextthread($mid, $subj);
131 say "<section class='thread'>";
136 entry($mid, $level, $date, $from, $subj);