mhonarc-commits
[Top] [All Lists]

CVS: mharc/bin mk-procmailrc,1.10,1.11 web-archive,1.24,1.25

2002-07-06 21:11:54
Update of /cvsroot/mhonarc/mharc/bin
In directory subversions:/tmp/cvs-serv15430/bin

Modified Files:
	mk-procmailrc web-archive 
Log Message:
* mk-procmailrc:
  . Can now specify name of catch archive and if catch archive should
    be disabled via the CATCH_ARCHIVE and DISABLE_CATCH_ARCHIVE config.sh
    variables.
  . POD added to script along with -help and -man options to display
    usage information.

* web-archive:
  . Added check for <!--x-search-form--> and <!--/x-search-form-->
    comment declarations in period index header/footer templates:
    .PNM.head.in and .PNM.foot.in.  If an archive is designated
    to not have searching enabled, any markup between these two
    comments will be stripped out when generating the period index.

    If upgrading, and if you are using the default .PNM.*.in files,
    you will need to delete them so the newer versions with the above
    comments will be applied.  If you have customized versions of
    .PNM.*.in files, you will need to add the above comments around
    the search form markup if you want the form to not appear in the
    top period indexes for non-searchable archives.


Index: mk-procmailrc
===================================================================
RCS file: /cvsroot/mhonarc/mharc/bin/mk-procmailrc,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** mk-procmailrc	25 May 2002 00:52:34 -0000	1.10
--- mk-procmailrc	7 Jul 2002 04:10:45 -0000	1.11
***************
*** 5,8 ****
--- 5,9 ----
  ##  Description:
  ##	Program to create a procmail recipe file from lists.txt.
+ ##	Run script with '-man' option to view manpage for this program.
  ##---------------------------------------------------------------------------##
  ##  Copyright (C) 2001-2002	Earl Hood <earl(_at_)earlhood(_dot_)com>
