1.1 --- a/macros/EventAggregator.py Mon Jun 08 23:41:01 2009 +0200
1.2 +++ b/macros/EventAggregator.py Fri Oct 02 22:42:37 2009 +0200
1.3 @@ -277,9 +277,31 @@
1.4
1.5 # Output top-level information.
1.6
1.7 + # Start of list view output.
1.8 +
1.9 if mode == "list":
1.10 output.append(fmt.bullet_list(on=1, attr={"class" : "event-listings"}))
1.11
1.12 + # Start of table view output.
1.13 +
1.14 + elif mode == "table":
1.15 +
1.16 + # Output a table.
1.17 +
1.18 + output.append(fmt.table(on=1, attrs={"tableclass" : "event-table"}))
1.19 +
1.20 + output.append(fmt.table_row(on=1))
1.21 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-table-heading"}))
1.22 + output.append(fmt.text(_("Event dates")))
1.23 + output.append(fmt.table_cell(on=0))
1.24 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-table-heading"}))
1.25 + output.append(fmt.text(_("Event location")))
1.26 + output.append(fmt.table_cell(on=0))
1.27 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-table-heading"}))
1.28 + output.append(fmt.text(_("Event details")))
1.29 + output.append(fmt.table_cell(on=0))
1.30 + output.append(fmt.table_row(on=0))
1.31 +
1.32 # Visit all months in the requested range, or across known events.
1.33
1.34 for year, month in EventAggregatorSupport.daterange(first, last):
1.35 @@ -692,6 +714,62 @@
1.36
1.37 output.append(fmt.bullet_list(on=0))
1.38
1.39 + # Or output a table of events...
1.40 +
1.41 + elif mode == "table":
1.42 +
1.43 + # Get the events in order.
1.44 +
1.45 + ordered_events = EventAggregatorSupport.getOrderedEvents(shown_events.get((year, month), []))
1.46 +
1.47 + # Show the events in order.
1.48 +
1.49 + for event_page, event_details in ordered_events:
1.50 + event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details)
1.51 +
1.52 + # Prepare CSS classes with category-related styling.
1.53 +
1.54 + css_classes = ["event-table-details"]
1.55 +
1.56 + for topic in event_details.get("topics") or event_details.get("categories"):
1.57 +
1.58 + # Filter the category text to avoid illegal characters.
1.59 +
1.60 + css_classes.append("event-table-category-%s" % "".join(filter(lambda c: c.isalnum(), topic)))
1.61 +
1.62 + attrs = {"class" : " ".join(css_classes)}
1.63 +
1.64 + output.append(fmt.table_row(on=1))
1.65 +
1.66 + # Start and end dates.
1.67 +
1.68 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.69 + output.append(fmt.span(on=1))
1.70 + output.append(fmt.text("%04d-%02d-%02d" % event_details["start"]))
1.71 + output.append(fmt.span(on=0))
1.72 + output.append(fmt.text(" - "))
1.73 + output.append(fmt.span(on=1))
1.74 + output.append(fmt.text("%04d-%02d-%02d" % event_details["end"]))
1.75 + output.append(fmt.span(on=0))
1.76 + output.append(fmt.table_cell(on=0))
1.77 +
1.78 + # Location.
1.79 +
1.80 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.81 +
1.82 + if event_details.has_key("location"):
1.83 + output.append(fmt.text(event_details["location"]))
1.84 +
1.85 + output.append(fmt.table_cell(on=0))
1.86 +
1.87 + # Link to the page using the summary.
1.88 +
1.89 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.90 + output.append(linkToPage(request, event_page, event_summary))
1.91 + output.append(fmt.table_cell(on=0))
1.92 +
1.93 + output.append(fmt.table_row(on=0))
1.94 +
1.95 # Output top-level information.
1.96
1.97 # End of list view output.
1.98 @@ -699,6 +777,11 @@
1.99 if mode == "list":
1.100 output.append(fmt.bullet_list(on=0))
1.101
1.102 + # End of table view output.
1.103 +
1.104 + elif mode == "table":
1.105 + output.append(fmt.table(on=0))
1.106 +
1.107 return ''.join(output)
1.108
1.109 # vim: tabstop=4 expandtab shiftwidth=4