Generate sorted-by-classification pages.

This commit is contained in:
gdr 1998-01-17 21:27:25 +00:00
parent a029903025
commit 6ca306ec57

View File

@ -1,10 +1,93 @@
#! /usr/bin/perl #! /usr/bin/perl
# This script makes the generated files used by the describe(1) web
# page. It's not pretty, but it works.
#
# Devin Reade, January 1998.
#
# $Id: mkgen,v 1.2 1998/01/17 21:27:25 gdr Exp $
#
$gnohome_internal = "/home/gno/public_html"; $gnohome_internal = "/home/gno/public_html";
$gnohome_external = "http://www.gno.org/gno"; $gnohome_external = "http://www.gno.org/gno";
$basedir = "/home/gno/public_html/describe/gen"; $gendir = "describe/gen"; # relative to $gnohome_*
$entrydir = "describe/entry"; # relative to $gnohome_* $entrydir = "describe/entry"; # relative to $gnohome_*
$basedir = $gnohome_internal . '/' . $gendir;
$headinfo =
'<!-- This page is auto-generated -->' . "\n" .
'<META name="description" content="List of Utilities for GNO/ME">' . "\n".
'<META name="keywords" content="Apple IIgs ORCA/Shell James Brookes">'
. "\n".
'<BASE HREF="http://www.gno.org/">'. "\n";
$bodyinfo =
'<BODY background="icons/bluebg.jpg" text="#000000" bgcolor="#00C0FF"'.
' link="#0000FF" alink="#001177" vlink="#001177">' . "\n";
$tailinfo =
'<hr>' . "\n" .
'Comments on this page should be forwarded to Devin Reade at' . "\n" .
'<A HREF="mailto:gdr@eddore.myrias.com">gdr@eddore.myrias.com</A>' . "\n" .
'<p>' . "\n" .
'<A HREF="http://www.visi.com/~nathan/a2/a2viewable.html">' . "\n" .
'<img alt="Apple II Viewable Page" height=31 width=88 border=0' . "\n" .
'src="icons/a2viewable.gif"></A>' . "\n" .
'<br>' . "\n" .
'</body>' . "\n" .
'</html>';
$categoryMap{""} = "";
$categoryMap{"gno/archive"} = "archive";
$categoryMap{"gno/comm"} = "comm";
$categoryMap{"gno/daemons"} = "daemon";
$categoryMap{"gno/doc.utils"} = "docutil";
$categoryMap{"gno/editors"} = "edit";
$categoryMap{"gno/file.convert"} = "file.convert";
$categoryMap{"gno/file.manip"} = "file.manip";
$categoryMap{"gno/games"} = "games";
$categoryMap{"gno/graphics"} = "graphics";
$categoryMap{"gno/gui"} = "gui";
$categoryMap{"gno/languages"} = "lang";
$categoryMap{"gno/libraries"} = "lib";
$categoryMap{"gno/mail"} = "mail";
$categoryMap{"gno/network"} = "network";
$categoryMap{"gno/news"} = "news";
$categoryMap{"gno/patches"} = "patch";
$categoryMap{"gno/programming"} = "prog";
$categoryMap{"gno/scripting"} = "script";
$categoryMap{"gno/shells"} = "shells";
$categoryMap{"gno/sounds"} = "sound";
$categoryMap{"gno/sys"} = "sys";
$categoryMap{"gno/sysadmin"} = "sysadmin";
$categoryMap{"gno/text.utils"} = "text";
$categoryMap{"orca/scripting"} = "script";
$categoryMap{"unsorted"} = "unsorted";
$categoryNames{"archive"} = "Archiving Utilities";
$categoryNames{"comm"} = "Communications Utilities";
$categoryNames{"daemon"} = "Daemons";
$categoryNames{"docutil"} = "Documentation Utilities";
$categoryNames{"edit"} = "Editors, Word Processors, and Document " .
"Viewers";
$categoryNames{"file.convert"} = "File Conversion Utilities";
$categoryNames{"file.manip"} = "File Manipulation Utilities";
$categoryNames{"games"} = "Games";
$categoryNames{"graphics"} = "Graphics Programs";
$categoryNames{"gui"} = "GUI";
$categoryNames{"lang"} = "Programming Languages";
$categoryNames{"lib"} = "Libraries";
$categoryNames{"mail"} = "Mail Readers";
$categoryNames{"network"} = "Networking Utilities";
$categoryNames{"news"} = "News Readers";
$categoryNames{"patch"} = "Patch Programs";
$categoryNames{"prog"} = "Programming Utilities";
$categoryNames{"script"} = "Scripting Utilities";
$categoryNames{"shells"} = "Shells";
$categoryNames{"sound"} = "Sound and Music Utilities";
$categoryNames{"sys"} = "System Utilities";
$categoryNames{"sysadmin"} = "System Administration Utilities";
$categoryNames{"text"} = "Text Manipulation Utilities";
$categoryNames{"unsorted"} = "Utilities Not Yet Sorted";
while (<>) { while (<>) {
($name, $classes) = split; ($name, $classes) = split;
@ -16,6 +99,7 @@ while (<>) {
$currentLetter = ''; $currentLetter = '';
foreach $f (@sorted) { foreach $f (@sorted) {
# create the describe entry # create the describe entry
open(pp, "/usr/local/bin/describe $f|") open(pp, "/usr/local/bin/describe $f|")
|| die ("couldn't open pipe to 'describe $f'"); || die ("couldn't open pipe to 'describe $f'");
@ -23,17 +107,17 @@ foreach $f (@sorted) {
open(fp2, "> $filename") || die("couldn't open $filename"); open(fp2, "> $filename") || die("couldn't open $filename");
printf(fp2 printf(fp2
"<html>\n" . "<html>\n" .
"<!-- This page is auto-generated -->\n" .
"<head>\n" . "<head>\n" .
"<title>Apple IIgs Describe Database -- " . $f . "</title>\n" . "<title>Apple IIgs Describe Database -- %s</title>\n" .
"</head>\n" . "</head>%s" .
"<body bgcolor=#ffffff>\n" . "<body bgcolor=#ffffff>\n" .
"<h1>Describe Entry for " . $f . "</h1>\n" . "<h1>Describe Entry for %s</h1>\n" .
"<pre>\n"); "<pre>\n",
$f, $headinfo, $f);
while($_ = <pp>) { while($_ = <pp>) {
printf(fp2 "%s", $_); printf(fp2 "%s", $_);
} }
printf(fp2 "</pre><hr></body></html>\n"); printf(fp2 "</pre>\n%s\n", $tailinfo);
close(fp2); close(fp2);
close(pp); close(pp);
@ -41,7 +125,7 @@ foreach $f (@sorted) {
$l = substr($f, 0, 1); $l = substr($f, 0, 1);
if ($l ne $currentLetter) { if ($l ne $currentLetter) {
($currentLetter eq '') || ($currentLetter eq '') ||
(printf(fp "</ul><hr></body></html>\n") && close(fp)); (printf(fp "</ul>%s\n", $tailinfo) && close(fp));
$filename = $basedir . '/' . $l . '.html'; $filename = $basedir . '/' . $l . '.html';
open(fp, "> $filename") || die("couldn't open $filename"); open(fp, "> $filename") || die("couldn't open $filename");
$currentLetter = $l; $currentLetter = $l;
@ -49,21 +133,33 @@ foreach $f (@sorted) {
$cap =~ tr/a-z/A-Z/; $cap =~ tr/a-z/A-Z/;
printf(fp printf(fp
"<html>\n" . "<html>\n" .
"<!-- This page is auto-generated -->\n" .
"<head>\n" . "<head>\n" .
"<title>Apple IIgs Describe Database -- Index by " . $cap . "<title>Apple IIgs Describe Database -- Index by %s</title>\n".
"</title>\n" . "%s\n" .
"</head>\n" . "</head>\n" .
"<body bgcolor=#ffffff>\n" . "%s\n" .
"<h1>Describe Entries by Name: " . $cap . "</h1>\n" . "<h1>Describe Entries by Name: %s</h1>\n" .
"<ul>\n"); "<ul>\n",
$cap, $headinfo, $bodyinfo, $cap);
} }
printf(fp "<li><A HREF=\"%s/%s/%s.html\">%s</A>\n", printf(fp "<li><A HREF=\"%s/%s/%s.html\">%s</A>\n",
$gnohome_external, $entrydir, $f, $f); $gnohome_external, $entrydir, $f, $f);
# save the category for later
@catlist = split(/:/, $namelist{$f});
foreach $catentry (@catlist) {
if (!defined($categoryMap{$catentry})) {
printf(stderr "WARNING: Unregistered category \"%s\" for %s: " .
"skipped\n",
$catentry, $f);
} elsif ($categoryMap{$catentry} ne '') {
$categories{$categoryMap{$catentry}} .= $f . ':';
}
}
} }
($currentLetter eq '') || ($currentLetter eq '') ||
(printf(fp "</ul><hr></body></html>\n") && close(fp)); (printf(fp "</ul>\n%s\n", $tailinfo) && close(fp));
$letters = "a b c d e f g h i j k l m n o p q r s t u v w x y z"; $letters = "a b c d e f g h i j k l m n o p q r s t u v w x y z";
@letter = split(/\s+/, $letters); @letter = split(/\s+/, $letters);
@ -84,8 +180,73 @@ foreach $l (@letter) {
"<body bgcolor=#ffffff>\n" . "<body bgcolor=#ffffff>\n" .
"<H1>Empty Page</H1>\n" . "<H1>Empty Page</H1>\n" .
"There are currently no utilities registered that begin ". "There are currently no utilities registered that begin ".
"with " . $cap . ".<p>\n" . "with " . $cap . ".<p>%s\n",
"</body></html>\n"); $tailinfo);
close(fp);
}
}
#
# Now do them by category
#
@catkeys = keys(%categories);
foreach $k (@catkeys) {
$file = $basedir . '/' . $k . '.html';
open(fp, "> $basedir/$k.html") || die("could not open $basedir/$k.html");
printf(fp
"<html>\n" .
"<head>\n" .
"<title>Apple IIgs Describe Database -- By Category</title>\n" .
"%s\n" .
"</head>\n" .
"%s\n",
$headinfo, $bodyinfo);
if (defined($categoryNames{$k})) {
printf(fp
"<h1>%s</h1><hr>\n",
$categoryNames{$k});
} else {
printf(stderr "WARNING: No category name for \"%s\"\n", $k);
}
printf(fp "<ul>\n");
@files = sort(split(/:/, $categories{$k}));
foreach $f (@files) {
printf(fp "<li><A HREF=\"%s/%s/%s.html\">%s</A>\n",
$gnohome_external, $entrydir, $f, $f);
}
printf(fp "</ul>\n%s\n", $tailinfo);
close(fp);
}
# make category pages for which there is no entry
@catkeys = values(%categoryMap);
foreach $k (@catkeys) {
$filename = $basedir . "/" . $k . '.html';
if (! -f $filename) {
open(fp, ">$filename") || die("couldn't open $filename: $!");
printf(fp
"<html>\n" .
"<!-- This page is auto-generated -->\n" .
"<head>\n" .
"<title>Apple IIgs Describe Database -- By Category</title>\n" .
"%s\n" .
"</head>\n" .
"%s\n",
$headinfo, $bodyinfo);
if (defined($categoryNames{$k})) {
printf(fp
"<h1>%s</h1><hr>\n",
$categoryNames{$k});
} else {
printf(stderr "WARNING: No category name for \"%s\"\n", $k);
}
printf(fp
"There are currently no <b>describe</b>(1) entries in this ".
"category.\n" .
"%s\n", $tailinfo);
close(fp); close(fp);
} }
} }