Menu system suggestions

smith.js.8 at pg.com smith.js.8 at pg.com
Tue Nov 29 21:43:02 CET 2005


Henrik et al

I've found that the default width on the menu items does not work for some
browsers. It is just a bit too narrow. Increasing the width from 150 to 160
seems to solve the problem in every browser I can get my hands on. In the file

     server/www/menu/menu_tpl.js

change line 25 to read:

     'width': 160,



I've also found it useful to have the help system password protected. In the
file

     server/etc/hobbit-apache.conf

add the following to the end of the file:

     # See above for instructions on creating users. I generally
     # create a 'help' user for accessing this separately from
     # the administrator options.

     Alias /monitor/help/  "/home/hobbit/server/www/help/"
     <Directory "/home/hobbit/server/www/help">
         Options Indexes FollowSymLinks Includes MultiViews
         Order allow,deny
         Allow from all
         AuthUserFile /home/hobbit/server/etc/hobbitpasswd
         AuthType Basic
         AuthName "Hobbit Help"
         Require valid-user
     </Directory>

Of course, this file is created duing configuration, so I'm sure there is a
change necessary in the config system if this should become part of the
installed options.



I've also found it quite a pain to not have the hobbit menu system at the top of
the documentation pages. I have a script that makes it rather simple to add the
menu system into the entire documentation tree, post-install. The script is
pasted below.

To use it, I put the script in /server/bin and then use these commands:

#  cd /home/hobbit/server/www/help
#  for file in *.html */*.html */*/*.html
>  do
>      /home/hobbit/server/bin/hobbit-html.sh "$file" > /tmp/html.$$
>      cp /tmp/html.$$  "$file"
>  done
#  rm /tmp/html.$$

If you don't install hobbit in the root of your server (for example, I put it in
the /monitor path of my server) then you'll need to use the --path option:

>      /home/hobbit/server/bin/hobbit-html.sh --path "/monitor" "$file" >
/tmp/html.$$

Here is the hobbit-html.sh script:




#!/bin/bash
#-----------------------------------------------------------
# Program : hobbit-html.sh
# Purpose : Prepares an html file for use within the hobbit
#           monitor web system.
# Author  : Scott Smith <smith.js.8 at pg.com>
# Release : 28 Nov 2005
# License : Public Domain
#-----------------------------------------------------------

SYNTAX="syntax: ${0##*/} [--help] [--path] htmlfile"

case "$1" in
-h|"")  echo "$SYNTAX"
        exit 1
        ;;
--help) echo "$SYNTAX"
        echo " where: --path is the path prefix where Hobbit is installed"
        echo
        echo "        This is not required if Hobbit is installed relative"
        echo "        to the root / path in the URL."
        echo
        echo "        Example: If Hobbit is installed in the /monitor URL,"
        echo "        then '--path /monitor' is required in order for the"
        echo "        menu system to find its files."
        echo
        exit 1
        ;;
--path) URL="$1"
        HTML="$2"
        ;;
*)      URL=""
        HTML="$1"
        ;;
esac

[ -f "$HTML" ] || { echo "error: not found - $1" ; exit 2 ; }

awk --assign URL="$URL" -- '
    /<[/][Hh][Ee][Aa][Dd]>.*<[Bb][Oo][Dd][Yy]>/ {
        style()
        print
        body1()
        next
    }
    /<[/][Hh][Ee][Aa][Dd]>/ {
        style()
        print
        next
    }
    /<[Bb][Oo][Dd][Yy]>/ {
        print
        body1()
        next
    }
    /<[/][Bb][Oo][Dd][Yy]>/ {
        body2()
        print
        next
    }
    { print }
    function style()
    {
        print ""
        print "<!-- Styles for the menu bar -->"
        print "<link rel=\"stylesheet\" type=\"text/css\" href=\"" URL "/menu/
nu.css\">"
        print ""
    }
    function body1()
    {
        print ""
        print "<p> </p>  <!-- For the menu bar -->"
        print ""
    }
    function body2()
    {
        print ""
        print "<!-- menu script itself. you should not modify this file -->"
        print "<script type=\"text/javascript\" language=\"JavaScript\" src=\""
URL "/menu/menu.js\"></script>"
        print "<!-- items structure. menu hierarchy and links are stored there
->"
        print "<script type=\"text/javascript\" language=\"JavaScript\" src=\""
URL "/menu/menu_items.js\"></script>"
        print "<!-- files with geometry and styles structures -->"
        print "<script type=\"text/javascript\" language=\"JavaScript\" src=\""
URL "/menu/menu_tpl.js\"></script>"
        print "<script type=\"text/javascript\" language=\"JavaScript\">"
        print "        new menu (MENU_ITEMS, MENU_POS);"
        print "</script>"
        print ""
    }
' "$HTML"

fi

#EOF(hobbit-html.sh)



It appears much of the docs, in particular the man pages, is generated via a
script. I don't know how difficult it might be for these changes to become
configuration time options. However, it would be easy enough for this script to
be productized into the install if desired.

Enjoy...

Scott





More information about the Xymon mailing list