Next / Previous / Contents / Shipman's homepage

23.12. MonthCell.__daySummary(): Render the daily summary block

This method renders the day-summary content for one day-notes.

noteweb
# - - -   M o n t h C e l l . _ _ d a y S u m m a r y

    def __daySummary ( self, parent, dayNotes ):
        '''Render the daily summary block.

          [ (parent is an et.Element) and
            (dayNotes is a DayNotes instance) ->
              parent  +:=  a div class=DAY_SUMMARY_CLASS element
                  representing the daily summary for dayNotes ]
        '''

The entire content of this block is wrapped inside div class='day-summary'. If there are any notable records for the day, they are added just inside it: see Section 23.8, “MonthCell.__notablesBlock(): Display any notable records”.

noteweb
        #-- 1 --
        # [ parent  :=  parent with a new div element added with
        #               class-DAY_SUMMARY_CLASS
        #   summaryDiv  :=  that div element ]
        summaryDiv  =  et.SubElement ( parent, 'div' )
        summaryDiv.attrib['class']  =  DAY_SUMMARY_CLASS

        #-- 2 --
        # [ if dayNotes contains any notable records ->
        #     summaryDiv  +:=  a div element containing the
        #                      names from all notable records
        #   else -> I ]
        self.__notablesBlock ( summaryDiv, dayNotes )

Next we list the localities for the day; see Section 23.13, “MonthCell.__locDef(): Display a locality definition”.

noteweb
        #-- 3 --
        # [ summaryDiv  +:=  blocks displaying the localities
        #       in dayNotes.daySummary ]
        for loc in dayNotes.daySummary.genLocs():
            self.__locDef ( summaryDiv, loc )

Rounding out the daily summary block are the day-annotation elements; see Section 23.14, “MonthCell.__dayAnnotation(): Render day-annotation content”.

noteweb
        #-- 4 --
        # [ summaryDiv  +:=  blocks displaying day-annotation
        #       content from dayNotes.daySummary, if any ]
        self.__dayAnnotation ( summaryDiv, dayNotes.daySummary )

23.12.1. Historical note

In the output of the XSLT script that was the predecessor of noteweb, it was tedious to determine the location code for any given bird form:

  • The default location code was displayed at the top of the daily summary block, followed by the list of that day's location codes and their definitions.

  • Under each bird form, the location code was displayed only for records that were not at the default location.

So the reader's process for determining the locality of a record was:

  • If the bird form record shows no location, find the location code shown as the “Default location,” then look up the code in the table of locations.

  • If the bird form record shows a location code, look that up in the table of locations.

A better solution is to show the full-length locality name on each bird form record. This means we don't need to show the default location code at all; it's just an artifact of the file encoding (for the convention of the data entry worker).

The only reason for the old, ugly rendering was that the author found it difficult to implement in straight XSLT. Have a look at the old birdhtml.xsl if you like. It was put up as a stopgap before the birdnotes.py package was written.