***************
*** 37,52 ****
  use Getopt::Long;
  use MHArc::ListDef;
  
  MAIN: {
    my @htaccess = ();
!   my $basedir = $config->{'SW_ROOT'} || "$Dir/..";
!   my $procmail_path = $config->{'PROCMAIL_PATH'};
! 
!   GetOptions(
! 
!     'basedir', \$basedir,
!     'procmail-path=s', \$procmail_path
! 
!   ) || die;
  
    ## Read lists definition file
--- 38,70 ----
  use Getopt::Long;
  use MHArc::ListDef;
+ use MHArc::Util qw( usage );
  
  MAIN: {
    my @htaccess = ();
!   my %opt = ( );
!   my $clstatus = GetOptions(\%opt,
!     'home=s',
!     'procmail-path=s',
!     'catch-archive=s',
!     'disable-catch-archive!',
! 
!     'help',
!     'man'
!   );
!   usage(0) unless $clstatus;
!   usage(1) if $opt{'help'};
!   usage(2) if $opt{'man'};
! 
!   my $basedir       = $opt{'home'} ||
! 		      $config->{'SW_ROOT'} ||
! 		      "$Dir/..";
!   my $procmail_path = $opt{'procmail-path'} ||
! 		      $config->{'PROCMAIL_PATH'};
!   my $catch_arc     = $opt{'catch-archive'} ||
! 		      $config->{'CATCH_ARCHIVE'} ||
! 		      '.catch';
!   my $nocatch       = defined($opt{'disable-catch-archive'}) ?
! 			  $opt{'disable-catch-archive'} :
! 			  ($config->{'DISABLE_CATCH_ARCHIVE'} || 0);
  
    ## Read lists definition file
***************
*** 68,71 ****
--- 86,90 ----
  
  SHELL=/bin/sh
+ LINEBUF=4096
  UMASK=133
  PATH=$procmail_path
***************
*** 139,143 ****
      # check if doing monthly or yearly archives
      $period = lc($listdef->{$name}{'period'}[0]) || 'month';
!     $period = 'month'  if ($name eq '.catch');
      if ($period eq 'year') {
        $folder_name = '$YEARFOLDER';
--- 158,162 ----
      # check if doing monthly or yearly archives
      $period = lc($listdef->{$name}{'period'}[0]) || 'month';
!     $period = 'month'  if ($name eq $catch_arc);
      if ($period eq 'year') {
        $folder_name = '$YEARFOLDER';
***************
*** 195,199 ****
    }
  
!   print <<'EOT';
  ##======================================================================
  ##	No Matches
--- 214,219 ----
    }
  
!   if (!$nocatch) {
!     print <<EOT;
  ##======================================================================
  ##	No Matches
***************
*** 203,215 ****
  {
    :0 Wic
!   * ? test ! -d $MBOXROOT/.catch
!   | mkdir -m 755 -p $MBOXROOT/.catch
  
    :0
!   $MBOXROOT/.catch/$MONTHFOLDER
  }
  
  ##======================================================================
! ##	Fallback (should not get here)
  ##======================================================================
  :0
--- 223,239 ----
  {
    :0 Wic
!   * ? test ! -d \$MBOXROOT/$catch_arc
!   | mkdir -m 755 -p \$MBOXROOT/$catch_arc
  
    :0
!   \$MBOXROOT/$catch_arc/\$MONTHFOLDER
  }
  
+ EOT
+   }
+ 
+   print <<'EOT';
  ##======================================================================
! ##	Fallback: Discard message
  ##======================================================================
  :0
***************
*** 218,219 ****
--- 242,492 ----
  
  } # End: MAIN
+ 
+ __END__
+ 
+ =head1 NAME
+ 
+ mk-procmailrc - Generate .procmailrc from lists.def
+ 
+ =head1 SYNOPSIS
+ 
+   mk-procmailrc
+   mk-procmailrc [options]
+ 
+ =head1 DESCRIPTION
+ 
+ This program is part of MHArc, the auto-archiving system that works in
+ conjuction with Procmail, Namazu, and a collection of shell and
+ Perl programs.  This program has the responsibility of generating
+ the main C<.procmailrc> used by the C<filter-spool> program.  The
+ C<.procmailrc> is generated from C<I<mharc-root>/lib/lists.def>.
+ 
+ This program is typically invoked from calling C<make> from
+ the MHArc root directory with configuration options specified
+ in C<I<mharc-root>/lib/config.sh>.
+ 
+ =head1 LIST DEFINITION FILE
+ 
+ The list definition file, C<I<mharc-root>/lib/lists.def>, is
+ read to generate the C<.procmailrc> used by B<filter-spool> to
+ filter messages into raw mail archives.  The format of the file
+ is intended to be simple and more convenient than writing the
+ C<.procmailrc> file yourself.
+ 
+ The basic format of the file is as follows:
+ 
+ =over
+ 
+ =item *
+ 
+ Any blank links or lines starting with a C<#> are ignored.
+ 
+ =item *
+ 
+ Lines with the following format:
+ 
+   Option-Name: Option-Value
+ 
+ is an option to be read by this program.
+ 
+ =back
+ 
+ =head2 lists.def Supported Options
+ 
+ =over
+ 
+ =item Name
+ 
+ Starts, and defines, the name of the list to be archived.  This name
+ will be used as the directory name to contain the archives of the list
+ and the short title.  Typically notation is to use the list address,
+ but this is not required, especially if the archive is a combination
+ of multiple lists.
+ 
+ =item Address
+ 
+ Mail address of the list.  This option can be specified multiple times.
+ Multiple listings can be use to capture the multiple addresses that denote
+ the list.  This is useful if the list ever moves to a new address.
+ 
+ Multiple listings can also represent multiple lists that will be
+ archived together.
+ 
+ =item CVS-Commits
+ 
+ Boolean option (C<0> or C<1>) if the CVS commits to the list should be
+ separated out into a separate archive.
+ 
+ This option is useful for development lists that have all CVS commits
+ of a project mailed to the list.  This option allows the CVS commits
+ to be separated out into a separate archive so it will not pollute
+ the main archive that contains discussions.
+ 
+ =item CVS-Subject-Prefix
+ 
+ Option specifying the C<Subject:> prefix used to denote CVS commits to
+ the list.  Used if CVS-Commits is specified.
+ 
+ =item Description
+ 
+ Brief description of list.  This will be used as the title of archive
+ index pages.
+ 
+ =item Final
+ 
+ Boolean option (C<0> or C<1>) if generated rule should be final
+ if matched.  I.e.  If a message matches, further rules will not
+ be examined.
+ 
+ This option can be used to short-circuit messages from being
+ archived in other archives.  For example, you may want to catch
+ messages that have been cross-posted to a special address to
+ only be archived in the special address archive and not in the
+ regular archives.
+ 
+ =item No-Raw-Link
+ 
+ Boolean option (C<0> or C<1>) if link to raw archive from period index
+ page should be created.  If set to C<1>, no link will be created.
+ The default is to create a link to the raw archives.
+ 
+ You may want to enable this option if your HTML archives have
+ been customized to obscure address to prevent address harvesting.
+ 
+ B<Note:> If this is the case, make sure to change the permission of
+ the C<I<mharc-root>/mbox>> directory so it is not readable by the
+ HTTP server process so someone cannot backdoor into the raw archives.
+ This is generally done by removing world read permission .  Make sure
+ the permission do allow for the MHArc archiving system to read and
+ write to the directory.
+ 
+ You could also explicitly deny access to the directory via the HTTP
+ server configuration file.  This is the recommended approach since
+ it gives you additional protection in case the C<I<mharc-root>/mbox>>
+ directory permissions are unintentionally changed to world readable.
+ 
+ =item No-Search
+ 
+ Boolean option (C<I<mharc-root>/mbox>> directory) if searching should
+ be disabled.  If set to C<1>, no search index will be created for
+ the archive and the C<$SEARCH-FORM$> custom resource variable will
+ be set to the empty string.
+ 
+ =item MHonArc-Options
+ 
+ Additional command-line options to pass to MHonArc.  Command-line
+ options are specified as they would be at the shell prompt.
+ 
+ =item Period
+ 
+ If archive is a yearly or monthly archive.  Legal values are C<year>
+ or C<month>.  If Period is not defined, C<month> is the default.
+ 
+ =item Procmail-Condition
+ 
+ Additional conditions to apply to base address check.  The condition
+ must be legal procmailrc syntax and should include any prefixing C<*>,
+ C<!>, et. al.
+ 
+ B<Note:> Care should be used when using this option, especially if
+ C<CVS-Commits> is true.  When C<CVS-commits> is true, an additionaly
+ rule is already added to check for the C<CVS-Subject-Prefix> setting.
+ 
+ =back
+ 
+ =head2 lists.def Example
+ 
+   ##  In this definition, we define multiple addresses to check.
+   Name: mhonarc-users
+   Description: MHonArc Mailing List
+   Address: mhonarc-users(_at_)mhonarc(_dot_)org
+   Address: mhonarc(_at_)ncsa(_dot_)uiuc(_dot_)edu
+   Address: mhonarc(_at_)rosat(_dot_)mpe-garching(_dot_)mpg(_dot_)de
+ 
+   ##  This definition defines a list that receives CVS commits and those
+   ##  commits should be separated into a special archive as to not
+   ##  pollute the discussion messages with cvs commit messages
+   Name: mhonarc-dev
+   Description: MHonArc Development Mailing List
+   Address: mhonarc-dev(_at_)mhonarc(_dot_)org
+   CVS-Commits: 1
+   CVS-Subject-Prefix: CVS: 
+ 
+ =head1 OPTIONS
+ 
+ =over
+ 
+ =item C<-home> I<pathname>
+ 
+ Root pathname of archiving software and data.  If not specified,
+ C<SW_ROOT> variable in C<config.sh> is used, else the parent directory
+ that contains this program is used.
+ 
+ =item C<-catch-archive> I<name>
+ 
+ The name of the I<catch> archive.  The I<catch> archive collects
+ all messages that do not match any mailing list rules.  If this
+ option is not specified, the C<CATCH_ARCHIVE> variable in
+ C<config.sh> is used, else the name "C<.catch>" is used.
+ 
+ B<Note:> If you use this option, it is recommended that the name
+ starts with a '.'.  This insures that no search index built for
+ the archive (a saving in resources) and it will not be listed
+ in a HTTP (Apache) directory listing.
+ 
+ =item C<-disable-catch-archive>
+ 
+ If specified, no I<catch> archive will be defined.
+ 
+ B<Note:> Care should be used when using this option since any
+ message that does not match a normal rule will be lost.
+ 
+ =item C<-help>
+ 
+ Print out usage information.
+ 
+ =item C<-man>
+ 
+ Print out entire manpage.
+ 
+ =item C<-procmail-path> I<pathname-list>
+ 
+ The search path to be used by procmail.  I.e. The value to give
+ the C<PATH> variable in the C<.procmailrc>.  If this option is
+ not specified, the C<PROCMAIL_PATH> variable in C<config.sh>.
+ 
+ =back
+ 
+ =head1 FILES
+ 
+ =over
+ 
+ =item C<I<mharc-root>/lib/lists.def>
+ 
+ Mailing lists definition file.
+ 
+ =item C<I<mharc-root>/lib/config.sh>
+ 
+ Main configuration file for MHArc.
+ 
+ =item C<I<mharc-root>/.procmailrc>
+ 
+ Procmail resource file generated by this program.
+ 
+ =back
+ 
+ =head1 VERSION
+ 
+ $Id$
+ 
+ =head1 AUTHOR
+ 
+ Earl Hood, earl(_at_)earlhood(_dot_)com
+ 
+ This program is part of the MHArc archiving system and comes with
+ ABSOLUTELY NO WARRANTY and may be copied only under the terms of
+ the GNU General Public License, which may be found in the MHArc
+ distribution.
+ 
+ =cut
+ 

Index: web-archive
===================================================================
RCS file: /cvsroot/mhonarc/mharc/bin/web-archive,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** web-archive	23 May 2002 02:12:07 -0000	1.24
--- web-archive	7 Jul 2002 04:10:45 -0000	1.25
***************
*** 39,42 ****
--- 39,43 ----
  use Getopt::Long;
  use MHArc::ListDef;
+ use MHArc::Util qw( usage );
  
  # Load MHonArc library
***************
*** 207,211 ****
    my(@months, @folders);
    my($dir, $list, $mon, $mondir, $htmldir, $cvs, $title, $mtime,
!      $folder, $i, $yr, $prevdir, $nextdir, $prevmon, $nextmon);
  
    print "Lists: ", join(', ', @dirs), "\n"  if $debug;
--- 208,212 ----
    my(@months, @folders);
    my($dir, $list, $mon, $mondir, $htmldir, $cvs, $title, $mtime,
!      $folder, $i, $yr, $prevdir, $nextdir, $prevmon, $nextmon, $nosearch);
  
    print "Lists: ", join(', ', @dirs), "\n"  if $debug;
***************
*** 269,272 ****
--- 270,276 ----
      mkdir($htmldir, 0777);
  
+     $nosearch = (defined($listdef->{$list}{'no-search'}) &&
+ 		 $listdef->{$list}{'no-search'}[0]);
+ 
      $cvs = $list =~ /\.CVS/;
      #($title) = $list =~ /([^.]+)/;
***************
*** 330,336 ****
        }
  
