#!/usr/bin/ksh93
################################################################
function usagemsg_menugen {
print "
Program: menugen
Create naviation and look-and-feel characteristics for a
directory of web content files.
Usage: menugen [-g]] [-S]] [-u]] [-f datafile]] | -c | -C | -h
-c = Create a default \"menugen.cfg\" file
-C = Overwrite \"menugen.cfg\" file, even if it already exists
-g = Show grandchild links in menus
-R = Position menu bar on Right side of page
-S = If the static menu bar exists, overwrite it with the default
-f = Use data file specified by value \"datafile\"
-u = Underline Menu Links
-n = Generate .html files
-v = Verbose mode
-V = Very Verbose mode
-h = Display help file
Author: Dana French (dfrench@mtxia.com) Copyright 2005
\"Autocontent Enabled\"
"
}
################################################################
####
#### Description
####
#### "menugen" is a shell script that provides the ability to
#### easily maintain and modify web based documentation.
#### This script creates a standard "look-and-feel" for user
#### supplied HTML based content, and generates navigation
#### links between the pages. An web server feature called
#### "Server Side Includes" (SSI) is utilized by "menugen" to
#### reference the various parts and pieces of each page.
####
#### To use "menugen", the user should create content and
#### store it in files called "XXXXXXXX.content.shtml", where
#### XXXXXXXX is some prefix file name defined by the user.
#### "menugen" creates menus, links, headers, titles,
#### footers, contact info links, etc, based on information
#### stored in a user defined relationship file. The
#### relationship file is assumed to be in the same directory
#### with the "XXXXXXXX.content.shtml" files and is called
#### "menugen.dat".
####
#### "menugen" allows users to modify the "look-and-feel" of
#### all files in a directory by storing configuration
#### information such as colors, font sizes, title info, etc
#### in a file called "menugen.cfg".
####
#### The "-c" option will create a file called "menugen.cfg"
#### if it does not already exist. If it does exist it will
#### not overwrite it. To recreate the "menugen.cfg" file,
#### you will first have to remove it. The "menugen.cfg"
#### file contains user modifiable parameters such as font
#### colors, font sizes background color, title and contact
#### information.
####
#### One of the values defined in the "menugen.cfg" file is
#### called "THEME". This is a title which is displayed at
#### the top of every page. The title can be a two part
#### title separated by a colon (:). The part of the title
#### to the left of the colon will be displayed in a larger
#### text. The part of the title to the right of the colon
#### will be displayed in italics and a smaller text. All
#### values in the configuration file may be changed to suit
#### the users particular needs. The "menugen.cfg" file MUST
#### be executeable.
####
#### The "menugen" program creates a menu file for each page
#### which contains the relationships between each page, its
#### parent page, and its child pages. The links displayed
#### on the menu by default are that of the parent and
#### children of each page. The "-g" option causes the
#### grandchildren of each page to also be included in the
#### menu.
####
#### Normally, if the static menu bar file exists, it is not
#### overwritten in order to preserve any user customization
#### of that file. However the "-S" option will cause the
#### static menubar file to be overwritten with the default
#### values. The static menu bar file is "staticbar.shtml".
####
#### The datafile describes the relationships between all the
#### web pages in the current directory. The relationship
#### between the pages is maintained via parent/child
#### references. By default the relationships are read from
#### a file called "menugen.dat" in the current directory.
#### The "-f" option allows the user to specify a different
#### file name. The datafile has the following format:
####
#### PARENTCURRENTSHORT DESCRIPTION
####
#### PARENT and CURRENT are file name prefixes and are
#### usually limited to 8 characters or less. TAB characters
#### between the fields is mandatory. PARENT is the parent
#### of the CURRENT page. The SHORT DESCRIPTION is a
#### description of the CURRENT page. An example of datafile
#### would be:
####
#### NULL index Home Page
#### index child1 Child 1 of index
#### index child2 Child 2 of index
#### index child3 Child 3 of index
#### child1 child11 Child 1 of child1
#### child1 child12 Child 2 of child1
#### child1 child13 Child 3 of child1
#### child1 child14 Child 4 of child1
#### child2 child21 Child 1 of child2
#### child2 child22 Child 2 of child2
#### child2 child23 Child 3 of child2
#### child3 child31 Child 1 of child3
#### child3 child32 Child 2 of child3
####
#### In this example, the page "index" has three child pages
#### called "child1", "child2", and "child3". The menu on
#### the "index" page would reference these three pages. The
#### page "child1" has four child pages called "child11",
#### "child12", "child13", "child14". The menu on the
#### "child1" page would reference these four pages. And so
#### on for child pages "child2" and "child3".
####
#### The "-h" option displays this help file and is assumed
#### to reside in the file called
#### "/usr/local/sh/README.menugen".
####
#### Most graphical web browsers will show hypertext links as
#### underlined text of a different color than normal text.
#### When this program creates the menu bars, the links are
#### configured NOT to have underlines. If you want
####
#### the links in the menu bars to have underlines, use the
#### "-u" option.
####
#### Assumptions:
####
#### It is assumed that a file exists which describes a
#### parent-child relationship for each document. The format
#### of this file assumes the first column contains the
#### prefix name of the parent document, the second column
#### contains the prefix name of the child document, and the
#### third column contains a very short description (16 char or
#### less), of the child document.
####
#### The "content" files are assumed to be in the same
#### directory as the "menugen.dat" file.
####
#### Dependencies:
####
#### This script requires a "menugen.dat" file be created by
#### the user, which is normally a manual process, however
#### can be automated depending upon desired usage.
####
#### Products:
####
#### This script generates various parts and pieces
#### comprising the look-and-feel of the web pages. This
#### includes a title (title.shtml), header (X.shtml), footer
#### (footer.shtml), dynamic navigation links (X.menu.shtml),
#### static navigation links (staticbar.shtml), and a
#### configuration file (menugen.cfg). "X" in the above file
#### names represents the filename prefix of each page
#### identified in the "menugen.dat" file.
####
#### Configured Usage:
####
#### This script is written to be used as a command line
#### program, but can be scheduled to run through cron or any
#### other scheduling system. If scheduled, the current
#### directory must be the same as the directory containing
#### the "menugen.dat" file.
####
#### Details:
################################################################
################################################################
####
####
#### The "mkconfig" function checks for or creates a
#### configuration file for the "menugen" program. This
#### configuration file contains several parameter settings
#### that control text, color, font, sizes, etc.
####
#### If the "menugen" configuration file already exists, do not
#### overwrite it, simply return with a non-zero exit code.
#### If the "menugen" configuration file does not exist,
#### create it and exit with a zero exit code.
####
################################################################
mkconfig()
{
if [[ -f "./menugen.cfg" ]]
then
print "\"menugen.cfg\" file already exists, not overwritten"
return 1
fi
print "THEME=\"Default Theme: Default Subtheme\" # Title displayed at top of every page" > ./menugen.cfg
print "CLR_TEXT=\"#000000\" # Text color (default=#000000)" >> ./menugen.cfg
print "CLR_BACKGRD=\"#FFFFFF\" # Background color (default=#FFFFFF)" >> ./menugen.cfg
print "CLR_LINK=\"#0000FF\" # Link color (default=#0000FF)" >> ./menugen.cfg
print "CLR_ALINK=\"#777700\" # Active Link color (default=#777700)" >> ./menugen.cfg
print "CLR_VLINK=\"#770000\" # Viewed Link color (default=#770000)" >> ./menugen.cfg
print "CLR_MENUBORDER=\"#ABADC9\" # Menu Border color (default=#ABADC9)" >> ./menugen.cfg
print "CLR_MENUBG=\"#DDDDDD\" # Menu Background color (default=#DDDDDD)" >> ./menugen.cfg
print "CLR_MENUTEXT=\"#000000\" # Menu Text color (default=#000000)" >> ./menugen.cfg
print "SIZ_BASEFONT=\"4\" # Base Font Size (default=4)" >> ./menugen.cfg
print "CONTACT_NAME=\"Dana French\" # Person responsible for this Page (default=Dana French)" >> ./menugen.cfg
print "CONTACT_EMAIL=\"dfrench@mtxia.com\" # Email address of person responsible for this page (default=dfrench@mtxia.com)" >> ./menugen.cfg
chmod 755 ./menugen.cfg
print "\"menugen.cfg\" file was created in the current directory."
return 0
}
################################################################
####
#### The "mg_footer" function outputs the "footer" section of
#### the HTML pages, containing the information from the
#### "configuration" file.
####
################################################################
mg_footer()
{
print "