##---------------------------------------------------------------------------##
## $Id: mhindex.pl,v 1.10 2002/06/27 04:56:41 ehood Exp $
## Earl Hood mhonarc@mhonarc.org
## Main index routines for mhonarc
##---------------------------------------------------------------------------##
## MHonArc -- Internet mail-to-HTML converter
## Copyright (C) 1995-2001 Earl Hood, mhonarc@mhonarc.org
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
##---------------------------------------------------------------------------##
##---------------------------------------------------------------------------
## write_main_index outputs main index of archive
my($outhandle, $i, $i_p0, $filename, $tmpl, $isfirst, $tmp,
local($PageNum, $PageSize); # XXX: Use in replace_li_vars()
$totalpgs = $onlypg || $NumOfPages;
if (!scalar(@MListOrder)) {
@MListOrder = &sort_messages
();
@Index2MLoc{@MListOrder} = (0 .. $#MListOrder);
for ( ; $PageNum <= $totalpgs; ++$PageNum) {
next if $PageNum < $IdxMinPg;
$offstart = ($PageNum-1) * $IDXSIZE;
$offend = $offstart + $IDXSIZE-1;
$offend = $#MListOrder if $#MListOrder < $offend;
@a = @MListOrder[$offstart..$offend];
$IDXPATHNAME = join("", $OUTDIR, $DIRSEP,
$IDXPREFIX, $PageNum, ".", $HtmlExt);
$IDXPATHNAME = join($DIRSEP, $OUTDIR, $IDXNAME);
if ($IDXSIZE && (($i = ($#MListOrder+1) - $IDXSIZE) > 0)) {
@a = @MListOrder[0..($IDXSIZE-1)];
@a = @MListOrder[$i..$#MListOrder];
$IDXPATHNAME = join($DIRSEP, $OUTDIR, $IDXNAME);
## Open/create index file
$outhandle = &file_create
($IDXPATHNAME, $GzipFiles) ||
die("ERROR: Unable to create $IDXPATHNAME\n");
print STDOUT
"Writing $IDXPATHNAME ...\n" unless $QUIET;
## Print top part of index
&output_maillist_head
($outhandle);
## Output links to messages
($tmpl = $LITMPL) =~ s/$VarExp/&replace_li_var($1,$index)/geo;
if (($tmp = get_base_subject
($index)) ne $prevsub) {
s/$VarExp/&replace_li_var($1,$index)/geo;
s/$VarExp/&replace_li_var($1,$index)/geo;
($tmpl = $LITMPL) =~ s/$VarExp/&replace_li_var($1,$index)/geo;
($tmpl = $SUBJECTEND) =~ s/$VarExp/&replace_li_var($1,$index)/geo;
if (($tmp = &get_base_author
($index)) ne $prevauth) {
s/$VarExp/&replace_li_var($1,$index)/geo;
s/$VarExp/&replace_li_var($1,$index)/geo;
($tmpl = $LITMPL) =~ s/$VarExp/&replace_li_var($1,$index)/geo;
($tmpl = $AUTHEND) =~ s/$VarExp/&replace_li_var($1,$index)/geo;
$time = &get_time_from_index
($index);
$tmp = join("", $UseLocalTime ?
(localtime($time))[3,4,5] :
s/$VarExp/&replace_li_var($1,$index)/geo;
s/$VarExp/&replace_li_var($1,$index)/geo;
($tmpl = $LITMPL) =~ s/$VarExp/&replace_li_var($1,$index)/geo;
($tmpl = $DAYEND) =~ s/$VarExp/&replace_li_var($1,$index)/geo;
## Print bottom part of index
&output_maillist_foot
($outhandle);
close($outhandle) unless $IDXONLY;
##---------------------------------------------------------------------------
## output_maillist_head() outputs the beginning of the index page.
sub output_maillist_head
{
$tmp = ($IDXPGSSMARKUP ne '') ?
$IDXPGSSMARKUP : $SSMARKUP;
$tmp =~ s/$VarExp/&replace_li_var($1,'')/geo;
print $handle "<!-- ", &commentize
("MHonArc v$VERSION"), " -->\n";
($tmp = $IDXPGBEG) =~ s/$VarExp/&replace_li_var($1,'')/geo;
($tmp = $LIBEG) =~ s/$VarExp/&replace_li_var($1,'')/geo;
##---------------------------------------------------------------------------
## output_maillist_foot() outputs the end of the index page.
sub output_maillist_foot
{
($tmp = $LIEND) =~ s/$VarExp/&replace_li_var($1,'')/geo;
&output_doclink
($handle);
($tmp = $IDXPGEND) =~ s/$VarExp/&replace_li_var($1,'')/geo;
print $handle "<!-- ", &commentize
("MHonArc v$VERSION"), " -->\n";
##---------------------------------------------------------------------------
## Output link to documentation, if specified
local($handle) = ($_[0]);
if (!$NODOC && $DOCURL) {
qq|<a href
="$DOCURL">MHonArc
</a
> $VERSION\n|,
##---------------------------------------------------------------------------