commit ebad21b17317dc400355f7e65de6110b4b26ce29 from: Omar Polo date: Fri Aug 26 20:58:27 2022 UTC render only the threads list in the indexes, not the full threads suggested by Stefan, thanks! commit - 03d9df8019a7081a26755e6e39196f1951734bd5 commit + ebad21b17317dc400355f7e65de6110b4b26ce29 blob - 51dcd627a1c5af1f423f8667dc803b6e5e471f76 blob + 47f81e64eefcadb55d6c1b0a252ef9d63445f0da --- mkindex +++ mkindex @@ -28,13 +28,18 @@ sub pagename { return $i == 0 && "index.html" || "$i.html"; } +sub endfile { + say $pfh ''; + close($pfh); +} + sub nextfile { - $entries = 0; - close($pfh) if defined $pfh; + endfile if defined $pfh; $page += 1; my $path = pagename($page); open($pfh, '>', $path) or die "can't open $path: $!"; + say $pfh "
\n" x ($last_level - $level) if $last_level > $level; - 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 "
"; - } - - if ($last_level < $level) { - say $fh "
  • \n
      "; - } elsif ($last_level == 0) { - say $fh "
        "; - } - +sub entry { + my ($fh, $type, $mid, $date, $from, $subj) = @_; print $fh "
      • "; print $fh "

        "; print $fh " "; print $fh "$from"; print $fh ":"; - if ($fh != $tfh && $level == 0) { - print $fh " (thread)"; - } print $fh "

        "; print $fh "

        "; - print $fh "$subj"; + print $fh "$subj"; print $fh "

        "; print $fh "
      • \n"; } -sub entry { - $entries++; - entry_raw($pfh, "
        ", @_); - entry_raw($tfh, "", @_); +sub thread_entry { + my ($fh, $mid, $level, $date, $from, $subj) = @_; + + say $fh "
      \n" x ($last_level - $level) if $last_level > $level; + say $fh "
    \n
  • " if $threads_seen && $level == 0; + + say $fh "
    " if $level == 0; + + if ($last_level < $level) { + say $fh "
  • \n
      "; + } elsif ($last_level == 0) { + say $fh "
        "; + } + + entry $fh, "mail", $mid, $date, $from, $subj; } unveil($outdir, "rwc") or die "unveil $outdir: $!"; @@ -175,7 +169,7 @@ unveil(".", "rwc") or die "unveil .: $!"; # fattr is needed by move pledge("stdio rpath wpath cpath fattr") or die "pledge: $!"; -nextfile(); +nextfile; while (<>) { chomp; @@ -195,15 +189,22 @@ while (<>) { $subj =~ s/\s+/ /g; $subj =~ s/\s+$//g; - entry($mid, $level, $date, $from, $subj); + if ($level == 0) { + nextthread $mid, $subj; + + $entries++; + if ($entries > $entries_per_page) { + nextfile; + $entries = 0; + } + entry $pfh, "thread", $mid, $date, $from, $subj; + } + + thread_entry($tfh, $mid, $level, $date, $from, $subj); $last_level = $level; $threads_seen = 1; } -if ($threads_seen) { - say $pfh "
      " x $last_level; - say $pfh "
  • "; - endthread(); -} - +endfile; +endthread if $threads_seen; fixfiles();