devhtml:
@echo "Making developers html"
+ ./translate_images.pl --from_meaningful_names developers.html
@cp -fp ${IMAGES}/*.eps .
latex2html -white -no_subdir -split 0 -toc_stars -white -notransparent \
developers >/dev/null
- ./translate_images.pl developers.html
+ ./translate_images.pl --to_meaningful_names developers.html
@rm -f *.eps *.gif *.jpg *.old
@rm -rf bacula/*
@cp -fp ${IMAGES}/*.eps .
@rm -f next.eps next.png prev.eps prev.png up.eps up.png
-# @cp -fp ${IMAGES}/*.eps ${IMAGES}/*.png *.txt bacula
@cp -fp ${IMAGES}/*.eps *.txt bacula
@rm -f bacula/next.eps bacula/next.png bacula/prev.eps bacula/prev.png bacula/up.eps bacula/up.png
latex2html -split 4 -local_icons -t "Bacula User's Guide" -long_titles 4 \
devweb:
@echo "Making developers web"
@mkdir -p developers
- @rm -f developers/*
+ ./translate_images.pl --from_meaningful_names developers/Developers_Guide.html
+ @rm -f developers/*.html
@cp -fp ${IMAGES}/*.eps .
@rm -f next.eps next.png prev.eps prev.png up.eps up.png
- @cp -fp ${IMAGES}/*.eps ${IMAGES}/*.png developers/
+ @cp -fp ${IMAGES}/*.eps developers/
@rm -f developers/next.eps developers/next.png developers/prev.eps developers/prev.png developers/up.eps developers/up.png
latex2html -split 5 -local_icons -t "Developer's Guide" -long_titles 4 \
-contents_in_nav -toc_stars -white -notransparent developers >/dev/null
- ./translate_images.pl developers/Developers_Guide.html
+ ./translate_images.pl --to_meaningful_names developers/Developers_Guide.html
@cp -f developers/Developers_Guide.html developers/index.html
@rm -f *.eps *.gif *.jpg developers/*.eps *.old
#
use strict;
+# Used to change the names of the image files generated by latex2html from imgxx.png
+# to meaningful names. Provision is made to go either from or to the meaningful names.
+# The meaningful names are obtained from a file called imagename_translations, which
+# is generated by extensions to latex2html in the make_image_file subroutine in
+# bacula.perl.
+
# Opens the file imagename_translations and reads the contents into a hash.
+# The hash is creaed with the imgxx.png files as the key if processing TO
+# meaningful filenames, and with the meaningful filenames as the key if
+# processing FROM meaningful filenames.
# Then opens the html file(s) indicated in the command-line arguments and
# changes all image references according to the translations described in the
# above file. Finally, it renames the image files.
#
# Original creation: 3-27-05 by Karl Cunningham.
+# Modified 5-21-05 to go FROM and TO meaningful filenames.
#
my $TRANSFILE = "imagename_translations";
my $path;
# Loads the contents of $TRANSFILE file into the hash referenced in the first
-# argument.
+# argument. The hash is loaded to translate old to new if $direction is 0,
+# otherwise it is loaded to translate new to old. In this context, the
+# 'old' filename is the meaningful name, and the 'new' filename is the
+# imgxx.png filename. It is assumed that the old image is the one that
+# latex2html has used as the source to create the imgxx.png filename.
+# The filename extension is taken from the file
sub read_transfile {
- my $trans = shift;
+ my ($trans,$direction) = @_;
+
+ if (!open IN,"<$path$TRANSFILE") {
+ print "WARNING: Cannot open image translation file $path$TRANSFILE for reading\n";
+ print " Image filename translation aborted\n\n";
+ exit 0;
+ }
- open IN,"<$path$TRANSFILE" or die "Cannot open image translation file $path$TRANSFILE for reading\n";
while (<IN>) {
chomp;
my ($new,$old) = split(/\001/);
- # The filename extension of the new one must be made to be the old one.
- my ($ext) = $new =~ /.*(\..*)$/;
- $old =~ s/(.*)\..*$/$1$ext/;
- $trans->{$new} = $old;
+
+ # Old filenames will usually have a leading ./ which we don't need.
+ $old =~ s/^\.\///;
+
+ # The filename extension of the old filename must be made to match
+ # the new filename because it indicates the encoding format of the image.
+ my ($ext) = $new =~ /(\.[^\.]*)$/;
+ $old =~ s/\.[^\.]*$/$ext/;
+ if ($direction == 0) {
+ $trans->{$new} = $old;
+ } else {
+ $trans->{$old} = $new;
+ }
}
close IN;
}
# the file contents are then written. No particular care is taken to ensure that the
# file is not lost if a system failure occurs at an inopportune time. It is assumed
# that the html files being processed here can be recreated on demand.
+#
+# Links to other files are added to the %filelist for processing. That way,
+# all linked files will be processed (assuming they are local).
sub translate_html {
my ($filename,$trans,$filelist) = @_;
my ($contents,$out,$this,$img,$dest);
$filename =~ /^(http|ftp|mailto)\:/ and return 0;
$filename =~ s/^file\:\/\///;
# Load the contents of the html file.
- open IF,"<$path$filename" or die "Cannot open $path$filename for reading\n";
+ if (!open IF,"<$path$filename") {
+ print "WARNING: Cannot open $path$filename for reading\n";
+ print " Image Filename Translation aborted\n\n";
+ exit 0;
+ }
+
while (<IF>) {
$contents .= $_;
}
print OF $out;
close OF;
- # Now look for any links to other files.
+ # Now look for any links to other files and add them to the list of files to do.
while ($out =~ /\<\s*A[^\>]*HREF=\"(.*?)\"/si) {
$out = $';
$dest = $1;
foreach (keys(%$translate)) {
$response = `mv -f $path$_ $path$translate->{$_} 2>&1`;
- $response and die $response;
+ $response and print "ERROR from system $response\n";
}
}
# any links to other files are added to the %filelist. A hash of processed
# files is kept so we don't do any twice.
+# The first argument must be either --to_meaningful_names or --from_meaningful_names
+
my (%translate,$search_regex,%filelist,%completed,$thisfile);
-my $cnt;
+my ($cnt,$direction);
+
+my $arg0 = shift(@ARGV);
+$arg0 =~ /^(--to_meaningful_names|--from_meaningful_names)$/ or
+ die "ERROR: First argument must be either \'--to_meaningful_names\' or \'--from_meaningful_names\'\n";
+
+$direction = ($arg0 eq '--to_meaningful_names') ? 0 : 1;
(@ARGV) or die "ERROR: Filename(s) to process must be given as arguments\n";
($path) = $tmp =~ /(.*\/)/;
$path = '' unless $path;
-read_transfile(\%translate);
+read_transfile(\%translate,$direction);
foreach (@ARGV) {
# Strip the path from the filename, and use it later on.
- s/(.*\/)//;
- $path = $1;
- $path = '' unless $path;
+ if (s/(.*\/)//) {
+ $path = $1;
+ } else {
+ $path = '';
+ }
$filelist{$_} = '';
while ($thisfile = (keys(%filelist))[0]) {
delete($filelist{$thisfile});
$completed{$thisfile} = '';
}
- print "translate_images.pl: $cnt images translated to meaningful names\n";
+ print "translate_images.pl: $cnt image filenames translated ",($direction)?"from":"to"," meaningful names\n";
}
rename_images(\%translate);
html:
@echo "Making html"
+ ./translate_images.pl --from_meaningful_names bacula.html
@cp -fp ${IMAGES}/*.eps .
latex2html -white -no_subdir -split 0 -toc_stars -white -notransparent \
bacula >/dev/null
- ./translate_images.pl bacula.html
+ ./translate_images.pl --to_meaningful_names bacula.html
@rm -f *.eps *.gif *.jpg *.old
devhtml:
web:
@echo "Making web"
@mkdir -p bacula
- @rm -rf bacula/*
+ ./translate_images.pl --from_meaningful_names bacula/Bacula_Users_Guide.html
+ @rm -rf bacula/*.html
@cp -fp ${IMAGES}/*.eps .
@rm -f next.eps next.png prev.eps prev.png up.eps up.png
@cp -fp ${IMAGES}/*.eps *.txt bacula
@rm -f bacula/next.eps bacula/next.png bacula/prev.eps bacula/prev.png bacula/up.eps bacula/up.png
latex2html -split 4 -local_icons -t "Bacula User's Guide" -long_titles 4 \
-toc_stars -contents_in_nav -white -notransparent bacula >/dev/null
- ./translate_images.pl bacula/Bacula_Users_Guide.html
+ ./translate_images.pl --to_meaningful_names bacula/Bacula_Users_Guide.html
@cp -f bacula/Bacula_Users_Guide.html bacula/index.html
@rm -f *.eps *.gif *.jpg bacula/*.eps *.old
#
use strict;
+# Used to change the names of the image files generated by latex2html from imgxx.png
+# to meaningful names. Provision is made to go either from or to the meaningful names.
+# The meaningful names are obtained from a file called imagename_translations, which
+# is generated by extensions to latex2html in the make_image_file subroutine in
+# bacula.perl.
+
# Opens the file imagename_translations and reads the contents into a hash.
+# The hash is creaed with the imgxx.png files as the key if processing TO
+# meaningful filenames, and with the meaningful filenames as the key if
+# processing FROM meaningful filenames.
# Then opens the html file(s) indicated in the command-line arguments and
# changes all image references according to the translations described in the
# above file. Finally, it renames the image files.
#
# Original creation: 3-27-05 by Karl Cunningham.
+# Modified 5-21-05 to go FROM and TO meaningful filenames.
#
my $TRANSFILE = "imagename_translations";
my $path;
# Loads the contents of $TRANSFILE file into the hash referenced in the first
-# argument.
+# argument. The hash is loaded to translate old to new if $direction is 0,
+# otherwise it is loaded to translate new to old. In this context, the
+# 'old' filename is the meaningful name, and the 'new' filename is the
+# imgxx.png filename. It is assumed that the old image is the one that
+# latex2html has used as the source to create the imgxx.png filename.
+# The filename extension is taken from the file
sub read_transfile {
- my $trans = shift;
+ my ($trans,$direction) = @_;
+
+ if (!open IN,"<$path$TRANSFILE") {
+ print "WARNING: Cannot open image translation file $path$TRANSFILE for reading\n";
+ print " Image filename translation aborted\n\n";
+ exit 0;
+ }
- open IN,"<$path$TRANSFILE" or die "Cannot open image translation file $path$TRANSFILE for reading\n";
while (<IN>) {
chomp;
my ($new,$old) = split(/\001/);
- # The filename extension of the new one must be made to be the old one.
- my ($ext) = $new =~ /.*(\..*)$/;
- $old =~ s/(.*)\..*$/$1$ext/;
- $trans->{$new} = $old;
+
+ # Old filenames will usually have a leading ./ which we don't need.
+ $old =~ s/^\.\///;
+
+ # The filename extension of the old filename must be made to match
+ # the new filename because it indicates the encoding format of the image.
+ my ($ext) = $new =~ /(\.[^\.]*)$/;
+ $old =~ s/\.[^\.]*$/$ext/;
+ if ($direction == 0) {
+ $trans->{$new} = $old;
+ } else {
+ $trans->{$old} = $new;
+ }
}
close IN;
}
# the file contents are then written. No particular care is taken to ensure that the
# file is not lost if a system failure occurs at an inopportune time. It is assumed
# that the html files being processed here can be recreated on demand.
+#
+# Links to other files are added to the %filelist for processing. That way,
+# all linked files will be processed (assuming they are local).
sub translate_html {
my ($filename,$trans,$filelist) = @_;
my ($contents,$out,$this,$img,$dest);
$filename =~ /^(http|ftp|mailto)\:/ and return 0;
$filename =~ s/^file\:\/\///;
# Load the contents of the html file.
- open IF,"<$path$filename" or die "Cannot open $path$filename for reading\n";
+ if (!open IF,"<$path$filename") {
+ print "WARNING: Cannot open $path$filename for reading\n";
+ print " Image Filename Translation aborted\n\n";
+ exit 0;
+ }
+
while (<IF>) {
$contents .= $_;
}
print OF $out;
close OF;
- # Now look for any links to other files.
+ # Now look for any links to other files and add them to the list of files to do.
while ($out =~ /\<\s*A[^\>]*HREF=\"(.*?)\"/si) {
$out = $';
$dest = $1;
foreach (keys(%$translate)) {
$response = `mv -f $path$_ $path$translate->{$_} 2>&1`;
- $response and die $response;
+ $response and print "ERROR from system $response\n";
}
}
# any links to other files are added to the %filelist. A hash of processed
# files is kept so we don't do any twice.
+# The first argument must be either --to_meaningful_names or --from_meaningful_names
+
my (%translate,$search_regex,%filelist,%completed,$thisfile);
-my $cnt;
+my ($cnt,$direction);
+
+my $arg0 = shift(@ARGV);
+$arg0 =~ /^(--to_meaningful_names|--from_meaningful_names)$/ or
+ die "ERROR: First argument must be either \'--to_meaningful_names\' or \'--from_meaningful_names\'\n";
+
+$direction = ($arg0 eq '--to_meaningful_names') ? 0 : 1;
(@ARGV) or die "ERROR: Filename(s) to process must be given as arguments\n";
($path) = $tmp =~ /(.*\/)/;
$path = '' unless $path;
-read_transfile(\%translate);
+read_transfile(\%translate,$direction);
foreach (@ARGV) {
# Strip the path from the filename, and use it later on.
- s/(.*\/)//;
- $path = $1;
- $path = '' unless $path;
+ if (s/(.*\/)//) {
+ $path = $1;
+ } else {
+ $path = '';
+ }
$filelist{$_} = '';
while ($thisfile = (keys(%filelist))[0]) {
delete($filelist{$thisfile});
$completed{$thisfile} = '';
}
- print "translate_images.pl: $cnt images translated to meaningful names\n";
+ print "translate_images.pl: $cnt image filenames translated ",($direction)?"from":"to"," meaningful names\n";
}
rename_images(\%translate);
html:
@echo "Making html"
+ ./translate_images.pl --from_meaningful_names bacula.html
@cp -fp ${IMAGES}/*.eps .
latex2html -white -no_subdir -split 0 -toc_stars -white -notransparent \
bacula >/dev/null
- ./translate_images.pl bacula.html
+ ./translate_images.pl --to_meaningful_names bacula.html
@rm -f *.eps *.gif *.jpg
devhtml:
web:
@echo "Making web"
@mkdir -p bacula
- @rm -rf bacula/*
+ ./translate_images.pl --from_meaningful_names bacula/Bacula_Users_Guide.html
+ @rm -rf bacula/*.html
@cp -fp ${IMAGES}/*.eps .
@rm -f next.eps next.png prev.eps prev.png up.eps up.png
# @cp -fp ${IMAGES}/*.eps ${IMAGES}/*.png *.txt bacula
@rm -f bacula/next.eps bacula/next.png bacula/prev.eps bacula/prev.png bacula/up.eps bacula/up.png
latex2html -split 4 -local_icons -t "Bacula User's Guide" -long_titles 4 \
-toc_stars -contents_in_nav -white -notransparent bacula >/dev/null
- ./translate_images.pl bacula/Bacula_Users_Guide.html
+ ./translate_images.pl --to_meaningful_names bacula/Bacula_Users_Guide.html
@cp -f bacula/Bacula_Users_Guide.html bacula/index.html
@cp -f bacula/Bacula_Freque_Asked_Questi.html bacula/faq.html
@rm -f *.eps *.gif *.jpg bacula/*.eps *.old
#
use strict;
+# Used to change the names of the image files generated by latex2html from imgxx.png
+# to meaningful names. Provision is made to go either from or to the meaningful names.
+# The meaningful names are obtained from a file called imagename_translations, which
+# is generated by extensions to latex2html in the make_image_file subroutine in
+# bacula.perl.
+
# Opens the file imagename_translations and reads the contents into a hash.
+# The hash is creaed with the imgxx.png files as the key if processing TO
+# meaningful filenames, and with the meaningful filenames as the key if
+# processing FROM meaningful filenames.
# Then opens the html file(s) indicated in the command-line arguments and
# changes all image references according to the translations described in the
# above file. Finally, it renames the image files.
#
# Original creation: 3-27-05 by Karl Cunningham.
+# Modified 5-21-05 to go FROM and TO meaningful filenames.
#
my $TRANSFILE = "imagename_translations";
my $path;
# Loads the contents of $TRANSFILE file into the hash referenced in the first
-# argument.
+# argument. The hash is loaded to translate old to new if $direction is 0,
+# otherwise it is loaded to translate new to old. In this context, the
+# 'old' filename is the meaningful name, and the 'new' filename is the
+# imgxx.png filename. It is assumed that the old image is the one that
+# latex2html has used as the source to create the imgxx.png filename.
+# The filename extension is taken from the file
sub read_transfile {
- my $trans = shift;
+ my ($trans,$direction) = @_;
+
+ if (!open IN,"<$path$TRANSFILE") {
+ print "WARNING: Cannot open image translation file $path$TRANSFILE for reading\n";
+ print " Image filename translation aborted\n\n";
+ exit 0;
+ }
- open IN,"<$path$TRANSFILE" or die "Cannot open image translation file $path$TRANSFILE for reading\n";
while (<IN>) {
chomp;
my ($new,$old) = split(/\001/);
- # The filename extension of the new one must be made to be the old one.
- my ($ext) = $new =~ /.*(\..*)$/;
- $old =~ s/(.*)\..*$/$1$ext/;
- $trans->{$new} = $old;
+
+ # Old filenames will usually have a leading ./ which we don't need.
+ $old =~ s/^\.\///;
+
+ # The filename extension of the old filename must be made to match
+ # the new filename because it indicates the encoding format of the image.
+ my ($ext) = $new =~ /(\.[^\.]*)$/;
+ $old =~ s/\.[^\.]*$/$ext/;
+ if ($direction == 0) {
+ $trans->{$new} = $old;
+ } else {
+ $trans->{$old} = $new;
+ }
}
close IN;
}
# the file contents are then written. No particular care is taken to ensure that the
# file is not lost if a system failure occurs at an inopportune time. It is assumed
# that the html files being processed here can be recreated on demand.
+#
+# Links to other files are added to the %filelist for processing. That way,
+# all linked files will be processed (assuming they are local).
sub translate_html {
my ($filename,$trans,$filelist) = @_;
my ($contents,$out,$this,$img,$dest);
$filename =~ /^(http|ftp|mailto)\:/ and return 0;
$filename =~ s/^file\:\/\///;
# Load the contents of the html file.
- open IF,"<$path$filename" or die "Cannot open $path$filename for reading\n";
+ if (!open IF,"<$path$filename") {
+ print "WARNING: Cannot open $path$filename for reading\n";
+ print " Image Filename Translation aborted\n\n";
+ exit 0;
+ }
+
while (<IF>) {
$contents .= $_;
}
print OF $out;
close OF;
- # Now look for any links to other files.
+ # Now look for any links to other files and add them to the list of files to do.
while ($out =~ /\<\s*A[^\>]*HREF=\"(.*?)\"/si) {
$out = $';
$dest = $1;
foreach (keys(%$translate)) {
$response = `mv -f $path$_ $path$translate->{$_} 2>&1`;
- $response and die $response;
+ $response and print "ERROR from system $response\n";
}
}
# any links to other files are added to the %filelist. A hash of processed
# files is kept so we don't do any twice.
+# The first argument must be either --to_meaningful_names or --from_meaningful_names
+
my (%translate,$search_regex,%filelist,%completed,$thisfile);
-my $cnt;
+my ($cnt,$direction);
+
+my $arg0 = shift(@ARGV);
+$arg0 =~ /^(--to_meaningful_names|--from_meaningful_names)$/ or
+ die "ERROR: First argument must be either \'--to_meaningful_names\' or \'--from_meaningful_names\'\n";
+
+$direction = ($arg0 eq '--to_meaningful_names') ? 0 : 1;
(@ARGV) or die "ERROR: Filename(s) to process must be given as arguments\n";
($path) = $tmp =~ /(.*\/)/;
$path = '' unless $path;
-read_transfile(\%translate);
+read_transfile(\%translate,$direction);
foreach (@ARGV) {
# Strip the path from the filename, and use it later on.
- s/(.*\/)//;
- $path = $1;
- $path = '' unless $path;
+ if (s/(.*\/)//) {
+ $path = $1;
+ } else {
+ $path = '';
+ }
$filelist{$_} = '';
while ($thisfile = (keys(%filelist))[0]) {
delete($filelist{$thisfile});
$completed{$thisfile} = '';
}
- print "translate_images.pl: $cnt images translated to meaningful names\n";
+ print "translate_images.pl: $cnt image filenames translated ",($direction)?"from":"to"," meaningful names\n";
}
rename_images(\%translate);