diff options
author | Richard Darst <rkd@zgib.net> | 2009-08-31 22:40:59 (GMT) |
---|---|---|
committer | Richard Darst <rkd@zgib.net> | 2009-08-31 22:40:59 (GMT) |
commit | de2fc94184f8f1da300ee562af292dc928546ec8 (patch) | |
tree | ced3a8c375a3e4d3730119c7b84ad19e5588e84c /writers.py | |
parent | b68e348f7bcbe44ee97e30c29b67d45271054b7a (diff) |
Modularize the HTML2 writer in preparation for improvements
- This patch should not change any user-visible behavior - yet!
darcs-hash:20090831224059-82ea9-c384d4266b483d4d230c08182c5817a8bde9b3a3.gz
Diffstat (limited to 'writers.py')
-rw-r--r-- | writers.py | 118 |
1 files changed, 65 insertions, 53 deletions
@@ -300,55 +300,21 @@ class HTML(_BaseWriter): body = body%repl body = replaceWRAP(body) return body -class HTML2(_BaseWriter): - body = textwrap.dedent('''\ - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> - <html> - <head> - <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> - <title>%(pageTitle)s</title> - </head> - <body> - <h1>%(pageTitle)s</h1> - Meeting started by %(owner)s at %(starttime)s %(timeZone)s. - (<a href="%(fullLogs)s">full logs</a>)<br> - - %(MeetingItems)s - Meeting ended at %(endtime)s %(timeZone)s. - (<a href="%(fullLogs)s">full logs</a>) - <br><br><br> - <b>Action Items</b><ol> - %(ActionItems)s - </ol> - <br> - - <b>Action Items, by person</b> - <ol> - %(ActionItemsPerson)s - </ol><br> - - <b>People Present (lines said):</b><ol> - %(PeoplePresent)s - </ol> - - <br> - Generated by <a href="%(MeetBotInfoURL)s">MeetBot</a>%(MeetBotVersion)s. - </body></html> - ''') - - def format(self, extension=None): - """Write the minutes summary.""" +class HTML2(_BaseWriter): + """HTML formatter without tables. + """ + def meetingItems(self): + """Return the main 'Meeting minutes' block.""" M = self.M # Add all minute items to the table MeetingItems = [ ] + MeetingItems.append(self.heading('Meeting Minutes')) MeetingItems.append("<ol>") - - haveTopic = None inSublist = False for m in M.minutes: @@ -378,24 +344,36 @@ class HTML2(_BaseWriter): if haveTopic: MeetingItems.append("</li>") - - MeetingItems.append("</ol>") MeetingItems = "\n".join(MeetingItems) + return MeetingItems + def actionItems(self): + """Return the 'Action items' block.""" + M = self.M # Action Items ActionItems = [ ] + ActionItems.append(self.heading('Action items')) + ActionItems.append('<ol>') for m in M.minutes: # The hack below is needed because of pickling problems if m.itemtype != "ACTION": continue ActionItems.append(" <li>%s</li>"%html(m.line)) if len(ActionItems) == 0: ActionItems.append(" <li>(none)</li>") + ActionItems.append('</ol>') ActionItems = "\n".join(ActionItems) - + return ActionItems + def actionItemsPerson(self): + """Return the 'Action items, by person' block.""" + M = self.M # Action Items, by person (This could be made lots more efficient) ActionItemsPerson = [ ] + ActionItemsPerson.append(self.heading('Action items, by person')) + ActionItemsPerson.append('<ol>') + numberAssigned = 0 for nick, items in self.iterActionItemsNick(): + numberAssigned += 1 headerPrinted = False for m in items: if not headerPrinted: @@ -417,26 +395,60 @@ class HTML2(_BaseWriter): if numberUnassigned == 0: ActionItemsPerson.append(" <li>(none)</li>") ActionItemsPerson.append(' </ol>\n</li>') + ActionItemsPerson.append('</ol>') ActionItemsPerson = "\n".join(ActionItemsPerson) + # Only return anything if there are assigned items. + if numberAssigned == 0: + return None + else: + return ActionItemsPerson + def peoplePresent(self): + """Return the 'People present' block.""" # People Attending - PeoplePresent = [ ] + PeoplePresent = [] + PeoplePresent.append(self.heading('People present (lines said)')) + PeoplePresent.append('<ol>') # sort by number of lines spoken for nick, count in self.iterNickCounts(): PeoplePresent.append(' <li>%s (%s)</li>'%(html(nick), count)) + PeoplePresent.append('</ol>') PeoplePresent = "\n".join(PeoplePresent) + return PeoplePresent + def heading(self, name): + return '<h3>%s</h3>'%name + + def format(self, extension=None): + """Write the minutes summary.""" + M = self.M - # Actual formatting and replacement repl = self.replacements() - repl.update({'MeetingItems':MeetingItems, - 'ActionItems': ActionItems, - 'ActionItemsPerson': ActionItemsPerson, - 'PeoplePresent':PeoplePresent, - }) - body = self.body - body = body%repl + + body = [ ] + body.append(textwrap.dedent("""\ + <h1>%(pageTitle)s</h1> + Meeting started by %(owner)s at %(starttime)s %(timeZone)s + (<a href="%(fullLogs)s">full logs</a>). + """%repl)) + body.append(self.meetingItems()) + body.append(textwrap.dedent("""\ + Meeting ended at %(endtime)s %(timeZone)s + (<a href="%(fullLogs)s">full logs</a>). + """%repl)) + body.append(self.actionItems()) + body.append(self.actionItemsPerson()) + body.append(self.peoplePresent()) + body = [ b for b in body if b is not None ] + body = "\n<br><br>\n\n\n\n".join(body) body = replaceWRAP(body) - return body + + + repl.update({'body': body, + 'headExtra': '', + }) + html = html_template % repl + + return html class ReST(_BaseWriter): |