My opportunities to work on coding problems occur rarely in the office I work in. So when I was asked to figure out a menu generation problem, I was more than happy to accept. All of the content I'm working on will eventually be included on the DVD which will come included as supplemental material for a new edition of an oceanographic textbook titled Descriptive Physical Oceanography. What this means is all files included will be unchanging, static, little to no dynamic content. It is also desirable to have any materials included with the book be as self contained as possible due to the seafaring nature of oceanographic work, internet at sea may be unavailable or, when available, very expensive and slow.<br /><br />To allow the easy construction of static, self contained websites while utilizing templates and generators that use the state of the dynamic content at the time of "compile", we use a ruby gem</a> called webgen</a>. This gem allows easy creation of static websites using templates, markup languages, and a rather nifty programing language called ruby</a>.<br /><br />Webgen has a rather nice menu generation method which crawls a tree generated from the files and directories in a special folder of the webgen project. When the webgen command is run in the project directory, it crawls this folder looking for changes and updates the tree accordingly. As convenient as this was, it did not function in a way that would suit our needs based on what the very talented graphic designer had produced. The built in behavior was to create a nested unordered list</a>. What we needed it to do was only use the unordered list tag for the first level of the tree. Subsequent branches, if any, needed to be in the html div tag</a> and not be nested within the unordered list, as this both makes applying styling difficult, but also appears to be unsupported by the spec. To accomplish these changes, I needed to extend the functionality of webgen. Luckily, there was a framework in place to allow this and, thanks to the object oriented nature of ruby, I could easily inherent the functionally of built in menu generation class and simply override the methods I needed to. Just my luck, only one method need to be overridden. Bellow is the almost finished product.<br />
Code:<br /></p>

module Webgen
module Tag
include Webgen::Tag::Base
class CustomMenu < Webgen::Tag::Menu
def create_output_nested(context, tree, level = 1)
### output variable initialization ###
out = ""
out_div = ""
out = "