#!/usr/local/bin/perl # #------------------------------------------------------------------------- # # dolog.cron - A perl script used to convert Framemaker (.html) files # to HTML (.html) files. The script attempts to clean up # any stray files, such as .mif & .htags files that are # created during the conversion process. # # The script also groups the .html files by month # in the HTML archive directory by putting them in monthly # archive subdirectories. # # Version History: # # Ver. Initals Date Description # --- ------- -------- ------------------------------------- # HC1.1 saw 11/17/1997 Add capability to followup existing entries # Also won't trash entries with INDEX, PREV, or NEXT. # HC1.2 saw 11/19/1997 Rewrite squirly HTML (no more MULTICOL) so # that netscape Find works on logdir pages. # HC1.3 saw 11/20/1997 If an item is followed up by the very next # entry and if it's the only followup, # don't show it in index. # HC1.35 saw 11/20/1997 Index formatting tweaks. # (Remove seconds, more room for name) # HC1.4 saw 12/3/1997 Separate indexes for All, Only automatic, All # but automatic. # HA1.1 jv 07/12/1998 Ported HC1.4 to HA1.1 # HC1.5 saw 05/07/1999 Add a Y2K hack in the reverse sorting of directory names. Put years 9x to # the end of the sort. Will work till 2090. # HC1.6 saw 14.05.1999 During transfer from temp to finaly directory, #
/; $KEYWORD = "$`" if $tempkey =~ /
/; last; # } elsif ($line =~ /^
\n"; print OUTFILE $dayheader; if($do_runstart_stuff) { print OUTFILE_AUTO $dayheader; print OUTFILE_NOAUTO $dayheader; } $oldday = $thisday; } #=================================================================================== # print out the logbook entry line #=================================================================================== $entry_line = sprintf("%6s %s %s %-15.13s %s\n", $html_archive . "/" . $html_filename, $ENUMBER, $html_date, $html_shift, $NAMWORD, $KEYWORD ); print OUTFILE $entry_line; if($do_runstart_stuff) { if($KEYWORD=~/$auto_regexp/o) { print OUTFILE_AUTO $entry_line; } else { print OUTFILE_NOAUTO $entry_line; } } # If the followuplist consists of a single followup, and that followup has an # entry number just one more than $ENUMBER, then don't put it in the index. # Tell how many followups there are by counting " ". if($followuplist) { # $followuplist =~ s/a>, $followuplist\n"); # Don't print out followups when there is just one and it is the very next entry. if(index($followuplist," ") == rindex($followuplist," ")) { $followuplist=~/> *(\d+) +/; $nfollow = $1; if($nfollow != ($ENUMBER+1)) { print(OUTFILE "$followuplist"); if($do_runstart_stuff) { if($KEYWORD=~/$auto_regexp/o) { print(OUTFILE_AUTO "$followuplist"); } else { print(OUTFILE_NOAUTO "$followuplist"); } } } } else { print(OUTFILE "$followuplist"); if($do_runstart_stuff) { if($KEYWORD=~/$auto_regexp/o) { print(OUTFILE_AUTO "$followuplist"); } else { print(OUTFILE_NOAUTO "$followuplist"); } } } } } } } #=================================================================================== # at the end of the weekly listing put the monthly archive listings #=================================================================================== chdir( $htmldir ) || die "dolog can't chdir to $htmldir: $!\n"; opendir(HTMLARCHIVE, $htmldir ) || die "dolog can't open HTMLDIR: $!\n"; #=================================================================================== # Read and reverse sort the filenames as usual #=================================================================================== @html_array=reverse sort readdir( HTMLARCHIVE ); #=================================================================================== # Use only the filenames in the form xxxx_archive #=================================================================================== #Begin Y2K Fix @html_dirs_the1990s=reverse sort grep( /9..._archive$/, @html_array ); @html_dirs_newmillenium=reverse sort grep( /[0-8]..._archive$/, @html_array ); @html_dirs = (@html_dirs_newmillenium,@html_dirs_the1990s); #End Y2K Fix print OUTFILE "
%s %s Archive\n | \n}, $html_archive."/logdir.html", @month[substr($html_archive, 2, 2 )], substr( $html_archive, 0, 2 ) ); if($do_runstart_stuff) { $entry_line .= qq{No runs | Run Starts |
\n"; print OUTFILE $dayheader; if($do_runstart_stuff) { print OUTFILE_AUTO $dayheader; print OUTFILE_NOAUTO $dayheader; } $oldday = $thisday; } $html_date=substr( $html_filename, 2, 2 ) . "/" . substr( $html_filename, 4, 2 ) . "/" . substr( $html_filename, 0, 2 ); $html_shift=substr( $html_filename, 6, 2 ) . ":" . substr( $html_filename, 8, 2 );# . ":" . # substr( $html_filename, 10, 2 ); # open html file and retrieve the keyword and user name from the file $KEYWORD="no_key"; $NAMWORD="no_name"; $ENUMBER="0"; $followuplist = ""; open(TMPFILE,"$html_filename$htmlSuffix") || die "dolog can't open TMPFILE: $!\n"; while(chomp($line =)){ if ($line =~ /keyword=/) { $tempkey="$'" if $line =~ /keyword=/; $KEYWORD = "$`" if $tempkey =~ /
/; $KEYWORD = "$`" if $tempkey =~ //; $KEYWORD = "$`" if $tempkey =~ /
/; last; # } elsif ($line =~ /^
Followups: (.*)<\/h4>/) { } elsif ($line =~ /^
Followups:<\/h4>(.*)$/) { $followuplist = $1; } if ($line =~ /User name/) { $tempkey="$'" if $line =~ /User name/; $NAMWORD = "$`" if $tempkey =~ /<\/h4>/; } if ($line =~ /Entry number/) { @enumber = split(' ',$line); @enumber = split('<',$enumber[2]); $ENUMBER = $enumber[0]; } } close(TMPFILE); $entry_line=sprintf("
%6s %s %s %-15.13s %s\n", $html_filename, $ENUMBER, $html_date, $html_shift, $NAMWORD, $KEYWORD); print OUTFILE $entry_line; if($do_runstart_stuff) { if($KEYWORD=~/$auto_regexp/o) { print OUTFILE_AUTO $entry_line; } else { print OUTFILE_NOAUTO $entry_line; } } if($followuplist) { # $followuplist =~ s/a>, $followuplist"); print(OUTFILE "$followuplist"); if($do_runstart_stuff) { if($KEYWORD=~/$auto_regexp/o) { print(OUTFILE_AUTO "$followuplist"); } else { print(OUTFILE_NOAUTO "$followuplist"); } } } } #=================================================================================== # remove the logdir.html and replace it with the new one. Similar to the # weekly listing. #=================================================================================== unlink( "logdir.html" ); rename( "logdir.new.html", "logdir.html" ); system( "/bin/chmod 777 $logdir.html" ); system( "/bin/chown $logbook_account $logdir.html" ); printf( OUTFILE "\n" ); &print_logdirtail(OUTFILE); close( OUTFILE ); if($do_runstart_stuff) { unlink( "logdir_auto.html" ); rename( "logdir_auto.new.html", "logdir_auto.html" ); unlink( "logdir_noauto.html" ); rename( "logdir_noauto.new.html", "logdir_noauto.html" ); printf( OUTFILE_AUTO "\n" ); printf( OUTFILE_NOAUTO "\n" ); close( OUTFILE_AUTO ); close( OUTFILE_NOAUTO ); } closedir(HTMLDIR); } #=**********************************************************************=# #= =# #= =# #=**********************************************************************=# sub update_html { #======================================================================= # open the directory. If you can't then it doesn't exist so make it. #======================================================================= $archiveDir = substr( $root_filename, 0, 4 ) . $archiveSuffix . "/"; opendir( ARCHIVEDIR, $htmldir . $archiveDir ) || mkdir( $htmldir . $archiveDir, 0755 ); #======================================================================= # check if the file is a followup to a previous entry #======================================================================= open(SCAN,"<$tmpdir$root_filename.html") || die "dolog can't open $!\n"; $html_date=substr( $root_filename, 2, 2 ) . "/" . substr( $root_filename, 4, 2 ) . "/" . substr( $root_filename, 0, 2 ); $html_shift=substr( $root_filename, 6, 2 ) . ":" . substr( $root_filename, 8, 2 );# . ":" . # substr( $root_filename, 10, 2 ); $KEYWORD="no_key"; $NAMWORD="no_name"; $ENUMBER="0"; $followsup_entry=0; while(chomp($line = )){ # Need to take only first number shown here if ($line =~ //) { $followsup_entry=$1; } elsif ($line =~ />Entry number (.*)) { $entry=$1; } elsif ($line =~ /User name/) { $tempkey="$'" if $line =~ /User name/; $NAMWORD = "$`" if $tempkey =~ /<\/h4>/; } elsif ($line =~ /keyword=/) { $tempkey="$'" if $line =~ /keyword=/; $KEYWORD = "$`" if $tempkey =~ /
/; $KEYWORD = "$`" if $tempkey =~ //; $KEYWORD = "$`" if $tempkey =~ /
/; last; } } close(SCAN); if($followsup_entry) { # print "Entry $entry is a followup to $followsup_entry\n"; $followup_files{$entry}="$archiveDir$root_filename.html"; $followed_ids{$entry}=$followsup_entry; $followed_file{$followsup_entry}="x"; $followup_keywords{$entry}=sprintf("%6s %s %s %-15.13s %s", $entry, $html_date, $html_shift,$NAMWORD,$KEYWORD); } #======================================================================= # move html file into final html archive directory #======================================================================= #Don't Move it here, rewrite it # system( "/bin/mv $tmpdir$root_filename.html $htmldir$archiveDir" ); open(OUT,">$htmldir$archiveDir$root_filename.html"); print OUT "
$KEYWORD \n"; close(OUT); system( "/bin/cat $tmpdir$root_filename.html >> $htmldir$archiveDir$root_filename.html" ); open(OUT,">>$htmldir$archiveDir$root_filename.html"); print OUT "\n"; unlink "$tmpdir$root_filename.html"; system( "/bin/mv $tmpdir$root_filename*.gif $htmldir$archiveDir" ); system( "/bin/chmod 755 $htmldir$archiveDir/$root_filename*" ); # system( "/bin/chown webmgr $htmldir$archiveDir/$root_filename*" ); system( "/bin/chown $logbook_account $htmldir$archiveDir/$root_filename*" ); #print( "--> Mark:: 3\n" ); } #=**********************************************************************=# #= =# #= =# #=**********************************************************************=# sub reverse { $b cmp $a; } sub print_logdirmonthhead { my $fh = shift(@_); my $type = shift(@_); print $fh "\n"; print $fh "\n"; print $fh "$LOGTITLE Logbook \n"; print $fh "\n"; printf( $fh "Jefferson Lab $LOGTITLE Logbook for %s %s - %s
\n", @month[substr($html_archive, 2, 2 )], substr( $html_archive, 0, 2 ),$type); print $fh "\n"; # printf( $fh " }; print $fh "Main INDEX\n"); print $fh " Main INDEX\n"; } sub print_logdirhead { my $fh = shift(@_); my $type = shift(@_); print $fh "\n"; print $fh "\n"; print $fh " $LOGTITLE Logbook \n"; print $fh "\n"; print $fh "Jefferson Lab $LOGTITLE Logbook - $type
\n"; # print $fh "\n"; print $fh " \n"; print $fh "$extraheader_html"; print $fh "
\n"; print $fh "Logbook:\n"; print $fh qq{\n}; print $fh qq{
\n}; print $fh qq{}; print $fh qq{ Scrollable logbook \n}; if($do_runstart_stuff) { print $fh qq{All except run starts \n}; } print $fh qq{\n}; print $fh qq{ Preview $logbook Entries \n}; if($do_runstart_stuff) { print $fh qq{Run starts only \n}; } print $fh qq{\n}; print $fh "Other Logbooks:\n"; print $fh qq{
\n}; print $fh qq{
\n}; print $fh qq{}; print $fh qq{ Operations: ELOG \n}; print $fh qq{Cryo: CLOG \n}; print $fh qq{Software: SLOG \n}; print $fh qq{Pol Src: POLOG \n}; print $fh qq{}; print $fh qq{ FEL: FLOG \n}; print $fh qq{Hall-A: HALOG \n}; print $fh qq{Hall-B: HBLOG \n}; print $fh qq{Hall-C: HCLOG \n}; print $fh qq{\n}; print $fh qq{Other Links:\n}; print $fh qq{
\n}; print $fh qq{
\n}; #printf( $fh "}; print $fh qq{ PD Shift Plans \n}; print $fh qq{MCC Crew Chief Shift Summs \n}; print $fh qq{Short Term Schedule \n}; print $fh qq{}; print $fh qq{ Experiment Schedule \n}; print $fh qq{CEBAF status screen \n}; print $fh qq{Ops Documentation \n}; print $fh qq{Scrollable $LOGTITLE\n"); #printf( $fh " Other Links:
\n" ); #printf( $fh "\n" ); #printf( $fh " hclog FAQ's+HOWTO \n" ); #printf( $fh "
Other Links
\n" ); #printf( $fh "CEBAF status screen \n" ); #printf( $fh "Experiment Schedule \n" ); #printf( $fh "MCC short term schedule \n" ); #printf( $fh qq{Beam Information (not yet operational) \n} ); #printf( $fh " \n" ); #printf( $fh "
\n" ); } sub print_logdirtail { my $fh = shift(@_); print $fh "
\n"; print $fh qq{
\n"; print $fh "This file generated by $0 version $SCRIPT_VERSION
\n"; print $fh "If you have any comments or problems, please contact:
\n"; #printf( $fh "Valerie D. Bookwalter
\n" ); #printf( $fh "bookwalt\@cebaf.gov
\n" ); #printf( $fh "(804) 249-5802\n" ); # print $fh "Jochen Volmer
\n"; # print $fh "volmer\@cebaf.gov
\n"; # print $fh "(757) 269-5195\n"; print $fh "Stephen A. Wood
\n"; print $fh "saw\@jlab.org
\n"; print $fh "(757) 269-7367\n"; print $fh "\n"; }