#!/usr/bin/ksh93 ################################################################ if [ -s "./menugen.cfg" ] then if [ ! -x "./menugen.cfg" ] then if ! chmod 755 "./menugen.cfg" then echo "Unable to make \"menugen.cfg\" executable" exit 6 fi fi . ./menugen.cfg fi THEME="${THEME:-'Default Theme: Default Subtheme'}" CLR_TEXT="${CLR_TEXT:-'#000000'}" CLR_BACKGRD="${CLR_BACKGRD:-'#FFFFFF'}" CLR_LINK="${CLR_LINK:-'#0000FF'}" CLR_ALINK="${CLR_ALINK:-'#777700'}" CLR_VLINK="${CLR_VLINK:-'#770000'}" CLR_MENUBORDER="${CLR_MENUBORDER:-'#ABADC9'}" CLR_MENUBG="${CLR_MENUBG:-'#DDDDDD'}" CLR_MENUTEXT="${CLR_MENUTEXT:-'#000000'}" SIZ_BASEFONT="${SIZ_BASEFONT:-'4'}" CONTACT_NAME="${CONTACT_NAME:-'Dana French'}" CONTACT_EMAIL="${CONTACT_EMAIL:-'dfrench@mtxia.com'}" DATAFILE="menugen.dat" GRANDCHILD="0" HTMLFILES="0" MENUPOS="left" ################################################################ syntax() { [ "_${1}" != "_" ] && ( echo ""; echo "${1}" ) echo "" echo "Syntax: menugen [-g] [-S] [-u] [-f datafile] | -c | -C | -h" echo " -c = Create a default \"menugen.cfg\" file" echo " -C = Overwrite \"menugen.cfg\" file, even if it already exists" echo " -g = Show grandchild links in menus" echo " -R = Position menu box on Right side of page" echo " -S = If the static menu bar exists, overwrite it with the default" echo " -f = Use data file specified by value \"datafile\"" echo " -u = Underline Menu Links" echo " -n = Generate .html files" echo " -h = Display help file" echo "" } ################################################################ mkconfig() { if [ -f "./menugen.cfg" ] then echo "\"menugen.cfg\" file already exists, not overwritten" return 1 fi echo "THEME=\"Default Theme: Default Subtheme\" # Title displayed at top of every page" > ./menugen.cfg echo "CLR_TEXT=\"#000000\" # Text color (default=#000000)" >> ./menugen.cfg echo "CLR_BACKGRD=\"#FFFFFF\" # Background color (default=#FFFFFF)" >> ./menugen.cfg echo "CLR_LINK=\"#0000FF\" # Link color (default=#0000FF)" >> ./menugen.cfg echo "CLR_ALINK=\"#777700\" # Active Link color (default=#777700)" >> ./menugen.cfg echo "CLR_VLINK=\"#770000\" # Viewed Link color (default=#770000)" >> ./menugen.cfg echo "CLR_MENUBORDER=\"#ABADC9\" # Menu Border color (default=#ABADC9)" >> ./menugen.cfg echo "CLR_MENUBG=\"#DDDDDD\" # Menu Background color (default=#DDDDDD)" >> ./menugen.cfg echo "CLR_MENUTEXT=\"#000000\" # Menu Text color (default=#000000)" >> ./menugen.cfg echo "SIZ_BASEFONT=\"4\" # Base Font Size (default=4)" >> ./menugen.cfg echo "CONTACT_NAME=\"Dana French\" # Person responsible for this Page (default=Dana French)" >> ./menugen.cfg echo "CONTACT_EMAIL=\"dfrench@mtxia.com\" # Email address of person responsible for this page (default=dfrench@mtxia.com)" >> ./menugen.cfg chmod 755 ./menugen.cfg echo "\"menugen.cfg\" file was created in the current directory." return 0 } ################################################################ mg_footer() { echo "

For information regarding this page, contact ${CONTACT_NAME} ( ${CONTACT_EMAIL} )

" } ################################################################ mg_hr() { echo "
 
" } ################################################################ mg_staticbar() { echo " " if [ "_${UNDERLINE}" != "_1" ] then echo " " fi echo "

TXU | Documentation | Mt Xia

