This function builds the index page containing the table of links to the monthly pages. For a summary of the XHTML on this page, see Section 4.1, “XHTML for the index page”.
# - - - b u i l d I n d e x
def buildIndex ( yearCollection ):
'''Build the index page.
[ yearCollection is a YearCollection instance ->
index page +:= table of links to monthly web pages
made from yearCollection ]
'''
First we set up an empty page with appropriate navigational
links; see Section 14, “pageFrame: Set up navigation for the
index page”.
#-- 1 --
# [ page := a new tccpage2.TCCPage instance with navigation
# set up for the index page ]
page = pageFrame()
By “boilerplate” we mean the fixed content
that always starts off the index page. See Section 15, “indexBoilerplate: Fixed content for the
index page”.
#-- 2 --
# [ page.content +:= boilerplate content for the index page ]
indexBoilerplate ( page.content )
For the logic that builds the actual index, see
Section 16, “indexTable(): Build the table of
monthly links”.
#-- 3 --
# [ page.content +:= the index table made from yearCollection ]
indexTable ( page.content, yearCollection )
All that remains is to add a link to the documentation, and write the page where it goes.
#-- 4 --
# [ page.content +:= a link to this document ]
p = et.SubElement ( page.content, 'p' )
p.text = "These pages are generated automatically; see "
docLink = et.SubElement ( p, 'a', href='http://www.nmt.edu/~shipman/aba/doc/noteweb/' )
docLink.text = "the documentation"
docLink.tail = "."
#-- 5 --
# [ INDEX_PAGE_NAME+HTML_EXT can be created new ->
# that file := XHTML serialization of page ]
try:
indexName = INDEX_PAGE_NAME + HTML_EXT
indexFile = open ( indexName, 'w' )
page.write ( indexFile )
indexFile.close()
except IOError, detail:
print >>sys.stderr, ( "*** Can't write the index page "
"'%s'." % indexName )