|
Packit Service |
c5cf8c |
#! /usr/bin/env perl
|
|
Packit Service |
c5cf8c |
# -*- mode: perl; -*-
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# Create an index of web pages for MPICH
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# Default values
|
|
Packit Service |
c5cf8c |
# Root for the pages
|
|
Packit Service |
c5cf8c |
$WWWRoot=`pwd`;
|
|
Packit Service |
c5cf8c |
chop $WWWRoot;
|
|
Packit Service |
c5cf8c |
# Base address (installation address)
|
|
Packit Service |
c5cf8c |
# $URLBase = "http://";
|
|
Packit Service |
c5cf8c |
# End of line character (\r\n is DOS-friendly)
|
|
Packit Service |
c5cf8c |
$eol = "\r\n";
|
|
Packit Service |
c5cf8c |
# Number of colums in table of names
|
|
Packit Service |
c5cf8c |
$TableCols = 3;
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# Process arguments for any changes
|
|
Packit Service |
c5cf8c |
foreach $_ (@ARGV) {
|
|
Packit Service |
c5cf8c |
if (/-?(-[^=]*)=(.*)/) {
|
|
Packit Service |
c5cf8c |
$argname = $1;
|
|
Packit Service |
c5cf8c |
$argval = $2;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
$argname = $1;
|
|
Packit Service |
c5cf8c |
$argval = "";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if ($argname =~ /-wwwroot/) {
|
|
Packit Service |
c5cf8c |
$WWWRoot = $argval;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
elsif ($argname =~ /-urlbase/) {
|
|
Packit Service |
c5cf8c |
$URLBase = $argval;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
elsif ($argname eq "-help") {
|
|
Packit Service |
c5cf8c |
print STDOUT "createhtmlindex [ -wwwroot=directory ] [ -urlbase=base ]\n";
|
|
Packit Service |
c5cf8c |
print STDOUT "Build the www index pages for MPICH.";
|
|
Packit Service |
c5cf8c |
print STDOUT "This must be run in the root of an MPICH tree; it may\n
|
|
Packit Service |
c5cf8c |
be run in a VPATH directory after configuring.\n";
|
|
Packit Service |
c5cf8c |
exit 1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
print STDERR "Unknown argument $_\n";
|
|
Packit Service |
c5cf8c |
exit 1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Create the main index
|
|
Packit Service |
c5cf8c |
open( OUTFD, ">$WWWRoot/www/index.html" ) ||
|
|
Packit Service |
c5cf8c |
die "Cannot open $WWWRoot/www/index.html\n";
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
&AddHeader( "Web pages for MPI" );
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
print OUTFD "MPI Commands$eol";
|
|
Packit Service |
c5cf8c |
&AddDirectoryContents( "www", "www1" );
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
print OUTFD "MPI Routines and Constants$eol";
|
|
Packit Service |
c5cf8c |
if (-f "www/www3/mpi.cit") {
|
|
Packit Service |
c5cf8c |
&createRedirects("www/www3", "mpi.cit");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
print STDERR "Could not find mapping file\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
&AddDirectoryContents( "www", "www3" );
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#print OUTFD "MPE Routines$eol";
|
|
Packit Service |
c5cf8c |
#&AddDirectoryContents( "www", "www4" );
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
&AddTrailer( );
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
close( OUTFD );
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Create the sectional indices
|
|
Packit Service |
c5cf8c |
open( OUTFD, ">$WWWRoot/www/www1/index.htm" ) ||
|
|
Packit Service |
c5cf8c |
die "Cannot open $WWWRoot/www/www1/index.htm\n";
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
&AddHeader( "Manpages for MPICH" );
|
|
Packit Service |
c5cf8c |
&AddDirectoryContents( "www/www1", "." );
|
|
Packit Service |
c5cf8c |
&AddTrailer( );
|
|
Packit Service |
c5cf8c |
close( OUTFD );
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
open( OUTFD, ">$WWWRoot/www/www3/index.htm" ) ||
|
|
Packit Service |
c5cf8c |
die "Cannot open $WWWRoot/www/www3/index.htm\n";
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
&AddHeader( "Web pages for MPI Routines and Constants" );
|
|
Packit Service |
c5cf8c |
&AddDirectoryContents( "www/www3", "." );
|
|
Packit Service |
c5cf8c |
&AddTrailer( );
|
|
Packit Service |
c5cf8c |
close( OUTFD );
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# open( OUTFD, ">$WWWRoot/www/www4/index.htm" ) ||
|
|
Packit Service |
c5cf8c |
# die "Cannot open $WWWRoot/www/www4/index.htm\n";
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# &AddHeader( "Web pages for MPE Routines" );
|
|
Packit Service |
c5cf8c |
# &AddDirectoryContents( "www/www4", "." );
|
|
Packit Service |
c5cf8c |
# &AddTrailer( );
|
|
Packit Service |
c5cf8c |
# close( OUTFD );
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
0;
|
|
Packit Service |
c5cf8c |
# ---------------------------------------------------------------------------
|
|
Packit Service |
c5cf8c |
# Support routines.
|
|
Packit Service |
c5cf8c |
# All write to OUTFD and use $eol for end-of-line
|
|
Packit Service |
c5cf8c |
# ---------------------------------------------------------------------------
|
|
Packit Service |
c5cf8c |
sub AddHeader {
|
|
Packit Service |
c5cf8c |
my $title = $_[0];
|
|
Packit Service |
c5cf8c |
print OUTFD "<HTML>$eol<HEAD>$eol<TITLE>$title</TITLE>$eol";
|
|
Packit Service |
c5cf8c |
print OUTFD "$eol";
|
|
Packit Service |
c5cf8c |
print OUTFD "</HEAD>$eol<BODY BGCOLOR=\"FFFFFF\">$eol";
|
|
Packit Service |
c5cf8c |
print OUTFD "$title$eol";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
sub AddTrailer {
|
|
Packit Service |
c5cf8c |
print OUTFD "</BODY>$eol</HTML>$eol";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# For the items (mostly MPI constants) that are within a single web page,
|
|
Packit Service |
c5cf8c |
# create a redirect page for them. This allows us to point to a location
|
|
Packit Service |
c5cf8c |
# on the page, rather than just a page which is what a file link would
|
|
Packit Service |
c5cf8c |
# accomplish
|
|
Packit Service |
c5cf8c |
sub createRedirects {
|
|
Packit Service |
c5cf8c |
$rootdir = $_[0];
|
|
Packit Service |
c5cf8c |
$mapfile = $_[1];
|
|
Packit Service |
c5cf8c |
open( MAPFD, "<$rootdir/$mapfile" ) || die "Cannot open map file $mapfile\n";
|
|
Packit Service |
c5cf8c |
while (<MAPFD>) {
|
|
Packit Service |
c5cf8c |
@fields = split(/\+/);
|
|
Packit Service |
c5cf8c |
$name = $fields[1];
|
|
Packit Service |
c5cf8c |
$url = $fields[8];
|
|
Packit Service |
c5cf8c |
if ($url =~ /(.*)\/([^\/]*)\.([HTMLhtml]*)#(.*)/) {
|
|
Packit Service |
c5cf8c |
$rooturl = $1;
|
|
Packit Service |
c5cf8c |
$basefile = $2;
|
|
Packit Service |
c5cf8c |
$ext = $3;
|
|
Packit Service |
c5cf8c |
$anchor = $4;
|
|
Packit Service |
c5cf8c |
if ($basefile ne $anchor) {
|
|
Packit Service |
c5cf8c |
open(RFD, ">$rootdir/$anchor.htm") || die "Cannot open redirect file $anchor.htm\n";
|
|
Packit Service |
c5cf8c |
print RFD "<html><head><meta http-equiv=\"refresh\" content=\"0; url=$basefile.$ext#$anchor\" /></head></html>\n";
|
|
Packit Service |
c5cf8c |
close RFD;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
print STDERR "Could not decode $url\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
close MAPFD;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Take all .htm and .html files and add them to the OUTFD file.
|
|
Packit Service |
c5cf8c |
# This works in two steps:
|
|
Packit Service |
c5cf8c |
# 1. Read and sort the contents of the directory into the array
|
|
Packit Service |
c5cf8c |
# @HTMLFiles
|
|
Packit Service |
c5cf8c |
# 2. Use the routine MakeHTMLTable to create a table with a given
|
|
Packit Service |
c5cf8c |
# number of columns, adding the links within the columns
|
|
Packit Service |
c5cf8c |
@HTMLFiles = ();
|
|
Packit Service |
c5cf8c |
# Look in $1/$2 for files, but make links relative to $2
|
|
Packit Service |
c5cf8c |
sub AddDirectoryContents {
|
|
Packit Service |
c5cf8c |
my $rootdir = $_[0];
|
|
Packit Service |
c5cf8c |
my $dirname = $_[1];
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# 1 Read the files
|
|
Packit Service |
c5cf8c |
@HTMLFiles = ();
|
|
Packit Service |
c5cf8c |
opendir DIR, "$rootdir/$dirname";
|
|
Packit Service |
c5cf8c |
if ($dirname eq ".") {
|
|
Packit Service |
c5cf8c |
$prefixname = "";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
$prefixname = "$dirname/";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
while ($filename = readdir DIR) {
|
|
Packit Service |
c5cf8c |
if ($filename =~ /index\.html?/) { next; }
|
|
Packit Service |
c5cf8c |
if ($filename =~ /.*\.html?$/) {
|
|
Packit Service |
c5cf8c |
$HTMLFiles[$#HTMLFiles+1] = "$prefixname$filename";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
closedir DIR;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
@HTMLFiles = sort( @HTMLFiles );
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Format the table
|
|
Packit Service |
c5cf8c |
&MakeHTMLTable;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
# MakeHTMLTable takes an array of items and turns them into a table with
|
|
Packit Service |
c5cf8c |
# $TableCols columns.
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
sub MakeHTMLTable {
|
|
Packit Service |
c5cf8c |
my $nvals = $#HTMLFiles;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
my $nrows = int ( ($nvals + $TableCols - 1) / $TableCols );
|
|
Packit Service |
c5cf8c |
print OUTFD "$eol";
|
|
Packit Service |
c5cf8c |
for ($j=0; $j<$nrows; $j++) {
|
|
Packit Service |
c5cf8c |
print OUTFD "";
|
|
Packit Service |
c5cf8c |
for ($e=0; $e<$TableCols; $e++) {
|
|
Packit Service |
c5cf8c |
$filename = $HTMLFiles[$j + $e * $nrows];
|
|
Packit Service |
c5cf8c |
$linkname = $filename;
|
|
Packit Service |
c5cf8c |
$linkname =~ s/\.html?//;
|
|
Packit Service |
c5cf8c |
$linkname =~ s/.*\///;
|
|
Packit Service |
c5cf8c |
if ($filename ne "") {
|
|
Packit Service |
c5cf8c |
$line = "$linkname";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
$line = "";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
print OUTFD "$line$eol";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
print OUTFD "$eol";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
print OUTFD "$eol";
|
|
Packit Service |
c5cf8c |
}
|