mhonarc-users

Re: How to highlight new mail (with graphics)?

1998-11-13 09:59:01
How would you highlight new mail in the index files for the archive (with
little GIFs, say, or differently coloured text)? (When I say "new", I mean
mail that's arrived in the last 24 hours, for example.)

You'd have to write a CGI script that "wraps" the HTML indexes produced by
MHonArc, unless you want to continuously regenerate all of your pages.

The CGI script would basically read in the HTML index, and every time that
it found a relative link in the form /"msg[0-9]\.html"/ it would add an 
image on the end.  Something like

   #!/usr/local/bin/perl

   use CGI;
   $query = new CGI;
   print $query->header;

   $specialTime = 24*60*60;

   open (FILE, "<threads.html") || die "Can't open threads.html!\n";

   while (<FILE>) {
      if (/<STRONG><A\s+NAME\s*=\s*"(\d+)"/) {
         if ((time - modTime("msg$1.html")) < $specialTime) {
            s/<STRONG>(<A\s+NAME\s*=\s*"\d+")/<STRONG><img 
SRC="\/images\/newimage.gif" ALT="">$1/;
         }
      }
      print $_;
   }
   close FILE;

   sub modTime {
      local ($filename) = pop (@_);

      ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
          $atime, $mtime, $ctime, $blksize, $blocks) = stat $filename;
      return $mtime;
   }

This is off the top of my head, so no guarantees here.  But it should give you 
a start.

Chris

<Prev in Thread] Current Thread [Next in Thread>