#!/usr/bin/perl
# This script is part of the NoonQuilt project:
#
#
#
# © Ali Graham, 1998
#
# (See makeQuilt.pl for the version history.)
#
#
# Start of editAll.pl (List all patches to be edited)
# ################################################################
# make sure this is syntactically clear...
use strict; use English;
# ...and running under Perl5...
require 5.001;
# uses a module available from
# CPAN ( http://www.perl.com/CPAN/ ),
# CGI_Lite
# set the include path to recognise it
use lib 'perllib';
# include the external files...
my $path = "";
if ( $OSNAME =~ /^mswin/i ) {
$path = "d:\\Inetpub\\wwwroot\\quilt\\scripts\\";
chdir($path);
}
(I needed to add the above lines to the start of every script, otherwise
the Perl interpreter on Windows NT would not change to the directory the
scripts were running in -- this is inconsistent with the behaviour on Unix,
Amiga & Macintosh Perl, which did.)
(require $path."nq_config.pl") or (die "Can't open \"nq_config.pl\": $!\n");
(require $path."nq_dirstuff.pl") or (die "Can't open \"nq_dirstuff.pl\": $!\n");
# ################################################################
# Start of main()
# get the dirs based on CGI data
use CGI_Lite;
my $cgi = new CGI_Lite ();
my %cgi_data = $cgi->parse_form_data();
my $params; my $patch_file;
my $defaults = &nqco_getScriptDefaults;
The code below checks the location of the directory to list
be edited: this is passed in by the HTML page that calls this
script, control.htm, based on the selection on the form on the
left-hand side of the control bar.
my $source_dir; my $page_title;
if ( $cgi_data{'subm_type'} eq "pending" ) {
$source_dir = $defaults->{'S_PatchInDir'};
$page_title = "list of submitted patches";
} elsif ( $cgi_data{'subm_type'} eq "accepted" ) {
$source_dir = $defaults->{'S_PatchDir'};
$page_title = "list of accepted patches";
} else {
$source_dir = $defaults->{'S_PatchRejectDir'};
$page_title = "list of rejected patches";
}
my @patch_files = sort( &nqds_getDirList($source_dir) );
if ( $#patch_files > -1 ) {
This is an oft-repeated tactic used in this source code -- in-line
HTML code with the occasional interspersion of Perl variables. It may
be a little confusing to mix metaphors like this, but the advantages
that come from the resultant terseness make it much easier than using
a succession of print "" statements.
print STDOUT <
$page_title
$page_title
| ( edit ) |
( file name ) |
( author ) |
( start of submission ) |
End_StartPatchList
The code below writes a row in the table for each file it finds
in the directory it has been told to list. Each row has a button to
edit it, the name of the file, the name of the person who submitted
it, and the first few words of the submission so it can be easily
identified.
for $patch_file (@patch_files) {
my $submission;
$params = &nqco_readParameters("$source_dir$patch_file");
$submission = $params->{'F_UserSubmission'}{'Value'};
# strip out all parts in angled brackets...
$submission =~ s/<.*?>//gs;
$submission = substr($submission, 0, 40);
print STDOUT <
|
$patch_file
|
$params->{'F_UserName'}{'Value'}
|
$submission
|
End_PatchRow
}
print STDOUT <
End_EndPatchList
} else {
This prints out an error message, if there are no files in
the selected directory.
print STDOUT <
choose a patch to edit
There are no files in the directory ( $source_dir ).
End_NoPatches
}
# End of main()
# End of editList.pl
|