commit 28ebc168d009ad4283df12fa2ac781d1d6cdd6cb from: Omar Polo date: Wed Aug 24 15:18:40 2022 UTC split the index over multiple pages commit - 1f8b897b407a9c056f634821597b63f2d49e1239 commit + 28ebc168d009ad4283df12fa2ac781d1d6cdd6cb blob - 0e94c59b6b99fe942b29049c15b56e4913710b8f blob + 93e7723ddcb6b0678fd9a2fd9073a8009f4a4a08 --- Makefile +++ Makefile @@ -8,7 +8,7 @@ OUTDIR = www all: .mblaze dirs assets mlist '${MDIR}' | mthread -r | \ ${ENV} mscan -f '%R %I %i %16D <%64f> %128S' | \ - ${ENV} ./mexp | ${ENV} ./mkindex > ${OUTDIR}/index.html + ${ENV} ./mexp | ${ENV} ./mkindex gzip: gzip -fkr ${OUTDIR}/ blob - 22baac074144c86e8bc1561cf72bce11bde417cf blob + a4d9a81ec470dc6b38dba50046a191fcf2fa97ac --- mkindex +++ mkindex @@ -10,9 +10,13 @@ my $outdir = $ENV{'OUTDIR'}; die 'Set $OUTDIR' unless defined $outdir; mkdir $outdir; -my $tfh; +my $tfh; # thread file handle +my $pfh; # page file handle +my $page = -1; my $threads_seen = 0; my $last_level = 0; +my $entries = 0; +my $entries_per_page = 100; my $logo = <; } +sub pagename { + my $i = shift; + return $i == 0 && "index.html" || "$i.html"; +} + +sub nextfile { + $entries = 0; + close($pfh) if defined $pfh; + $page += 1; + my $path = pagename($page); + open($pfh, '>', $path) + or die "can't open $path: $!"; + + my $title = "Game of Trees Mail Archive"; + $title .= " | page $page" if $page != 0; + initpage($pfh, $title); + + my $hdr = < + + "GOT" where the "O" is a cute smiling sun. + +

$title

+ +
+EOF + say $pfh $hdr; +} + +sub fixfiles { + close($pfh); + + my ($first, $last) = (pagename(0), pagename($page)); + + for (my $i = 0; $i <= $page; $i++) { + my $path = pagename($i); + + open(my $page, '>>', $path) + or die "can't open $page for append: $!"; + + if ($page > 1) { + my ($next, $prev) = (pagename($i+1), pagename($i-1)); + + say $page ""; + } + + say $page "
"; + endpage($page); + close($page); + rename $path, "$outdir/$path"; + } +} + sub nextthread { endthread() if defined($tfh); my ($mid, $subj) = @_; @@ -80,6 +144,9 @@ sub entry_raw { say $fh "\n$sep" if $threads_seen && $new_thread; if ($new_thread) { + # don't break threads over multiple pages! + nextfile if $entries >= $entries_per_page && $fh != $tfh; + nextthread($mid, $subj); say $fh "
"; } @@ -106,22 +173,12 @@ sub entry_raw { } sub entry { - entry_raw(\*STDOUT, "
", @_); + $entries++; + entry_raw($pfh, "
", @_); entry_raw($tfh, "", @_); } -initpage(\*STDOUT, "Game of Trees Mail Archive"); -print < - - "GOT" where the "O" is a cute smiling sun. - -

Game of Trees Mail Archive

- -
-EOF +nextfile(); while (<>) { chomp; @@ -148,10 +205,9 @@ while (<>) { } if ($threads_seen) { - say "" x $last_level; - say "
"; + say $pfh "" x $last_level; + say $pfh ""; endthread(); } -say ""; -endpage(\*STDOUT); +fixfiles();