#! /usr/bin/env perl # # Copyright (c) 2001 Tama Communications Corporation # # 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, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # usage: makehtml.pl [-v] skelton-file ... # # skelton-file: # +------------------------------- # |@title # |@link <link name for anchor> # |@license # |<license for this file> # |@body # |... ############################################################ # Definitions ############################################################ # # String # $l_year = '2000,2001,2002,2003,2004,2005,2006'; $l_company = 'Tama Communications Corporation'; $l_name = 'Shigio Yamaguchi'; $l_copyright = 'Copyright (c)'; $l_statement = "$l_copyright $l_year $l_company"; $l_biglogo = 'globe.png'; $l_smalllogo = 'sglobe.png'; $l_GFDL = 'Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2'; # # Color # $c_bgcolor = '#ffffff'; $c_text = '#000000'; $c_link = '#1f00ff'; $c_alink = '#ff0000'; $c_vlink = '#7B68EE'; $c_menucolor = '#dcdcdc'; $c_titlecolor = '#660000'; # Size $w_menuwidth = '100'; $hr = "<hr width=100% size=3 align=left noshade>\n"; # # Parts # sub start_html { "<!doctype html public \"-//W3C//DTD HTML 3.2 Final//EN\">\n" . "<html>\n" . "<head>\n" . "<title>$_[0]\n" . "\n" . "\n" . "\n" . "\n"; } sub end_html { "\n"; } sub logobox { my($title, $fontsize, $logo) = @_; "\n" . "\n" . "\n" . "\n" . "\n" . "
\n" . "$title\n" . "\n" . "[image of the globe]\n" . "
\n"; } sub title { "

$_[0]

\n"; } sub home_title { logobox("

$_[0]

", 4, $l_biglogo) . "

\n" . "$l_copyright $l_year $l_company" . "

\n"; } sub copyright { my($msg) = $l_statement; $msg .= '
'; $msg .= $l_GFDL; return logobox($msg, -1, $l_smalllogo); } sub get_version { my($infile) = 'version.texi'; my($val); open(INFILE, "$infile") || die("cannot open '$infile'\n"); while () { if (/^\@set VERSION (.*)$/) { $val = $1; } } close(INFILE); if (!$val) { die("Version number not found in '$infile'\n"); } $val; } # End of definitions ############################################################ while ($ARGV[0] =~ /^-/) { $opt = shift; if ($opt eq '-v') { $verbose = 1; } } $version = get_version(); $total = @ARGV; # # Making %outfile, %title, %link, %body for each @ARGV. # for ($i = 0; $i < $total; $i++) { my($infile, $outfile, $skip); $infile = $outfile = $ARGV[$i]; $outfile =~ s/\.[^.]+/.html/; $outfile{$infile} = $outfile; open(INFILE, "$infile") || die("cannot open '$infile'\n"); $license = 0; while () { if ($license) { if (/^\@/) { $license = 0; } else { next; } } if (/^\@body/) { last; } elsif (/^\@title (.*)$/) { $title{$infile} = $1; } elsif (/^\@link (.*)$/) { $link{$infile} = $1; } elsif (/^\@license/) { $license = 1; } else { die("illegal skelton file format.($infile)\n"); } } if (!defined($title{$infile})) { die("\@title not found.\n"); } if (!defined($link{$infile})) { die("\@link not found.\n"); } my(@body) = ; foreach (@body) { s/\@VERSION\@/$version/g; } $body{$infile} = \@body; close(INFILE); } # # Generating html files. # for ($i = 0; $i < $total; $i++) { my($infile) = $ARGV[$i]; print STDERR "Generating $outfile{$infile} ...\n" if ($verbose); open(OUTFILE, ">$outfile{$infile}") || die("cannot open '$outfile{$infile}'\n"); # (1) Print prologue. print OUTFILE start_html($title{$infile}); print OUTFILE "\n"; print OUTFILE "\n"; print OUTFILE "GNU Project -\n"; print OUTFILE "GLOBAL / \n"; print OUTFILE "Savannah -\n"; print OUTFILE "GLOBAL\n"; print OUTFILE "\n"; print OUTFILE ""; print OUTFILE "\n"; # (2) Print menu. print OUTFILE "\n"; # (3) Print body. print OUTFILE "\n"; print OUTFILE "\n"; print OUTFILE "\n"; print OUTFILE "\n"; print OUTFILE "\n"; # (4) Print epilogue. print OUTFILE "\n"; print OUTFILE "\n"; print OUTFILE "
\n"; print OUTFILE "\n"; foreach $f (@ARGV) { print OUTFILE "

"; print OUTFILE "" if ($f ne $infile); print OUTFILE $link{$f}; print OUTFILE "" if ($f ne $infile); print OUTFILE "\n"; } print OUTFILE "\n"; print OUTFILE "

\n"; if ($infile eq 'global.in') { print OUTFILE home_title($title{$infile}); } else { print OUTFILE $hr; print OUTFILE title($title{$infile}); } print OUTFILE $hr; print OUTFILE @{$body{$infile}}; print OUTFILE "
\n"; print OUTFILE "[Top of page]\n"; print OUTFILE "\n"; print OUTFILE $hr; print OUTFILE copyright(); print OUTFILE "
\n"; print OUTFILE end_html; close(OUTFILE); }