Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/writers.py
diff options
context:
space:
mode:
authorRichard Darst <rkd@zgib.net>2009-07-02 17:57:30 (GMT)
committer Richard Darst <rkd@zgib.net>2009-07-02 17:57:30 (GMT)
commit5e763943c6b15ac0684da4c5b504a4c4d06e10d7 (patch)
tree35adc848266454a073d38eb963c477b32627ec26 /writers.py
parent2aedae56c9c5c385b27fc15c3058af5ffc9e4f88 (diff)
Changes to writers.py
- Move the body template to outside the functions - Check HTML sanitization of nicks. - Do reST sanitization of lines and nicks. Right now this is a null op. darcs-hash:20090702175730-82ea9-40a0ee253644d8e51ad91c4c4bec28343abc846a.gz
Diffstat (limited to 'writers.py')
-rw-r--r--writers.py218
1 files changed, 99 insertions, 119 deletions
diff --git a/writers.py b/writers.py
index 73fa395..fcd60df 100644
--- a/writers.py
+++ b/writers.py
@@ -16,6 +16,7 @@ def html(text):
"""Escape bad sequences (in HTML) in user-generated lines."""
return text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
def rst(text):
+ """Escapes bad sequences in reST (not implemented yet)"""
return text
# wraping functions (for RST)
@@ -114,10 +115,47 @@ class HTMLlog(_BaseWriter):
class HTML(_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>
+ \n\n<table border=1>
+ %(MeetingItems)s
+ </table>
+ 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>\n<ol>
+ %(ActionItemsPerson)s
+ </ol><br>
+
+ <b>People Present (lines said):</b><ol>
+ %(PeoplePresent)s
+ </ol>
+
+ <br>
+ Generated by <a href="%(MeetBotInfoURL)s">MeetBot</a>."""
+ </body></html>
+ ''')
+
def format(self):
"""Write the minutes summary."""
M = self.M
- # Header and things stored
# Add all minute items to the table
MeetingItems = [ ]
@@ -125,9 +163,6 @@ class HTML(_BaseWriter):
MeetingItems.append(m.html(M))
MeetingItems = "\n".join(MeetingItems)
- # End the log portion
-
-
# Action Items
ActionItems = [ ]
for m in M.minutes:
@@ -162,77 +197,77 @@ class HTML(_BaseWriter):
PeoplePresent = [ ]
# sort by number of lines spoken
for nick, count in self.iterNickCounts():
- PeoplePresent.append(' <li>%s (%s)</li>'%(nick, count))
+ PeoplePresent.append(' <li>%s (%s)</li>'%(html(nick), count))
PeoplePresent = "\n".join(PeoplePresent)
+ # Actual formatting and replacement
+ repl = self.replacements()
+ repl.update({'MeetingItems':MeetingItems,
+ 'ActionItems': ActionItems,
+ 'ActionItemsPerson': ActionItemsPerson,
+ 'PeoplePresent':PeoplePresent,
+ })
+ body = self.body
+ body = body%repl
+ body = replaceWRAP(body)
+ return body
- body = '''\
- <!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>
- \n\n<table border=1>
- %(MeetingItems)s
- </table>
- Meeting ended at %(endtime)s %(timeZone)s.
- (<a href="%(fullLogs)s">full logs</a>)
+class RST(_BaseWriter):
- <br><br><br>
+ body = textwrap.dedent("""\
+ %(titleBlock)s
+ %(pageTitle)s
+ %(titleBlock)s
- <b>Action Items</b><ol>
- %(ActionItems)s
- </ol>
- <br>
- <b>Action Items, by person</b>\n<ol>
- %(ActionItemsPerson)s
- </ol><br>
+ WRAPMeeting started by %(owner)s at %(starttime)s %(timeZone)s.
+ The `full logs`_ are available.WRAP
- <b>People Present (lines said):</b><ol>
- %(PeoplePresent)s
- </ol>
+ .. _`full logs`: %(fullLogs)s
- <br>
- Generated by <a href="%(MeetBotInfoURL)s">MeetBot</a>."""
- </body></html>
- '''
- #%(pageTitle, pageTitle, M.owner,
- # time.strftime("%H:%M:%S", M.starttime),
- # M.config.timeZone,
- # M.config.basename+'.log.html',
- # time.strftime("%H:%M:%S", M.endtime), M.config.timeZone,
- # M.config.basename+'.log.html'
- # ))
+ Meeting log
+ -----------
+ %(MeetingItems)s
+ Meeting ended at %(endtime)s %(timeZone)s.
- body = textwrap.dedent(body)
- body = replaceWRAP(body)
- repl = self.replacements()
- repl.update({'MeetingItems':MeetingItems,
- 'ActionItems': ActionItems,
- 'ActionItemsPerson': ActionItemsPerson,
- 'PeoplePresent':PeoplePresent,
- })
- body = body%repl
- return body
-class RST(_BaseWriter):
+
+ Action Items
+ ------------
+ %(ActionItems)s
+
+
+
+
+ Action Items, by person
+ -----------------------
+ %(ActionItemsPerson)s
+
+
+
+
+ People Present (lines said)
+ ---------------------------
+ %(PeoplePresent)s
+
+
+
+
+ Generated by `MeetBot`_
+
+ .. _`MeetBot`: %(MeetBotInfoURL)s
+ """)
+
def format(self):
"""Return a ReStructured Text minutes summary."""
M = self.M
- pageTitle = self.pagetitle
-
+ # Agenda items
MeetingItems = [ ]
M.rst_urls = [ ]
M.rst_refs = { }
@@ -257,7 +292,7 @@ class RST(_BaseWriter):
# The hack below is needed because of pickling problems
if m.itemtype != "ACTION": continue
#already escaped
- ActionItems.append(wrapList("* %s"%m.line, indent=0))
+ ActionItems.append(wrapList("* %s"%rst(m.line), indent=0))
ActionItems = "\n\n".join(ActionItems)
# Action Items, by person (This could be made lots more efficient)
@@ -269,86 +304,29 @@ class RST(_BaseWriter):
if m.itemtype != "ACTION": continue
if m.line.find(nick) == -1: continue
if not headerPrinted:
- ActionItemsPerson.append("* %s"%nick)
+ ActionItemsPerson.append("* %s"%rst(nick))
headerPrinted = True
- # already escaped
- ActionItemsPerson.append(wrapList("* %s"%m.line, 2))
+ ActionItemsPerson.append(wrapList("* %s"%rst(m.line), 2))
m.assigned = True
- #if headerPrinted:
- # ActionItemsPerson.append(" </ol></li>")
# unassigned items:
ActionItemsPerson.append("* **UNASSIGNED**")
numberUnassigned = 0
for m in M.minutes:
if m.itemtype != "ACTION": continue
if getattr(m, 'assigned', False): continue
- # already escaped
- ActionItemsPerson.append(wrapList("* %s"%m.line, 2))
+ ActionItemsPerson.append(wrapList("* %s"%rst(m.line), 2))
numberUnassigned += 1
if numberUnassigned == 0: ActionItemsPerson.append(" * (none)")
- #ActionItemsPerson.append(' </ol>\n</li>')
- # clean-up
- #ActionItemsPerson.append("</ol>\n\n<br>")
ActionItemsPerson = "\n\n".join(ActionItemsPerson)
-
# People Attending
PeoplePresent = [ ]
# sort by number of lines spoken
for nick, count in self.iterNickCounts():
- PeoplePresent.append('* %s (%s)'%(nick, count))
+ PeoplePresent.append('* %s (%s)'%(rst(nick), count))
PeoplePresent = "\n\n".join(PeoplePresent)
- # End the log portion
- body = """\
- %(titleBlock)s
- %(pageTitle)s
- %(titleBlock)s
-
-
- WRAPMeeting started by %(owner)s at %(starttime)s %(timeZone)s.
- The `full logs`_ are available.WRAP
-
- .. _`full logs`: %(fullLogs)s
-
-
-
- Meeting log
- -----------
- %(MeetingItems)s
-
- Meeting ended at %(endtime)s %(timeZone)s.
-
-
-
-
- Action Items
- ------------
- %(ActionItems)s
-
-
-
-
- Action Items, by person
- -----------------------
- %(ActionItemsPerson)s
-
-
-
-
- People Present (lines said)
- ---------------------------
- %(PeoplePresent)s
-
-
-
-
- Generated by `MeetBot`_
-
- .. _`MeetBot`: %(MeetBotInfoURL)s
- """
- body = textwrap.dedent(body)
- body = replaceWRAP(body)
+ # Actual formatting and replacement
repl = self.replacements()
repl.update({'titleBlock':('='*len(repl['pageTitle'])),
'MeetingItems':MeetingItems,
@@ -356,6 +334,8 @@ class RST(_BaseWriter):
'ActionItemsPerson': ActionItemsPerson,
'PeoplePresent':PeoplePresent,
})
+ body = self.body
+ body = replaceWRAP(body)
body = body%repl
return body