1.1 --- a/macros/EventAggregator.py Sat Nov 07 22:28:16 2009 +0100
1.2 +++ b/macros/EventAggregator.py Sun Nov 08 02:49:26 2009 +0100
1.3 @@ -385,18 +385,11 @@
1.4 output.append(view.writeDownloadControls())
1.5 output.append(fmt.div(on=0))
1.6
1.7 - # Output top-level information.
1.8 -
1.9 - # Start of list view output.
1.10 + # Output a table.
1.11
1.12 - if mode == "list":
1.13 - output.append(fmt.bullet_list(on=1, attr={"class" : "event-listings"}))
1.14 + if mode == "table":
1.15
1.16 - # Start of table view output.
1.17 -
1.18 - elif mode == "table":
1.19 -
1.20 - # Output a table.
1.21 + # Start of table view output.
1.22
1.23 output.append(fmt.table(on=1, attrs={"tableclass" : "event-table"}))
1.24
1.25 @@ -412,100 +405,134 @@
1.26 output.append(fmt.table_cell(on=0))
1.27 output.append(fmt.table_row(on=0))
1.28
1.29 - # Visit all months in the requested range, or across known events.
1.30 + # Get the events in order.
1.31
1.32 - for year, month in EventAggregatorSupport.daterange(first, last):
1.33 -
1.34 - # Either output a calendar view...
1.35 + ordered_events = EventAggregatorSupport.getOrderedEvents(all_shown_events)
1.36
1.37 - if mode == "calendar":
1.38 + # Show the events in order.
1.39
1.40 - # Output a month.
1.41 -
1.42 - output.append(fmt.table(on=1, attrs={"tableclass" : "event-month"}))
1.43 + for event_page, event_details in ordered_events:
1.44 + event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details, parent_name)
1.45
1.46 - output.append(fmt.table_row(on=1))
1.47 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-month-heading", "colspan" : "21"}))
1.48 + # Prepare CSS classes with category-related styling.
1.49
1.50 - # Either write a month heading or produce links for navigable
1.51 - # calendars.
1.52 + css_classes = ["event-table-details"]
1.53 +
1.54 + for topic in event_details.get("topics") or event_details.get("categories") or []:
1.55
1.56 - output.append(view.writeMonthHeading(year, month))
1.57 + # Filter the category text to avoid illegal characters.
1.58
1.59 - output.append(fmt.table_cell(on=0))
1.60 - output.append(fmt.table_row(on=0))
1.61 + css_classes.append("event-table-category-%s" % "".join(filter(lambda c: c.isalnum(), topic)))
1.62
1.63 - # Weekday headings.
1.64 + attrs = {"class" : " ".join(css_classes)}
1.65
1.66 output.append(fmt.table_row(on=1))
1.67
1.68 - for weekday in range(0, 7):
1.69 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-weekday-heading", "colspan" : "3"}))
1.70 - output.append(fmt.text(_(EventAggregatorSupport.getDayLabel(weekday))))
1.71 - output.append(fmt.table_cell(on=0))
1.72 + # Start and end dates.
1.73 +
1.74 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.75 + output.append(fmt.span(on=1))
1.76 + output.append(fmt.text("%04d-%02d-%02d" % event_details["start"]))
1.77 + output.append(fmt.span(on=0))
1.78 +
1.79 + if event_details["start"] != event_details["end"]:
1.80 + output.append(fmt.text(" - "))
1.81 + output.append(fmt.span(on=1))
1.82 + output.append(fmt.text("%04d-%02d-%02d" % event_details["end"]))
1.83 + output.append(fmt.span(on=0))
1.84 +
1.85 + output.append(fmt.table_cell(on=0))
1.86 +
1.87 + # Location.
1.88 +
1.89 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.90 +
1.91 + if event_details.has_key("location"):
1.92 + output.append(fmt.text(event_details["location"]))
1.93 +
1.94 + output.append(fmt.table_cell(on=0))
1.95 +
1.96 + # Link to the page using the summary.
1.97 +
1.98 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.99 + output.append(linkToPage(request, event_page, event_summary))
1.100 + output.append(fmt.table_cell(on=0))
1.101
1.102 output.append(fmt.table_row(on=0))
1.103
1.104 - # Process the days of the month.
1.105 + # End of table view output.
1.106 +
1.107 + output.append(fmt.table(on=0))
1.108
1.109 - start_weekday, number_of_days = calendar.monthrange(year, month)
1.110 + # Output a list or calendar.
1.111 +
1.112 + elif mode in ("list", "calendar"):
1.113
1.114 - # The start weekday is the weekday of day number 1.
1.115 - # Find the first day of the week, counting from below zero, if
1.116 - # necessary, in order to land on the first day of the month as
1.117 - # day number 1.
1.118 + # Output top-level information.
1.119 +
1.120 + # Start of list view output.
1.121
1.122 - first_day = 1 - start_weekday
1.123 + if mode == "list":
1.124 + output.append(fmt.bullet_list(on=1, attr={"class" : "event-listings"}))
1.125 +
1.126 + # Visit all months in the requested range, or across known events.
1.127 +
1.128 + for year, month in EventAggregatorSupport.daterange(first, last):
1.129
1.130 - while first_day <= number_of_days:
1.131 + # Either output a calendar view...
1.132 +
1.133 + if mode == "calendar":
1.134
1.135 - # Find events in this week and determine how to mark them on the
1.136 - # calendar.
1.137 + # Output a month.
1.138 +
1.139 + output.append(fmt.table(on=1, attrs={"tableclass" : "event-month"}))
1.140
1.141 - week_start = (year, month, max(first_day, 1))
1.142 - week_end = (year, month, min(first_day + 6, number_of_days))
1.143 + output.append(fmt.table_row(on=1))
1.144 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-month-heading", "colspan" : "21"}))
1.145 +
1.146 + # Either write a month heading or produce links for navigable
1.147 + # calendars.
1.148
1.149 - week_coverage, week_events = EventAggregatorSupport.getCoverage(
1.150 - week_start, week_end, shown_events.get((year, month), []))
1.151 + output.append(view.writeMonthHeading(year, month))
1.152
1.153 - # Output a week, starting with the day numbers.
1.154 + output.append(fmt.table_cell(on=0))
1.155 + output.append(fmt.table_row(on=0))
1.156 +
1.157 + # Weekday headings.
1.158
1.159 output.append(fmt.table_row(on=1))
1.160
1.161 for weekday in range(0, 7):
1.162 - day = first_day + weekday
1.163 - date = (year, month, day)
1.164 -
1.165 - # Output out-of-month days.
1.166 -
1.167 - if day < 1 or day > number_of_days:
1.168 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-excluded", "colspan" : "3"}))
1.169 - output.append(fmt.table_cell(on=0))
1.170 -
1.171 - # Output normal days.
1.172 -
1.173 - else:
1.174 - if date in week_coverage:
1.175 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-busy", "colspan" : "3"}))
1.176 - else:
1.177 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-empty", "colspan" : "3"}))
1.178 -
1.179 - # Output the day number, making a link to a new event
1.180 - # action.
1.181 -
1.182 - output.append(view.writeDayNumberLinked(day, month, year))
1.183 -
1.184 - # End of day.
1.185 -
1.186 - output.append(fmt.table_cell(on=0))
1.187 -
1.188 - # End of day numbers.
1.189 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-weekday-heading", "colspan" : "3"}))
1.190 + output.append(fmt.text(_(EventAggregatorSupport.getDayLabel(weekday))))
1.191 + output.append(fmt.table_cell(on=0))
1.192
1.193 output.append(fmt.table_row(on=0))
1.194
1.195 - # Either generate empty days...
1.196 + # Process the days of the month.
1.197 +
1.198 + start_weekday, number_of_days = calendar.monthrange(year, month)
1.199 +
1.200 + # The start weekday is the weekday of day number 1.
1.201 + # Find the first day of the week, counting from below zero, if
1.202 + # necessary, in order to land on the first day of the month as
1.203 + # day number 1.
1.204 +
1.205 + first_day = 1 - start_weekday
1.206
1.207 - if not week_events:
1.208 + while first_day <= number_of_days:
1.209 +
1.210 + # Find events in this week and determine how to mark them on the
1.211 + # calendar.
1.212 +
1.213 + week_start = (year, month, max(first_day, 1))
1.214 + week_end = (year, month, min(first_day + 6, number_of_days))
1.215 +
1.216 + week_coverage, week_events = EventAggregatorSupport.getCoverage(
1.217 + week_start, week_end, shown_events.get((year, month), []))
1.218 +
1.219 + # Output a week, starting with the day numbers.
1.220 +
1.221 output.append(fmt.table_row(on=1))
1.222
1.223 for weekday in range(0, 7):
1.224 @@ -516,376 +543,351 @@
1.225
1.226 if day < 1 or day > number_of_days:
1.227 output.append(fmt.table_cell(on=1,
1.228 - attrs={"class" : "event-day-content event-day-excluded", "colspan" : "3"}))
1.229 + attrs={"class" : "event-day-heading event-day-excluded", "colspan" : "3"}))
1.230 output.append(fmt.table_cell(on=0))
1.231
1.232 - # Output empty days.
1.233 + # Output normal days.
1.234
1.235 else:
1.236 - output.append(fmt.table_cell(on=1,
1.237 - attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"}))
1.238 + if date in week_coverage:
1.239 + output.append(fmt.table_cell(on=1,
1.240 + attrs={"class" : "event-day-heading event-day-busy", "colspan" : "3"}))
1.241 + else:
1.242 + output.append(fmt.table_cell(on=1,
1.243 + attrs={"class" : "event-day-heading event-day-empty", "colspan" : "3"}))
1.244 +
1.245 + # Output the day number, making a link to a new event
1.246 + # action.
1.247 +
1.248 + output.append(view.writeDayNumberLinked(day, month, year))
1.249 +
1.250 + # End of day.
1.251 +
1.252 + output.append(fmt.table_cell(on=0))
1.253 +
1.254 + # End of day numbers.
1.255
1.256 output.append(fmt.table_row(on=0))
1.257
1.258 - # Or visit each set of scheduled events...
1.259 -
1.260 - else:
1.261 - for coverage, events in week_events:
1.262 + # Either generate empty days...
1.263
1.264 - # Output each set.
1.265 -
1.266 + if not week_events:
1.267 output.append(fmt.table_row(on=1))
1.268
1.269 - # Then, output day details.
1.270 -
1.271 for weekday in range(0, 7):
1.272 day = first_day + weekday
1.273 date = (year, month, day)
1.274
1.275 - # Skip out-of-month days.
1.276 + # Output out-of-month days.
1.277
1.278 if day < 1 or day > number_of_days:
1.279 output.append(fmt.table_cell(on=1,
1.280 attrs={"class" : "event-day-content event-day-excluded", "colspan" : "3"}))
1.281 output.append(fmt.table_cell(on=0))
1.282 - continue
1.283
1.284 - # Output the day.
1.285 + # Output empty days.
1.286
1.287 - if date not in coverage:
1.288 + else:
1.289 output.append(fmt.table_cell(on=1,
1.290 attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"}))
1.291
1.292 - # Get event details for the current day.
1.293 + output.append(fmt.table_row(on=0))
1.294 +
1.295 + # Or visit each set of scheduled events...
1.296 +
1.297 + else:
1.298 + for coverage, events in week_events:
1.299 +
1.300 + # Output each set.
1.301 +
1.302 + output.append(fmt.table_row(on=1))
1.303
1.304 - for event_page, event_details in events:
1.305 - if not (event_details["start"] <= date <= event_details["end"]):
1.306 + # Then, output day details.
1.307 +
1.308 + for weekday in range(0, 7):
1.309 + day = first_day + weekday
1.310 + date = (year, month, day)
1.311 +
1.312 + # Skip out-of-month days.
1.313 +
1.314 + if day < 1 or day > number_of_days:
1.315 + output.append(fmt.table_cell(on=1,
1.316 + attrs={"class" : "event-day-content event-day-excluded", "colspan" : "3"}))
1.317 + output.append(fmt.table_cell(on=0))
1.318 continue
1.319
1.320 - # Get basic properties of the event.
1.321 + # Output the day.
1.322
1.323 - starts_today = event_details["start"] == date
1.324 - ends_today = event_details["end"] == date
1.325 - event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details, parent_name)
1.326 + if date not in coverage:
1.327 + output.append(fmt.table_cell(on=1,
1.328 + attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"}))
1.329
1.330 - # Generate a colour for the event.
1.331 + # Get event details for the current day.
1.332
1.333 - bg = getColour(event_page.page_name)
1.334 - fg = getBlackOrWhite(bg)
1.335 - style = ("background-color: rgb(%d, %d, %d); color: rgb(%d, %d, %d);" % (bg + fg))
1.336 + for event_page, event_details in events:
1.337 + if not (event_details["start"] <= date <= event_details["end"]):
1.338 + continue
1.339
1.340 - # Determine if the event name should be shown.
1.341 + # Get basic properties of the event.
1.342
1.343 - start_of_period = starts_today or weekday == 0 or day == 1
1.344 + starts_today = event_details["start"] == date
1.345 + ends_today = event_details["end"] == date
1.346 + event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details, parent_name)
1.347
1.348 - if name_usage == "daily" or start_of_period:
1.349 - hide_text = 0
1.350 - else:
1.351 - hide_text = 1
1.352 + # Generate a colour for the event.
1.353
1.354 - # Output start of day gap and determine whether
1.355 - # any event content should be explicitly output
1.356 - # for this day.
1.357 + bg = getColour(event_page.page_name)
1.358 + fg = getBlackOrWhite(bg)
1.359 + style = ("background-color: rgb(%d, %d, %d); color: rgb(%d, %d, %d);" % (bg + fg))
1.360
1.361 - if starts_today:
1.362 + # Determine if the event name should be shown.
1.363
1.364 - # Single day events...
1.365 + start_of_period = starts_today or weekday == 0 or day == 1
1.366
1.367 - if ends_today:
1.368 - colspan = 3
1.369 - event_day_type = "event-day-single"
1.370 + if name_usage == "daily" or start_of_period:
1.371 + hide_text = 0
1.372 + else:
1.373 + hide_text = 1
1.374
1.375 - # Events starting today...
1.376 + # Output start of day gap and determine whether
1.377 + # any event content should be explicitly output
1.378 + # for this day.
1.379
1.380 - else:
1.381 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-start-gap"}))
1.382 - output.append(fmt.table_cell(on=0))
1.383 + if starts_today:
1.384
1.385 - # Calculate the span of this cell.
1.386 - # Events whose names appear on every day...
1.387 + # Single day events...
1.388
1.389 - if name_usage == "daily":
1.390 - colspan = 2
1.391 - event_day_type = "event-day-starting"
1.392 + if ends_today:
1.393 + colspan = 3
1.394 + event_day_type = "event-day-single"
1.395
1.396 - # Events whose names appear once per week...
1.397 + # Events starting today...
1.398
1.399 else:
1.400 - if event_details["end"] <= week_end:
1.401 - event_length = event_details["end"][2] - day + 1
1.402 - colspan = (event_length - 2) * 3 + 4
1.403 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-start-gap"}))
1.404 + output.append(fmt.table_cell(on=0))
1.405 +
1.406 + # Calculate the span of this cell.
1.407 + # Events whose names appear on every day...
1.408 +
1.409 + if name_usage == "daily":
1.410 + colspan = 2
1.411 + event_day_type = "event-day-starting"
1.412 +
1.413 + # Events whose names appear once per week...
1.414 +
1.415 else:
1.416 - event_length = week_end[2] - day + 1
1.417 - colspan = (event_length - 1) * 3 + 2
1.418 + if event_details["end"] <= week_end:
1.419 + event_length = event_details["end"][2] - day + 1
1.420 + colspan = (event_length - 2) * 3 + 4
1.421 + else:
1.422 + event_length = week_end[2] - day + 1
1.423 + colspan = (event_length - 1) * 3 + 2
1.424
1.425 - event_day_type = "event-day-multiple"
1.426 + event_day_type = "event-day-multiple"
1.427 +
1.428 + # Events continuing from a previous week...
1.429
1.430 - # Events continuing from a previous week...
1.431 + elif start_of_period:
1.432
1.433 - elif start_of_period:
1.434 + # End of continuing event...
1.435
1.436 - # End of continuing event...
1.437 + if ends_today:
1.438 + colspan = 2
1.439 + event_day_type = "event-day-ending"
1.440 +
1.441 + # Events continuing for at least one more day...
1.442 +
1.443 + else:
1.444
1.445 - if ends_today:
1.446 - colspan = 2
1.447 - event_day_type = "event-day-ending"
1.448 + # Calculate the span of this cell.
1.449 + # Events whose names appear on every day...
1.450 +
1.451 + if name_usage == "daily":
1.452 + colspan = 3
1.453 + event_day_type = "event-day-full"
1.454 +
1.455 + # Events whose names appear once per week...
1.456
1.457 - # Events continuing for at least one more day...
1.458 -
1.459 - else:
1.460 + else:
1.461 + if event_details["end"] <= week_end:
1.462 + event_length = event_details["end"][2] - day + 1
1.463 + colspan = (event_length - 1) * 3 + 2
1.464 + else:
1.465 + event_length = week_end[2] - day + 1
1.466 + colspan = event_length * 3
1.467
1.468 - # Calculate the span of this cell.
1.469 - # Events whose names appear on every day...
1.470 + event_day_type = "event-day-multiple"
1.471 +
1.472 + # Continuing events whose names appear on every day...
1.473
1.474 - if name_usage == "daily":
1.475 + elif name_usage == "daily":
1.476 + if ends_today:
1.477 + colspan = 2
1.478 + event_day_type = "event-day-ending"
1.479 + else:
1.480 colspan = 3
1.481 event_day_type = "event-day-full"
1.482
1.483 - # Events whose names appear once per week...
1.484 + # Continuing events whose names appear once per week...
1.485 +
1.486 + else:
1.487 + colspan = None
1.488
1.489 - else:
1.490 - if event_details["end"] <= week_end:
1.491 - event_length = event_details["end"][2] - day + 1
1.492 - colspan = (event_length - 1) * 3 + 2
1.493 - else:
1.494 - event_length = week_end[2] - day + 1
1.495 - colspan = event_length * 3
1.496 + # Output the main content only if it is not
1.497 + # continuing from a previous day.
1.498
1.499 - event_day_type = "event-day-multiple"
1.500 + if colspan is not None:
1.501
1.502 - # Continuing events whose names appear on every day...
1.503 + # Colour the cell for continuing events.
1.504
1.505 - elif name_usage == "daily":
1.506 - if ends_today:
1.507 - colspan = 2
1.508 - event_day_type = "event-day-ending"
1.509 - else:
1.510 - colspan = 3
1.511 - event_day_type = "event-day-full"
1.512 + attrs={
1.513 + "class" : "event-day-content event-day-busy %s" % event_day_type,
1.514 + "colspan" : str(colspan)
1.515 + }
1.516
1.517 - # Continuing events whose names appear once per week...
1.518 -
1.519 - else:
1.520 - colspan = None
1.521 + if not (starts_today and ends_today):
1.522 + attrs["style"] = style
1.523
1.524 - # Output the main content only if it is not
1.525 - # continuing from a previous day.
1.526 -
1.527 - if colspan is not None:
1.528 -
1.529 - # Colour the cell for continuing events.
1.530 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.531
1.532 - attrs={
1.533 - "class" : "event-day-content event-day-busy %s" % event_day_type,
1.534 - "colspan" : str(colspan)
1.535 - }
1.536 + # Output the event.
1.537
1.538 - if not (starts_today and ends_today):
1.539 - attrs["style"] = style
1.540 + if starts_today and ends_today or not hide_text:
1.541
1.542 - output.append(fmt.table_cell(on=1, attrs=attrs))
1.543 + output.append(fmt.div(on=1, css_class="event-summary-box"))
1.544 + output.append(fmt.div(on=1, css_class="event-summary", style=style))
1.545 + output.append(linkToPage(request, event_page, event_summary))
1.546 + output.append(fmt.div(on=0))
1.547
1.548 - # Output the event.
1.549 -
1.550 - if starts_today and ends_today or not hide_text:
1.551 + # Add a pop-up element for long summaries.
1.552
1.553 - output.append(fmt.div(on=1, css_class="event-summary-box"))
1.554 - output.append(fmt.div(on=1, css_class="event-summary", style=style))
1.555 - output.append(linkToPage(request, event_page, event_summary))
1.556 - output.append(fmt.div(on=0))
1.557 + output.append(fmt.div(on=1, css_class="event-summary-popup", style=style))
1.558 + output.append(linkToPage(request, event_page, event_summary))
1.559 + output.append(fmt.div(on=0))
1.560
1.561 - # Add a pop-up element for long summaries.
1.562 + output.append(fmt.div(on=0))
1.563
1.564 - output.append(fmt.div(on=1, css_class="event-summary-popup", style=style))
1.565 - output.append(linkToPage(request, event_page, event_summary))
1.566 - output.append(fmt.div(on=0))
1.567 + # Output end of day content.
1.568
1.569 output.append(fmt.div(on=0))
1.570
1.571 - # Output end of day content.
1.572 -
1.573 - output.append(fmt.div(on=0))
1.574 -
1.575 - # Output end of day gap.
1.576 + # Output end of day gap.
1.577
1.578 - if ends_today and not starts_today:
1.579 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-end-gap"}))
1.580 - output.append(fmt.table_cell(on=0))
1.581 -
1.582 - # End of day.
1.583 + if ends_today and not starts_today:
1.584 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-end-gap"}))
1.585 + output.append(fmt.table_cell(on=0))
1.586
1.587 - output.append(fmt.table_cell(on=0))
1.588 -
1.589 - # End of set.
1.590 -
1.591 - output.append(fmt.table_row(on=0))
1.592 + # End of day.
1.593
1.594 - # Add a spacer.
1.595 -
1.596 - output.append(fmt.table_row(on=1))
1.597 + output.append(fmt.table_cell(on=0))
1.598
1.599 - for weekday in range(0, 7):
1.600 - day = first_day + weekday
1.601 - css_classes = "event-day-spacer"
1.602 + # End of set.
1.603
1.604 - # Skip out-of-month days.
1.605 -
1.606 - if day < 1 or day > number_of_days:
1.607 - css_classes += " event-day-excluded"
1.608 + output.append(fmt.table_row(on=0))
1.609
1.610 - output.append(fmt.table_cell(on=1, attrs={"class" : css_classes, "colspan" : "3"}))
1.611 - output.append(fmt.table_cell(on=0))
1.612 + # Add a spacer.
1.613
1.614 - output.append(fmt.table_row(on=0))
1.615 + output.append(fmt.table_row(on=1))
1.616
1.617 - # Process the next week...
1.618 -
1.619 - first_day += 7
1.620 -
1.621 - # End of month.
1.622 -
1.623 - output.append(fmt.table(on=0))
1.624 + for weekday in range(0, 7):
1.625 + day = first_day + weekday
1.626 + css_classes = "event-day-spacer"
1.627
1.628 - # Or output a summary view...
1.629 -
1.630 - elif mode == "list":
1.631 + # Skip out-of-month days.
1.632
1.633 - # Output a list.
1.634 -
1.635 - output.append(fmt.listitem(on=1, attr={"class" : "event-listings-month"}))
1.636 - output.append(fmt.div(on=1, attr={"class" : "event-listings-month-heading"}))
1.637 + if day < 1 or day > number_of_days:
1.638 + css_classes += " event-day-excluded"
1.639
1.640 - # Either write a month heading or produce links for navigable
1.641 - # calendars.
1.642 -
1.643 - output.append(view.writeMonthHeading(year, month))
1.644 + output.append(fmt.table_cell(on=1, attrs={"class" : css_classes, "colspan" : "3"}))
1.645 + output.append(fmt.table_cell(on=0))
1.646
1.647 - output.append(fmt.div(on=0))
1.648 -
1.649 - output.append(fmt.bullet_list(on=1, attr={"class" : "event-month-listings"}))
1.650 -
1.651 - # Get the events in order.
1.652 + output.append(fmt.table_row(on=0))
1.653
1.654 - ordered_events = EventAggregatorSupport.getOrderedEvents(shown_events.get((year, month), []))
1.655 + # Process the next week...
1.656
1.657 - # Show the events in order.
1.658 + first_day += 7
1.659
1.660 - for event_page, event_details in ordered_events:
1.661 - event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details, parent_name)
1.662 + # End of month.
1.663
1.664 - output.append(fmt.listitem(on=1, attr={"class" : "event-listing"}))
1.665 -
1.666 - # Link to the page using the summary.
1.667 + output.append(fmt.table(on=0))
1.668
1.669 - output.append(fmt.paragraph(on=1))
1.670 - output.append(linkToPage(request, event_page, event_summary))
1.671 - output.append(fmt.paragraph(on=0))
1.672 + # Or output a summary view...
1.673
1.674 - # Start and end dates.
1.675 + elif mode == "list":
1.676
1.677 - output.append(fmt.paragraph(on=1))
1.678 - output.append(fmt.span(on=1))
1.679 - output.append(fmt.text("%04d-%02d-%02d" % event_details["start"]))
1.680 - output.append(fmt.span(on=0))
1.681 - output.append(fmt.text(" - "))
1.682 - output.append(fmt.span(on=1))
1.683 - output.append(fmt.text("%04d-%02d-%02d" % event_details["end"]))
1.684 - output.append(fmt.span(on=0))
1.685 - output.append(fmt.paragraph(on=0))
1.686 + # Output a list.
1.687
1.688 - # Location.
1.689 + output.append(fmt.listitem(on=1, attr={"class" : "event-listings-month"}))
1.690 + output.append(fmt.div(on=1, attr={"class" : "event-listings-month-heading"}))
1.691
1.692 - if event_details.has_key("location"):
1.693 - output.append(fmt.paragraph(on=1))
1.694 - output.append(fmt.text(event_details["location"]))
1.695 - output.append(fmt.paragraph(on=1))
1.696 + # Either write a month heading or produce links for navigable
1.697 + # calendars.
1.698
1.699 - # Topics.
1.700 + output.append(view.writeMonthHeading(year, month))
1.701
1.702 - if event_details.has_key("topics") or event_details.has_key("categories"):
1.703 - output.append(fmt.bullet_list(on=1, attr={"class" : "event-topics"}))
1.704 + output.append(fmt.div(on=0))
1.705
1.706 - for topic in event_details.get("topics") or event_details.get("categories") or []:
1.707 - output.append(fmt.listitem(on=1))
1.708 - output.append(fmt.text(topic))
1.709 - output.append(fmt.listitem(on=0))
1.710 + output.append(fmt.bullet_list(on=1, attr={"class" : "event-month-listings"}))
1.711
1.712 - output.append(fmt.bullet_list(on=0))
1.713 -
1.714 - output.append(fmt.listitem(on=0))
1.715 + # Get the events in order.
1.716
1.717 - output.append(fmt.bullet_list(on=0))
1.718 -
1.719 - # Or output a table of events...
1.720 + ordered_events = EventAggregatorSupport.getOrderedEvents(shown_events.get((year, month), []))
1.721
1.722 - elif mode == "table":
1.723 -
1.724 - # Get the events in order.
1.725 + # Show the events in order.
1.726
1.727 - ordered_events = EventAggregatorSupport.getOrderedEvents(shown_events.get((year, month), []))
1.728 -
1.729 - # Show the events in order.
1.730 + for event_page, event_details in ordered_events:
1.731 + event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details, parent_name)
1.732
1.733 - for event_page, event_details in ordered_events:
1.734 - event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details, parent_name)
1.735 + output.append(fmt.listitem(on=1, attr={"class" : "event-listing"}))
1.736
1.737 - # Prepare CSS classes with category-related styling.
1.738 -
1.739 - css_classes = ["event-table-details"]
1.740 + # Link to the page using the summary.
1.741
1.742 - for topic in event_details.get("topics") or event_details.get("categories") or []:
1.743 -
1.744 - # Filter the category text to avoid illegal characters.
1.745 -
1.746 - css_classes.append("event-table-category-%s" % "".join(filter(lambda c: c.isalnum(), topic)))
1.747 -
1.748 - attrs = {"class" : " ".join(css_classes)}
1.749 + output.append(fmt.paragraph(on=1))
1.750 + output.append(linkToPage(request, event_page, event_summary))
1.751 + output.append(fmt.paragraph(on=0))
1.752
1.753 - output.append(fmt.table_row(on=1))
1.754 -
1.755 - # Start and end dates.
1.756 + # Start and end dates.
1.757
1.758 - output.append(fmt.table_cell(on=1, attrs=attrs))
1.759 - output.append(fmt.span(on=1))
1.760 - output.append(fmt.text("%04d-%02d-%02d" % event_details["start"]))
1.761 - output.append(fmt.span(on=0))
1.762 -
1.763 - if event_details["start"] != event_details["end"]:
1.764 + output.append(fmt.paragraph(on=1))
1.765 + output.append(fmt.span(on=1))
1.766 + output.append(fmt.text("%04d-%02d-%02d" % event_details["start"]))
1.767 + output.append(fmt.span(on=0))
1.768 output.append(fmt.text(" - "))
1.769 output.append(fmt.span(on=1))
1.770 output.append(fmt.text("%04d-%02d-%02d" % event_details["end"]))
1.771 output.append(fmt.span(on=0))
1.772 -
1.773 - output.append(fmt.table_cell(on=0))
1.774 + output.append(fmt.paragraph(on=0))
1.775
1.776 - # Location.
1.777 -
1.778 - output.append(fmt.table_cell(on=1, attrs=attrs))
1.779 + # Location.
1.780
1.781 - if event_details.has_key("location"):
1.782 - output.append(fmt.text(event_details["location"]))
1.783 + if event_details.has_key("location"):
1.784 + output.append(fmt.paragraph(on=1))
1.785 + output.append(fmt.text(event_details["location"]))
1.786 + output.append(fmt.paragraph(on=1))
1.787
1.788 - output.append(fmt.table_cell(on=0))
1.789 + # Topics.
1.790
1.791 - # Link to the page using the summary.
1.792 + if event_details.has_key("topics") or event_details.has_key("categories"):
1.793 + output.append(fmt.bullet_list(on=1, attr={"class" : "event-topics"}))
1.794
1.795 - output.append(fmt.table_cell(on=1, attrs=attrs))
1.796 - output.append(linkToPage(request, event_page, event_summary))
1.797 - output.append(fmt.table_cell(on=0))
1.798 + for topic in event_details.get("topics") or event_details.get("categories") or []:
1.799 + output.append(fmt.listitem(on=1))
1.800 + output.append(fmt.text(topic))
1.801 + output.append(fmt.listitem(on=0))
1.802
1.803 - output.append(fmt.table_row(on=0))
1.804 + output.append(fmt.bullet_list(on=0))
1.805
1.806 - # Output top-level information.
1.807 + output.append(fmt.listitem(on=0))
1.808
1.809 - # End of list view output.
1.810 + output.append(fmt.bullet_list(on=0))
1.811
1.812 - if mode == "list":
1.813 - output.append(fmt.bullet_list(on=0))
1.814 + # Output top-level information.
1.815
1.816 - # End of table view output.
1.817 + # End of list view output.
1.818
1.819 - elif mode == "table":
1.820 - output.append(fmt.table(on=0))
1.821 + if mode == "list":
1.822 + output.append(fmt.bullet_list(on=0))
1.823
1.824 # Output view controls.
1.825