paul@0 | 1 | # -*- coding: iso-8859-1 -*- |
paul@0 | 2 | """ |
paul@0 | 3 | MoinMoin - EventAggregator Macro |
paul@0 | 4 | |
paul@0 | 5 | @copyright: 2008, 2009 by Paul Boddie <paul@boddie.org.uk> |
paul@0 | 6 | @copyright: 2000-2004 Juergen Hermann <jh@web.de>, |
paul@0 | 7 | 2005-2008 MoinMoin:ThomasWaldmann. |
paul@0 | 8 | @license: GNU GPL (v2 or later), see COPYING.txt for details. |
paul@0 | 9 | """ |
paul@0 | 10 | |
paul@10 | 11 | from MoinMoin import wikiutil |
paul@10 | 12 | import EventAggregatorSupport |
paul@0 | 13 | import calendar |
paul@0 | 14 | |
paul@5 | 15 | try: |
paul@5 | 16 | set |
paul@5 | 17 | except NameError: |
paul@5 | 18 | from sets import Set as set |
paul@5 | 19 | |
paul@0 | 20 | Dependencies = ['pages'] |
paul@0 | 21 | |
paul@0 | 22 | # Date labels. |
paul@0 | 23 | |
paul@0 | 24 | month_labels = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] |
paul@0 | 25 | weekday_labels = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] |
paul@0 | 26 | |
paul@10 | 27 | # HTML-related functions. |
paul@2 | 28 | |
paul@2 | 29 | def getColour(s): |
paul@2 | 30 | colour = [0, 0, 0] |
paul@2 | 31 | digit = 0 |
paul@2 | 32 | for c in s: |
paul@2 | 33 | colour[digit] += ord(c) |
paul@2 | 34 | colour[digit] = colour[digit] % 256 |
paul@2 | 35 | digit += 1 |
paul@2 | 36 | digit = digit % 3 |
paul@2 | 37 | return tuple(colour) |
paul@2 | 38 | |
paul@2 | 39 | def getBlackOrWhite(colour): |
paul@2 | 40 | if sum(colour) / 3.0 > 127: |
paul@2 | 41 | return (0, 0, 0) |
paul@2 | 42 | else: |
paul@2 | 43 | return (255, 255, 255) |
paul@2 | 44 | |
paul@11 | 45 | # Macro functions. |
paul@11 | 46 | |
paul@11 | 47 | def getMonth(arg): |
paul@13 | 48 | if arg.startswith("current"): |
paul@11 | 49 | date = EventAggregatorSupport.getCurrentMonth() |
paul@13 | 50 | if len(arg) > 8: |
paul@13 | 51 | n = int(arg[7:]) |
paul@13 | 52 | date = EventAggregatorSupport.monthupdate(date, n) |
paul@11 | 53 | else: |
paul@11 | 54 | date = EventAggregatorSupport.getMonth(arg) |
paul@11 | 55 | return date |
paul@11 | 56 | |
paul@11 | 57 | def getFormMonth(request, calendar_name, argname): |
paul@11 | 58 | arg = request.form.get("%s-%s" % (calendar_name, argname), [None])[0] |
paul@11 | 59 | if arg is not None: |
paul@11 | 60 | return getMonth(arg) |
paul@11 | 61 | else: |
paul@11 | 62 | return None |
paul@10 | 63 | |
paul@0 | 64 | def execute(macro, args): |
paul@0 | 65 | |
paul@0 | 66 | """ |
paul@0 | 67 | Execute the 'macro' with the given 'args': an optional list of selected |
paul@0 | 68 | category names (categories whose pages are to be shown), together with |
paul@5 | 69 | optional named arguments of the following forms: |
paul@5 | 70 | |
paul@5 | 71 | start=YYYY-MM shows event details starting from the specified month |
paul@13 | 72 | start=current-N shows event details relative to the current month |
paul@5 | 73 | end=YYYY-MM shows event details ending at the specified month |
paul@13 | 74 | end=current+N shows event details relative to the current month |
paul@5 | 75 | |
paul@5 | 76 | mode=calendar shows a calendar view of events |
paul@5 | 77 | mode=list shows a list of events by month |
paul@9 | 78 | mode=ics provides iCalendar data for the events |
paul@5 | 79 | |
paul@5 | 80 | names=daily shows the name of an event on every day of that event |
paul@5 | 81 | names=weekly shows the name of an event once per week |
paul@11 | 82 | |
paul@11 | 83 | calendar=NAME uses the given NAME to provide request parameters which |
paul@11 | 84 | can be used to control the calendar view |
paul@0 | 85 | """ |
paul@0 | 86 | |
paul@0 | 87 | request = macro.request |
paul@0 | 88 | fmt = macro.formatter |
paul@0 | 89 | page = fmt.page |
paul@0 | 90 | _ = request.getText |
paul@0 | 91 | |
paul@0 | 92 | # Interpret the arguments. |
paul@0 | 93 | |
paul@0 | 94 | try: |
paul@0 | 95 | parsed_args = args and wikiutil.parse_quoted_separated(args, name_value=False) or [] |
paul@0 | 96 | except AttributeError: |
paul@0 | 97 | parsed_args = args.split(",") |
paul@0 | 98 | |
paul@0 | 99 | parsed_args = [arg for arg in parsed_args if arg] |
paul@0 | 100 | |
paul@0 | 101 | # Get special arguments. |
paul@0 | 102 | |
paul@0 | 103 | category_names = [] |
paul@0 | 104 | calendar_start = None |
paul@0 | 105 | calendar_end = None |
paul@0 | 106 | mode = "calendar" |
paul@5 | 107 | name_usage = "daily" |
paul@11 | 108 | calendar_name = None |
paul@0 | 109 | |
paul@0 | 110 | for arg in parsed_args: |
paul@0 | 111 | if arg.startswith("start="): |
paul@11 | 112 | calendar_start = getMonth(arg[6:]) |
paul@11 | 113 | |
paul@0 | 114 | elif arg.startswith("end="): |
paul@11 | 115 | calendar_end = getMonth(arg[4:]) |
paul@11 | 116 | |
paul@0 | 117 | elif arg.startswith("mode="): |
paul@0 | 118 | mode = arg[5:] |
paul@11 | 119 | |
paul@5 | 120 | elif arg.startswith("names="): |
paul@5 | 121 | name_usage = arg[6:] |
paul@11 | 122 | |
paul@11 | 123 | elif arg.startswith("calendar="): |
paul@11 | 124 | calendar_name = arg[9:] |
paul@11 | 125 | |
paul@0 | 126 | else: |
paul@0 | 127 | category_names.append(arg) |
paul@0 | 128 | |
paul@11 | 129 | # Find request parameters to override settings. |
paul@11 | 130 | |
paul@11 | 131 | if calendar_name is not None: |
paul@13 | 132 | calendar_start = getFormMonth(request, calendar_name, "start") or calendar_start |
paul@13 | 133 | calendar_end = getFormMonth(request, calendar_name, "end") or calendar_end |
paul@11 | 134 | |
paul@11 | 135 | # Get the events. |
paul@11 | 136 | |
paul@10 | 137 | events, shown_events, all_shown_events, earliest, latest = \ |
paul@10 | 138 | EventAggregatorSupport.getEvents(request, category_names, calendar_start, calendar_end) |
paul@2 | 139 | |
paul@13 | 140 | # Get a concrete period of time. |
paul@13 | 141 | |
paul@13 | 142 | first, last = EventAggregatorSupport.getConcretePeriod(calendar_start, calendar_end, earliest, latest) |
paul@13 | 143 | |
paul@13 | 144 | # Define some useful navigation months. |
paul@13 | 145 | |
paul@13 | 146 | if calendar_name is not None: |
paul@13 | 147 | span = EventAggregatorSupport.span(first, last) |
paul@13 | 148 | number_of_months = span[0] * 12 + span[1] + 1 |
paul@13 | 149 | |
paul@13 | 150 | previous_month_start = EventAggregatorSupport.prevmonth(first) |
paul@13 | 151 | next_month_start = EventAggregatorSupport.nextmonth(first) |
paul@13 | 152 | previous_month_end = EventAggregatorSupport.prevmonth(last) |
paul@13 | 153 | next_month_end = EventAggregatorSupport.nextmonth(last) |
paul@13 | 154 | |
paul@13 | 155 | previous_set_start = EventAggregatorSupport.monthupdate(first, -number_of_months) |
paul@13 | 156 | next_set_start = EventAggregatorSupport.monthupdate(first, number_of_months) |
paul@13 | 157 | previous_set_end = EventAggregatorSupport.monthupdate(last, -number_of_months) |
paul@13 | 158 | next_set_end = EventAggregatorSupport.monthupdate(last, number_of_months) |
paul@13 | 159 | |
paul@0 | 160 | # Make a calendar. |
paul@0 | 161 | |
paul@0 | 162 | output = [] |
paul@0 | 163 | |
paul@9 | 164 | # Output top-level information. |
paul@9 | 165 | |
paul@2 | 166 | if mode == "list": |
paul@2 | 167 | output.append(fmt.bullet_list(on=1, attr={"class" : "event-listings"})) |
paul@0 | 168 | |
paul@2 | 169 | # Visit all months in the requested range, or across known events. |
paul@0 | 170 | |
paul@10 | 171 | for year, month in EventAggregatorSupport.daterange(first, last): |
paul@2 | 172 | |
paul@2 | 173 | # Either output a calendar view... |
paul@0 | 174 | |
paul@2 | 175 | if mode == "calendar": |
paul@2 | 176 | |
paul@2 | 177 | # Output a month. |
paul@2 | 178 | |
paul@2 | 179 | output.append(fmt.table(on=1, attrs={"tableclass" : "event-month"})) |
paul@0 | 180 | |
paul@2 | 181 | output.append(fmt.table_row(on=1)) |
paul@2 | 182 | output.append(fmt.table_cell(on=1, attrs={"class" : "event-month-heading", "colspan" : "7"})) |
paul@11 | 183 | |
paul@11 | 184 | # Either write a month heading or produce a link for navigable |
paul@11 | 185 | # calendars. |
paul@11 | 186 | |
paul@11 | 187 | month_label = _(month_labels[month - 1]) # zero-based labels |
paul@11 | 188 | |
paul@11 | 189 | if calendar_name is not None: |
paul@13 | 190 | previous_set_link = "%s-start=%04d-%02d&%s-end=%04d-%02d" % ( |
paul@13 | 191 | (calendar_name,) + previous_set_start + (calendar_name,) + previous_set_end |
paul@13 | 192 | ) |
paul@13 | 193 | previous_month_link = "%s-start=%04d-%02d&%s-end=%04d-%02d" % ( |
paul@13 | 194 | (calendar_name,) + previous_month_start + (calendar_name,) + previous_month_end |
paul@13 | 195 | ) |
paul@11 | 196 | |
paul@11 | 197 | output.append(fmt.span(on=1, css_class="previous-month")) |
paul@13 | 198 | output.append(page.link_to_raw(request, wikiutil.escape("<<"), previous_set_link)) |
paul@11 | 199 | output.append(fmt.text(" ")) |
paul@11 | 200 | output.append(page.link_to_raw(request, wikiutil.escape("<"), previous_month_link)) |
paul@11 | 201 | output.append(fmt.span(on=0)) |
paul@11 | 202 | |
paul@13 | 203 | next_set_link = "%s-start=%04d-%02d&%s-end=%04d-%02d" % ( |
paul@13 | 204 | (calendar_name,) + next_set_start + (calendar_name,) + next_set_end |
paul@13 | 205 | ) |
paul@13 | 206 | next_month_link = "%s-start=%04d-%02d&%s-end=%04d-%02d" % ( |
paul@13 | 207 | (calendar_name,) + next_month_start + (calendar_name,) + next_month_end |
paul@13 | 208 | ) |
paul@11 | 209 | |
paul@11 | 210 | output.append(fmt.span(on=1, css_class="next-month")) |
paul@11 | 211 | output.append(page.link_to_raw(request, wikiutil.escape(">"), next_month_link)) |
paul@11 | 212 | output.append(fmt.text(" ")) |
paul@13 | 213 | output.append(page.link_to_raw(request, wikiutil.escape(">>"), next_set_link)) |
paul@11 | 214 | output.append(fmt.span(on=0)) |
paul@11 | 215 | |
paul@11 | 216 | full_month_label = "%s %s" % (month_label, year) |
paul@11 | 217 | month_link = "%s-start=%04d-%02d" % (calendar_name, year, month) |
paul@11 | 218 | output.append(page.link_to_raw(request, wikiutil.escape(full_month_label), month_link)) |
paul@11 | 219 | |
paul@11 | 220 | else: |
paul@11 | 221 | output.append(fmt.span(on=1)) |
paul@11 | 222 | output.append(fmt.text(month_label)) |
paul@11 | 223 | output.append(fmt.span(on=0)) |
paul@11 | 224 | output.append(fmt.text(" ")) |
paul@11 | 225 | output.append(fmt.span(on=1)) |
paul@11 | 226 | output.append(fmt.text(year)) |
paul@11 | 227 | output.append(fmt.span(on=0)) |
paul@11 | 228 | |
paul@2 | 229 | output.append(fmt.table_cell(on=0)) |
paul@2 | 230 | output.append(fmt.table_row(on=0)) |
paul@0 | 231 | |
paul@2 | 232 | # Weekday headings. |
paul@0 | 233 | |
paul@2 | 234 | output.append(fmt.table_row(on=1)) |
paul@0 | 235 | |
paul@2 | 236 | for weekday in range(0, 7): |
paul@5 | 237 | output.append(fmt.table_cell(on=1, attrs={"class" : "event-weekday-heading"})) |
paul@2 | 238 | output.append(fmt.text(_(weekday_labels[weekday]))) |
paul@0 | 239 | output.append(fmt.table_cell(on=0)) |
paul@2 | 240 | |
paul@2 | 241 | output.append(fmt.table_row(on=0)) |
paul@2 | 242 | |
paul@2 | 243 | # Process the days of the month. |
paul@2 | 244 | |
paul@2 | 245 | start_weekday, number_of_days = calendar.monthrange(year, month) |
paul@0 | 246 | |
paul@2 | 247 | # The start weekday is the weekday of day number 1. |
paul@2 | 248 | # Find the first day of the week, counting from below zero, if |
paul@2 | 249 | # necessary, in order to land on the first day of the month as |
paul@2 | 250 | # day number 1. |
paul@2 | 251 | |
paul@2 | 252 | first_day = 1 - start_weekday |
paul@2 | 253 | |
paul@2 | 254 | while first_day <= number_of_days: |
paul@2 | 255 | |
paul@5 | 256 | # Find events in this week and determine how to mark them on the |
paul@5 | 257 | # calendar. |
paul@5 | 258 | |
paul@5 | 259 | week_events = [] |
paul@5 | 260 | week_coverage = set() |
paul@5 | 261 | |
paul@5 | 262 | week_start = (year, month, max(first_day, 1)) |
paul@5 | 263 | week_end = (year, month, min(first_day + 6, number_of_days)) |
paul@5 | 264 | |
paul@5 | 265 | # Get event details. |
paul@5 | 266 | |
paul@5 | 267 | for event in shown_events.get((year, month), []): |
paul@5 | 268 | event_page, event_details = event |
paul@5 | 269 | |
paul@5 | 270 | # Test for the event in the current week. |
paul@5 | 271 | |
paul@5 | 272 | if event_details["start"] <= week_end and event_details["end"] >= week_start: |
paul@5 | 273 | |
paul@5 | 274 | # Find the coverage of this week for the event. |
paul@5 | 275 | |
paul@5 | 276 | event_start = max(event_details["start"], week_start) |
paul@5 | 277 | event_end = min(event_details["end"], week_end) |
paul@10 | 278 | event_coverage = set(EventAggregatorSupport.daterange(event_start, event_end)) |
paul@5 | 279 | |
paul@5 | 280 | # Update the overall coverage. |
paul@5 | 281 | |
paul@5 | 282 | week_coverage.update(event_coverage) |
paul@5 | 283 | |
paul@5 | 284 | # Try and fit the event into the events list. |
paul@5 | 285 | |
paul@5 | 286 | for i, (coverage, events) in enumerate(week_events): |
paul@5 | 287 | |
paul@5 | 288 | # Where the event does not overlap with the current |
paul@5 | 289 | # element, add it alongside existing events. |
paul@5 | 290 | |
paul@5 | 291 | if not coverage.intersection(event_coverage): |
paul@5 | 292 | events.append(event) |
paul@5 | 293 | week_events[i] = coverage.union(event_coverage), events |
paul@5 | 294 | break |
paul@5 | 295 | |
paul@5 | 296 | # Make a new element in the list if the event cannot be |
paul@5 | 297 | # marked alongside existing events. |
paul@5 | 298 | |
paul@5 | 299 | else: |
paul@5 | 300 | week_events.append((event_coverage, [event])) |
paul@5 | 301 | |
paul@5 | 302 | # Output a week, starting with the day numbers. |
paul@0 | 303 | |
paul@0 | 304 | output.append(fmt.table_row(on=1)) |
paul@0 | 305 | |
paul@0 | 306 | for weekday in range(0, 7): |
paul@2 | 307 | day = first_day + weekday |
paul@5 | 308 | date = (year, month, day) |
paul@2 | 309 | |
paul@2 | 310 | # Output out-of-month days. |
paul@2 | 311 | |
paul@2 | 312 | if day < 1 or day > number_of_days: |
paul@5 | 313 | output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-excluded"})) |
paul@2 | 314 | output.append(fmt.table_cell(on=0)) |
paul@2 | 315 | |
paul@2 | 316 | # Output normal days. |
paul@2 | 317 | |
paul@2 | 318 | else: |
paul@5 | 319 | if date in week_coverage: |
paul@5 | 320 | output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-busy"})) |
paul@2 | 321 | else: |
paul@5 | 322 | output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-empty"})) |
paul@2 | 323 | |
paul@2 | 324 | output.append(fmt.div(on=1)) |
paul@2 | 325 | output.append(fmt.span(on=1, css_class="event-day-number")) |
paul@2 | 326 | output.append(fmt.text(day)) |
paul@2 | 327 | output.append(fmt.span(on=0)) |
paul@2 | 328 | output.append(fmt.div(on=0)) |
paul@2 | 329 | |
paul@5 | 330 | # End of day. |
paul@5 | 331 | |
paul@5 | 332 | output.append(fmt.table_cell(on=0)) |
paul@5 | 333 | |
paul@5 | 334 | # End of day numbers. |
paul@5 | 335 | |
paul@5 | 336 | output.append(fmt.table_row(on=0)) |
paul@5 | 337 | |
paul@7 | 338 | # Either generate empty days... |
paul@5 | 339 | |
paul@7 | 340 | if not week_events: |
paul@5 | 341 | output.append(fmt.table_row(on=1)) |
paul@5 | 342 | |
paul@5 | 343 | for weekday in range(0, 7): |
paul@5 | 344 | day = first_day + weekday |
paul@5 | 345 | date = (year, month, day) |
paul@5 | 346 | |
paul@7 | 347 | # Output out-of-month days. |
paul@5 | 348 | |
paul@5 | 349 | if day < 1 or day > number_of_days: |
paul@5 | 350 | output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-excluded"})) |
paul@5 | 351 | output.append(fmt.table_cell(on=0)) |
paul@2 | 352 | |
paul@7 | 353 | # Output empty days. |
paul@5 | 354 | |
paul@5 | 355 | else: |
paul@5 | 356 | output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-empty"})) |
paul@5 | 357 | |
paul@7 | 358 | output.append(fmt.table_row(on=0)) |
paul@7 | 359 | |
paul@7 | 360 | # Or visit each set of scheduled events... |
paul@7 | 361 | |
paul@7 | 362 | else: |
paul@7 | 363 | for coverage, events in week_events: |
paul@7 | 364 | |
paul@7 | 365 | # Output each set. |
paul@7 | 366 | |
paul@7 | 367 | output.append(fmt.table_row(on=1)) |
paul@5 | 368 | |
paul@7 | 369 | # Then, output day details. |
paul@7 | 370 | |
paul@7 | 371 | for weekday in range(0, 7): |
paul@7 | 372 | day = first_day + weekday |
paul@7 | 373 | date = (year, month, day) |
paul@7 | 374 | |
paul@7 | 375 | # Skip out-of-month days. |
paul@7 | 376 | |
paul@7 | 377 | if day < 1 or day > number_of_days: |
paul@7 | 378 | output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-excluded"})) |
paul@7 | 379 | output.append(fmt.table_cell(on=0)) |
paul@5 | 380 | continue |
paul@2 | 381 | |
paul@7 | 382 | # Output the day. |
paul@2 | 383 | |
paul@7 | 384 | if date in coverage: |
paul@7 | 385 | output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-busy"})) |
paul@7 | 386 | else: |
paul@7 | 387 | output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-empty"})) |
paul@2 | 388 | |
paul@7 | 389 | # Get event details for the current day. |
paul@2 | 390 | |
paul@7 | 391 | for event_page, event_details in events: |
paul@7 | 392 | if not (event_details["start"] <= date <= event_details["end"]): |
paul@7 | 393 | continue |
paul@7 | 394 | |
paul@7 | 395 | # Get a pretty version of the page name. |
paul@3 | 396 | |
paul@10 | 397 | pretty_pagename = EventAggregatorSupport.getPrettyPageName(event_page) |
paul@7 | 398 | |
paul@7 | 399 | # Generate a colour for the event. |
paul@3 | 400 | |
paul@7 | 401 | bg = getColour(event_page.page_name) |
paul@7 | 402 | fg = getBlackOrWhite(bg) |
paul@7 | 403 | |
paul@7 | 404 | css_classes = ["event-summary"] |
paul@3 | 405 | |
paul@7 | 406 | if event_details["start"] == date: |
paul@7 | 407 | css_classes.append("event-starts") |
paul@7 | 408 | start_of_event = 1 |
paul@7 | 409 | else: |
paul@7 | 410 | start_of_event = 0 |
paul@2 | 411 | |
paul@7 | 412 | if event_details["end"] == date: |
paul@7 | 413 | css_classes.append("event-ends") |
paul@7 | 414 | |
paul@7 | 415 | # Output the event. |
paul@5 | 416 | |
paul@7 | 417 | if name_usage == "daily" or start_of_event or weekday == 0 or day == 1: |
paul@7 | 418 | hide_text = 0 |
paul@7 | 419 | else: |
paul@7 | 420 | hide_text = 1 |
paul@5 | 421 | |
paul@7 | 422 | output.append(fmt.div(on=1, css_class=(" ".join(css_classes)), |
paul@7 | 423 | style=("background-color: rgb(%d, %d, %d); color: rgb(%d, %d, %d);" % (bg + fg)))) |
paul@5 | 424 | |
paul@7 | 425 | if not hide_text: |
paul@7 | 426 | output.append(event_page.link_to_raw(request, wikiutil.escape(pretty_pagename))) |
paul@7 | 427 | |
paul@7 | 428 | output.append(fmt.div(on=0)) |
paul@2 | 429 | |
paul@7 | 430 | # End of day. |
paul@2 | 431 | |
paul@7 | 432 | output.append(fmt.table_cell(on=0)) |
paul@0 | 433 | |
paul@7 | 434 | # End of set. |
paul@5 | 435 | |
paul@7 | 436 | output.append(fmt.table_row(on=0)) |
paul@5 | 437 | |
paul@5 | 438 | # Process the next week... |
paul@0 | 439 | |
paul@2 | 440 | first_day += 7 |
paul@0 | 441 | |
paul@2 | 442 | # End of month. |
paul@0 | 443 | |
paul@2 | 444 | output.append(fmt.table(on=0)) |
paul@0 | 445 | |
paul@2 | 446 | # Or output a summary view... |
paul@0 | 447 | |
paul@2 | 448 | elif mode == "list": |
paul@0 | 449 | |
paul@2 | 450 | output.append(fmt.listitem(on=1, attr={"class" : "event-listings-month"})) |
paul@2 | 451 | output.append(fmt.div(on=1, attr={"class" : "event-listings-month-heading"})) |
paul@2 | 452 | output.append(fmt.span(on=1)) |
paul@2 | 453 | output.append(fmt.text(_(month_labels[month - 1]))) # zero-based labels |
paul@2 | 454 | output.append(fmt.span(on=0)) |
paul@2 | 455 | output.append(fmt.text(" ")) |
paul@2 | 456 | output.append(fmt.span(on=1)) |
paul@2 | 457 | output.append(fmt.text(year)) |
paul@2 | 458 | output.append(fmt.span(on=0)) |
paul@2 | 459 | output.append(fmt.div(on=0)) |
paul@0 | 460 | |
paul@2 | 461 | output.append(fmt.bullet_list(on=1, attr={"class" : "event-month-listings"})) |
paul@0 | 462 | |
paul@2 | 463 | for event_page, event_details in shown_events.get((year, month), []): |
paul@0 | 464 | |
paul@2 | 465 | # Get a pretty version of the page name. |
paul@0 | 466 | |
paul@10 | 467 | pretty_pagename = EventAggregatorSupport.getPrettyPageName(event_page) |
paul@0 | 468 | |
paul@2 | 469 | output.append(fmt.listitem(on=1, attr={"class" : "event-listing"})) |
paul@0 | 470 | |
paul@2 | 471 | # Link to the page using the pretty name. |
paul@0 | 472 | |
paul@2 | 473 | output.append(event_page.link_to_raw(request, wikiutil.escape(pretty_pagename))) |
paul@0 | 474 | |
paul@2 | 475 | # Add the event details. |
paul@0 | 476 | |
paul@2 | 477 | output.append(fmt.definition_list(on=1, attr={"class" : "event-details"})) |
paul@0 | 478 | |
paul@2 | 479 | for key, value in event_details.items(): |
paul@2 | 480 | output.append(fmt.definition_term(on=1)) |
paul@2 | 481 | output.append(fmt.text(key)) |
paul@2 | 482 | output.append(fmt.definition_term(on=0)) |
paul@2 | 483 | output.append(fmt.definition_desc(on=1)) |
paul@2 | 484 | output.append(fmt.text(value)) |
paul@2 | 485 | output.append(fmt.definition_desc(on=0)) |
paul@0 | 486 | |
paul@2 | 487 | output.append(fmt.definition_list(on=0)) |
paul@2 | 488 | output.append(fmt.listitem(on=0)) |
paul@0 | 489 | |
paul@2 | 490 | output.append(fmt.bullet_list(on=0)) |
paul@0 | 491 | |
paul@9 | 492 | # Output top-level information. |
paul@9 | 493 | |
paul@9 | 494 | # End of list view output. |
paul@9 | 495 | |
paul@10 | 496 | if mode == "list": |
paul@0 | 497 | output.append(fmt.bullet_list(on=0)) |
paul@0 | 498 | |
paul@0 | 499 | return ''.join(output) |
paul@0 | 500 | |
paul@0 | 501 | # vim: tabstop=4 expandtab shiftwidth=4 |