) {
next if (/^#.*/); # skip comments
next if (/^\s*$/); # skip empty lines
$Tabargs = $_; # we only take single line!
chop($Tabargs); # don't want the trailing \n
}
print "*** For tabset using >>> $Tabargs\n" if ($Verbose);
} # We use $Tabs in pipe when we open $HTML later
}
}
#######################################################################
# Generates both HTML and TSV files in parallel
# Assumes all (sorted) data in in @Work
# Puts error notice in output data files if no records were selected
# NB file names cannot be constructed before $Project is extracted
# from the input database file
#######################################################################
sub Web {
my ($ii,$kk);
if ( ! $Outfile ) {
$Outfile = "$Project" . "$WorkName";
}
$HTML = "$WorkDir/$Outfile.html";
$TSV = "$WorkDir/$Outfile.tsv";
if ($Tsv) {
print "*** Writing TSV file $TSV\n" if ($Verbose);
open(TSV,">$TSV") || die "Could not open $TSV to write output";
}
if ($Web) {
print "*** writing HTML file $HTML\n" if ($Verbose);
if ($Plain) {
open(HTML,"| $Tab $Tabargs >$HTML") || die "Could not open $HTML to write output";
} else {
open(HTML,">$HTML") || die "Could not open $HTML to write output";
}
}
if ( $Web ) {
printf HTML "
$Title
$Title
Last Database Update: $Datetag
";
while () {
print HTML;
}
print HTML "Tab Separated Value report
";
if ( $Plain ) {
print HTML "";
print HTML "";
} else {
print HTML "
";
}
foreach $kk ( @Out ) {
my $caps = $kk;
$caps =~ tr/[a-z]/[A-Z]/;
if ($Plain) {
printf HTML "$caps\t";
} else {
printf HTML " %s | \n",$Yellow,$caps;
}
}
if ($Plain) {
printf HTML "
\n";
} else {
printf HTML "
\n\n";
}
# So we leave off here waiting for data fill into table
}
if ( $Tsv ) {
$EDIT = "*EDIT*";
printf TSV "### Last Data Base Update: $Datetag";
printf TSV "### EDIT column must contain A (append), C (change), D (delete), or N (no change)\n";
foreach $kk ( 0 .. $#Out ) {
my $caps = $Out[$kk];
$caps =~ tr/[a-z]/[A-Z]/;
printf TSV "%s\t",$caps;
}
printf TSV "$EDIT\n";
}
# if ( $Print ) {
# print "*** Writing PRN file $PRN\n" if ($Verbose);
# open(PRN,">$PRN") || die "Could not open $PRN to write output";
# foreach $jj ( 1..$#Fields ) { # set the %Length array to 0
# $Length{$Fields[$jj]} = 0;
# }
# }
#################################################################
# This is the major branch to fill the table
#################################################################
if (!$NoneSelected) {
foreach $ii (0 .. $#Work) {
&Format($Work[$ii]);
}
} else {
if ( $Web ) {
printf HTML "No documents were selected
\n
";
printf TSV "\nNo documents were selected\n";
}
}
printf HTML "
\n" if ($Web && !$Plain);
printf HTML "";
printf HTML "\n\n" if ( $Web );
chmod(0755, "$HTML") if ( $Web ); # req. for include to work
}
#######################################################################
# HTML readers only wrap lines on blank space, so guarantee some
# A line is passed in, a line with perhaps extra blank space is returned
# (Adding extra space doesn't affect HTML commands/formatting at all!)
#######################################################################
sub Wrap {
my $rets = $_[0];
my $halfmax = $MAXWORD*2/3;
my $splits = '.,;:-';
return $rets if ($rets !~ /\S{$MAXWORD},/);
$rets =~ s/(\S{$halfmax}[^$splits]*[$splits])/$1 /g;
return $rets if ($rets !~ /\S{$MAXWORD,}/);
$rets =~ s/(\S{$MAXWORD})/$1 /g;
return $rets;
}
######################################################################
# Pod follows
# NB the CSS addition makes possible the desired indent with
# =over/=item...=item/=back construct when used in an HTML context
########################################################################
=for html
=head2 NAME
dbreport -- Extracts data froom a compressed data base according to a template
=head2 USAGE
dbreport [-hpw] [-d dirname] [-f filename] [-l dirname] [-L dirname]
[-n field1,field2,...] [-o filename] [-t filename]
[-T document_title] [start_record [final_record]
=head2 FLAGS
-d[irecotry] puts results in the named directory;
"./data/" is the default output directory
-f[ile] uses the follwoing file name as the data source;
if file_name is "-", uses STDIN;
"./parts.cdb" is the detault data source
-h[elp] produces this help message
-l[ink] following dir_name is top of the directory tree in Unix space for links;
default is to use "./file_cabinet/"
-L[ink] following dir name is top of the directory tree in Web space for links;
default is to use "./"
-n[names] outputs data only for the named fields;
default is to output data for all fields
-o[utput] uses following name for output files;
default is "##-data", where ## is the Project No.
-p[lain] produes "simple" HTML output; i.e.: no tables
-s[paces] substitues hard spaces for each ".." in text
-t[abs] file contains tab spacing for use in plain output
default is "./parts.tdb"
-T[itle] use the following text string as a report title
-v[ervose] produces diagnostics on STDOUT
-w[eb] produces HTML and TSV output files (default)
If a file parts.pdb exists, it is read as a list of file suffixes
for which document links are valid; if no such file exists, the
default is PDF, TXT.
In generating an HTML file for the output, after some
preliiminaries the contents of the file C is copied to
the output prior to the actual record data being written.
If no record number is given, the entire data base is processed
If one one record number is given, only that record and all its
sub-records are processed.
=head2 DESCRIPTION
Subject to all the flags listed above, by default this program takes a
set of data records from a file C and generates an
HTML-formatted file displaying the contents of the data base. Links
to all available displayable documents are placed on the primary
document numbers. Links to the sub-directories containing all the
relevant documents are placed on the revision field.
If the search for a link fails for a given document, a parallel
universe of the data base prefaced by "itar" will be scanned.
The program C is called in "plain" mode to generate explicit
no-break-spaces for HTML in lieu of tabs. C is passed the
contents of "parts.tdb" as arguments if available. (The default
output mode is to produce one long HTML table.)
In parallel with the HTML output, a tab-separated-value file is
generated, suitable for importing into spreadsheet programs.
=head2 BUGS
Alternatives to the file C should be available via a flag
on the command line.
=head2 SEE ALSO
=head4 High Level programs
dbnormal
=head4 Low Level programs/files
base.html
parts.cdb
parts.tdb
tabset
=head2 AUTHOR
Bob Goeke
=head2 RCS Information
$Id: dbreport,v 2.17 2020/08/02 00:16:56 goeke Exp goeke $
=cut
######################################################################
######################################################################
# History
######################################################################
# $Log: dbreport,v $
# Revision 2.17 2020/08/02 00:16:56 goeke
# Added required Accessibility footer to web output
#
# Revision 2.16 2018/09/11 18:00:16 goeke
# Substitute 3 hard spaces for each ".." (plain only)
#
# Revision 2.15 2017/12/20 16:45:25 goeke
# Allow for 3-digit project ID when scanning for HTML links
#
# Revision 2.14 2014/04/10 18:19:56 goeke
# Added links to paralell itar directory under "file_cabinet"
#
# Revision 2.13 2014/04/10 14:54:33 goeke
# Edit regex check on Field_names
#
# Revision 2.12 2013/07/22 14:44:46 goeke
# Fixed bug in not displaying link to TSV file in plain output
# Updated pod & help to reference the TSV file
#
# Revision 2.11 2013/07/22 13:12:29 goeke
# Modified call to tabset to read parts.tdb for args
#
# Revision 2.10 2013/07/22 00:26:53 goeke
# Add pod
#
# Revision 2.9 2013/07/17 19:24:55 goeke
# Clean up display of table formatted database
#
# Revision 2.8 2013/04/10 15:40:48 goeke
# Add *EDIT* column and comment to TSV output for use in editing
#
# Revision 2.7 2007/06/04 14:41:40 goeke
# Minor info updates; use /usr/bin/env on first line
#
# Revision 2.6 2006/05/25 19:20:49 goeke
# Cleaned up logic in AddLinks() to fix bug in use of *pdb files
#
# Revision 2.5 2006/01/13 15:15:45 goeke
# Use *.pdb file to define those file suffixes which will link to a drawing
# number for one-click display -- default to *.pdf and *.txt
#
# Revision 2.4 2005/11/17 16:29:20 goeke
# Added EASM files as special case
# Fixed bug in html output on database update line
#
# Revision 2.3 2005/09/15 18:45:01 goeke
# Added handlers for *.easm files
# Added blank lines between major drawing numbers in web/plain output
#
# Revision 2.2 2005/01/06 16:32:31 goeke
# Added -L flag to separate out Unix and Web file spaces
#
# Revision 2.1 2004/12/30 16:01:26 goeke
# Typo in printf statement for TSV output
#
# Revision 2.0 2004/12/29 16:45:27 goeke
# Clean up script for adding prefix to drawing number;
# Fix bug in display of rev when drawing not in the file cabinet
#
# Revision 1.15 2004/12/28 21:39:29 goeke
# Bug fixes and cleanup
#
# Revision 1.14 2004/12/23 19:11:40 goeke
# Fixed bug in cross-link tags
#
# Revision 1.13 2004/12/21 21:57:59 goeke
# Internal cross-ref links implemented
#
# Revision 1.12 2004/12/21 13:54:39 goeke
# Fixed link pick up (though ref links aren't working yet).
#
# Revision 1.11 2004/12/20 20:07:05 goeke
# Allow generation of plain (non-table) HTML file
#
# Revision 1.10 2004/12/20 15:47:59 goeke
# Formatted verbose messages to start with "***" string
#
# Revision 1.9 2004/12/20 14:15:29 goeke
# Add explicit line wrap on table cells
#
# Revision 1.8 2004/12/14 16:29:55 goeke
# A large variety of bug fixes for use as a general database dumper
#
# Revision 1.7 2004/09/28 19:13:45 goeke
# Fix bug in adding link to .txt files
#
# Revision 1.6 2004/07/08 14:36:58 goeke
# Moved position of data base date in TSV output
#
# Revision 1.5 2004/06/29 01:14:52 goeke
# Added links to HTML version
# Fixed bug in single drawing select
#
# Revision 1.3 2004/06/23 19:15:54 goeke
# Add/modify logic to output all daughter documents if only one number given.
#
# Revision 1.2 2004/06/21 16:08:10 goeke
# Accept explicit output file names
# Merge -t flag into -w[eb]
#
# Revision 1.1 2004/06/18 19:21:54 goeke
# Pass title text in; add cdb file date to reports
#
# Revision 1.0 2004/06/18 15:24:25 goeke
# Both HTML and TSV files being generated
#
# Revision 0.5 2004/06/18 13:44:12 goeke
# Fixed various bugs in hash in &Format
#
# Revision 0.4 2004/06/17 19:56:47 goeke
# Hash field contents, only for requested output data
#
# Revision 0.3 2004/06/17 17:56:23 goeke
# Add working directory arg; changed single field logic
#
# Revision 0.2 2004/06/17 15:50:05 goeke
# Fixed bugs in field name select and tsv and web select
#
# Revision 0.1 2004/06/17 15:17:53 goeke
# Just status; only TSV is functional
#
#
#
######################################################################
######################################################################