1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
#!/usr/bin/perl
###!/usr/local/bin/perl
$dd = '/'; # directory-delimiter
### $Id: makemap,v 1.4 1997/07/03 14:16:18 RRM Exp $
### File: makemap
### Written by Herbert W. Swan <dprhws@edp.Arco.com>
### Version 1.0, December 22, 1995
### This is part of the 96.1 release of LaTeX2HTML by Nikos Drakos
## Copyright (C) 1995 by Herbert W. Swan
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
## Change Log (for initials see file Changes):
## $Log: makemap,v $
## Revision 1.4 1997/07/03 14:16:18 RRM
## - added HTML comments with the USEMAP option
## - the $labels can be given as a filename (test existence) or a prefix
##
## Revision 1.3 1997/07/03 07:24:47 RRM
## - Extended to also process for client-side image-maps, via <USEMAP> tags
## - introduced a $dd directory-delimiter, for customisation
##
## Revision 1.2 1996/12/23 01:41:16 JCL
## o added informative comments and CVS log history
## o changed usage of <date> to an OS independent construction, the
## patch is from Piet van Oostrum.
## o moved most of the code into a main function
##
##
## HWS -- Dec 22, 1995 -- created
#
# LaTeX2HTML image map script
#
# NOTE: The following configuration variable MUST be set to either
# "NCSA" or "CERN" to reflect the type of server you are using;
# or "USEMAP" (AXR)
$SERVER = "NCSA";
#
# Get the command-line arguments:
#
die "Usage: makemap map_template [dest_directory]\n" unless @ARGV;
$template_file = $ARGV[0];
$dest_dir = ".";
$dest_dir = $ARGV[1] if ($#ARGV >= 1);
# print $#ARGV, ":", $dest_dir, "\n";
$map_file = "";
$Date = &get_date;
&main;
sub main {
#
# Next, try to open the template file.
#
open (TEMPLATE, "<$template_file") || die "Can't open $template_file\n";
while (<TEMPLATE>) {
next if /^(\s*\#.*|\s*)$/; # Ignore comments;
#
# Associate the contents of a labels.pl file with a URL.
#
if (/^\+(\S+)\s+(\S+)/) {
$labels = (-f ${1})? ${1} : "${1}labels.pl";
$URL = $2;
open (LABELS, "<$labels") || die "Can't open $labels\n";
while (<LABELS>) {
eval if (/^\$/);
}
close (LABELS);
next;
}
#
# Proceed to the next map file.
#
elsif (/(\S*):\s*$/) {
close (MAP) if (length($map_file));
$map_file = "$dest_dir${dd}$1";
open (MAP, ">$map_file") ||
die "Can't open $map_file for output.";
if ( $SERVER eq "USEMAP" ) {
($tag_name = $1) =~ s/\.map//g;
print (MAP "<!-- Image map, generated by makemap 1.2 at $Date\n");
print (MAP " from source $template_file using $labels -->\n\n");
print (MAP "<MAP NAME=\"$tag_name\">\n");
} else {
print (MAP "# Created by makemap 1.2\n");
print (MAP "# ", $Date);
print (MAP "#\n\n\n");
}
next;
}
#
# Continue mapping coordinates to URL's:
#
else {
$url = $_;
@array = split(/[ \t\n]+/);
$op = @array[1];
if (!/\//) {
($symbol = @array[0]) =~ s/://g;
$url = $symbol unless ($url = $external_labels{$symbol});
next unless $url;
if ($SERVER eq "NCSA") {
print MAP ("$op $url @array[2..$#array]\n");
} elsif ($SERVER eq "CERN") {
print MAP ("$op @array[2..$#array] $url\n");
} elsif ($SERVER eq "USEMAP") {
print MAP ("<AREA SHAPE=\"$op\" ALT=\"\" "
. "COORDS=\"@array[2],@array[3]\"\n HREF=\"$url\">\n");
} else {
print STDERR "Unknown map-server $SERVER, ignoring:\n";
print STDERR ("$op @array[2..$#array] $url\n");
}
} elsif ($SERVER eq "USEMAP") {
print MAP ("<AREA SHAPE=\"$op\" ALT=\"\" "
. "COORDS=\"@array[2],@array[3]\"\n HREF=\"@array[0]\">\n");
#
# Explicit URL's simply get copied.
#
} else {
print MAP ("$op @array[0] @array[2..$#array]\n");
}
}
}
#
# EOF on input. Finish up.
#
close (TEMPLATE);
print MAP "</MAP>\n" if ($SERVER eq "USEMAP");
close (MAP) if (length($map_file));
}
sub get_date {
local(@lt) = localtime;
local($d,$m,$y) = @lt[3,4,5];
sprintf("%d/%d/%d", $m+1, $d, 1900+$y);
}
|