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