" if [ "_${UNDERLINE}" != "_1" ] then echo " " fi echo " " } ################################################################ mg_titlebar() { THEME1="${THEME}" THEME2=" " if echo "${THEME}" | grep ":" > /dev/null 2>&1 then THEME1="${THEME%%:*}" THEME2="${THEME#*:}" fi echo "


${THEME1}:
${THEME2}

" } ################################################################ for OPT in "$@" do case "${OPT}" in "-c") mkconfig; exit 3;; "-C") rm -f "./menugen.cfg"; mkconfig; exit 5;; "-h") syntax | more - "/usr/local/sh/README.menugen"; exit 4;; "-g") GRANDCHILD="1";; "-R") MENUPOS="right";; "-S") rm -f "./staticbar.shtml";; "-f") DATAFILE="${2}";; "-n") HTMLFILES="1";; "-u") UNDERLINE="1";; "-?") syntax "Help"; exit 2;; esac if [ "_${DATAFILE}" = "_" -o ! -s "${DATAFILE}" ] then syntax "Invalid data file name" exit 1 fi shift 2>/dev/null done if [ ! -s "${DATAFILE}" ] then syntax "Invalid data file" exit 1 fi echo "${DATAFILE} will be used to define pages and relationships" [ "_${GRANDCHILD}" = "_1" ] && echo "Grandchild links will be shown on menus" [ ! -f "./staticbar.shtml" ] && mg_staticbar > ./staticbar.shtml mg_titlebar > ./titlebar.shtml mg_hr > ./hr.shtml mg_footer > ./footer.shtml ################################################################ while read PARENTID1 PAGEID1 PAGENAME1 do echo "" grep "^${PAGEID1} " ${DATAFILE} > /tmp/tmp1${$}.out PARENTNAME=`grep " ${PARENTID1} " ${DATAFILE} | head -1 | sed -e "s/ /:/g;s/ /:/g" | cut -d":" -f3` echo "${PARENTNAME}" echo " ${PAGENAME1}" | tr '[a-z]' '[A-Z]' if echo "${PARENTID1}" | grep "^#" > /dev/null 2>&1 then continue fi if [[ "_${MENUPOS}" = "_right" ]] then echo " ${PAGENAME1} - ${THEME}

" > "${PAGEID1/#*\///tmp/}.shtml" else echo " ${PAGENAME1} - ${THEME}

${PAGENAME1}


" > "${PAGEID1/#*\///tmp/}.shtml" fi ################################################################ echo " " > "${PAGEID1/#*\///tmp/}.menu.shtml" if [ "_${UNDERLINE}" != "_1" ] then echo " " >> "${PAGEID1/#*\///tmp/}.menu.shtml" fi echo "

${PAGENAME1}


Current:${PAGENAME1}
Previous:${PARENTNAME} " >> "${PAGEID1/#*\///tmp/}.menu.shtml" if [ "_${PARENTNAME}" != "_Home Page" ] then echo "
Home Page" >> "${PAGEID1/#*\///tmp/}.menu.shtml" fi echo "
" >> "${PAGEID1/#*\///tmp/}.menu.shtml" while read PARENTID2 PAGEID2 PAGENAME2 do LINK="${PAGEID2}.shtml" if echo "${PAGEID2}" | grep "#" > /dev/null 2>&1 then LINK=`echo "${PAGEID2}"` fi echo " ${PAGENAME2}" echo "
${PAGENAME2}" >> "${PAGEID1/#*\///tmp/}.menu.shtml" grep "^${PAGEID2} " ${DATAFILE} > /tmp/tmp2${$}.out if [ "_${GRANDCHILD}" = "_1" ] then ICNT=0 echo "" >> "${PAGEID1/#*\///tmp/}.menu.shtml" while read PARENTID3 PAGEID3 PAGENAME3 do ICNT="1" LINK="${PAGEID3}.shtml" if echo "${PAGEID3}" | grep "#" > /dev/null 2>&1 then LINK=`echo "${PARENTID3}.shtml${PAGEID3}"` fi echo " ${PAGENAME3}" echo "
  • ${PAGENAME3}
  • " >> "${PAGEID1/#*\///tmp/}.menu.shtml" done < /tmp/tmp2${$}.out echo "
    " >> "${PAGEID1}.menu.shtml" [ "_${ICNT}" != "_0" ] && echo "
    " >> "${PAGEID1/#*\///tmp/}.menu.shtml" fi done < /tmp/tmp1${$}.out ################################################################ echo "

    " >> "${PAGEID1/#*\///tmp/}.menu.shtml" if [ "_${UNDERLINE}" != "_1" ] then echo " " >> "${PAGEID1/#*\///tmp/}.menu.shtml" fi echo " " >> "${PAGEID1/#*\///tmp/}.menu.shtml" ################################################################ if [[ "_${MENUPOS}" = "_right" ]] then echo "

    " >> "${PAGEID1/#*\///tmp/}.shtml" else echo " " >> "${PAGEID1/#*\///tmp/}.shtml" fi echo " " >> "${PAGEID1/#*\///tmp/}.shtml" if [[ ${HTMLFILES} -eq 1 ]] then echo " ${PAGENAME1} - ${THEME} " > "${PAGEID1/#*\///tmp/}.html" cat "staticbar.shtml" >> "${PAGEID1/#*\///tmp/}.html" cat "titlebar.shtml" >> "${PAGEID1/#*\///tmp/}.html" cat "hr.shtml" >> "${PAGEID1/#*\///tmp/}.html" if [[ "_${MENUPOS}" = "_right" ]] then echo "

    ${PAGENAME1}


    " >> "${PAGEID1}.html" cat "${PAGEID1}.menu.shtml" >> "${PAGEID1/#*\///tmp/}.html" echo "
    " >> "${PAGEID1/#*\///tmp/}.html" cat "${PAGEID1}.content.shtml" >> "${PAGEID1/#*\///tmp/}.html" echo "

    " >> "${PAGEID1/#*\///tmp/}.html" else cat "${PAGEID1}.menu.shtml" >> "${PAGEID1/#*\///tmp/}.html" echo "

    ${PAGENAME1}


    " >> "${PAGEID1/#*\///tmp/}.html" cat "${PAGEID1}.content.shtml" >> "${PAGEID1/#*\///tmp/}.html" fi cat "hr.shtml" >> "${PAGEID1/#*\///tmp/}.html" cat "footer.shtml" >> "${PAGEID1/#*\///tmp/}.html" echo "" >> "${PAGEID1/#*\///tmp/}.html" fi done < ${DATAFILE} rm -f /tmp/tmp1${$}.out rm -f /tmp/tmp2${$}.out