!       # check if searching is disabled
!       if (defined($listdef->{$list}{'no-search'}) &&
! 	  $listdef->{$list}{'no-search'}[0]) {
  	push(@mhaargs, '-definevar', "SEARCH-FORM=''");
        }
--- 334,339 ----
        }
  
!       # if searching is disabled, zero-out $SEARCH-FORM$
!       if ($nosearch) {
  	push(@mhaargs, '-definevar', "SEARCH-FORM=''");
        }
***************
*** 426,429 ****
--- 429,433 ----
  
      my @vars = (
+       '-nosearch'  => $nosearch,
        'SEARCH-CGI' => $SEARCH_CGI,
        'LIST-NAME'  => $list,
***************
*** 490,496 ****
    my $fh	= shift;
    my %varhash	= @_;
!   local $/;
!   my $data = <$fh>;
!   $data =~ s/\$([^\$]+)\$/$varhash{$1}/ge;
    $data;
  }
--- 494,519 ----
    my $fh	= shift;
    my %varhash	= @_;
!   my $data = "";
! 
!   if ($varhash{'-nosearch'}) {
!     local $_;
!     my $ignore = 0;
!     while (<$fh>) {
!       if ($ignore) {
! 	$ignore = 0  if /<!--\/x-search-form-->/;
! 	next;
!       }
!       if (/<!--x-search-form-->/) {
! 	$ignore = 1;
! 	next;
!       }
!       s/\$([^\$]+)\$/$varhash{$1}/ge;
!       $data .= $_;
!     }
!   } else {
!     local $/;
!     my $data = <$fh>;
!     $data =~ s/\$([^\$]+)\$/$varhash{$1}/ge;
!   }
    $data;
  }
***************
*** 511,528 ****
        warn qq/Warning: Unable to remove "$lock": $!\n/;
      }
-   }
- }
- 
- sub usage {
-   require Pod::Usage;
-   my $verbose = shift;
-   if ($verbose == 0) {
-     Pod::Usage::pod2usage(-verbose => $verbose);
-   } else {
-     my $pager = $ENV{'PAGER'} || 'more';
-     local(*PAGER);
-     my $fh = (-t STDOUT && open(PAGER, "|$pager")) ? \*PAGER : \*STDOUT;
-     Pod::Usage::pod2usage(-verbose => $verbose,
- 			  -output  => $fh);
    }
  }
--- 534,537 ----

---------------------------------------------------------------------
To sign-off this list, send email to majordomo(_at_)mhonarc(_dot_)org with the
message text UNSUBSCRIBE MHONARC-DEV