1.1 --- a/macros/EventAggregator.py Mon Mar 30 01:37:45 2009 +0200
1.2 +++ b/macros/EventAggregator.py Tue Mar 31 00:43:20 2009 +0200
1.3 @@ -37,6 +37,18 @@
1.4 else:
1.5 return (255, 255, 255)
1.6
1.7 +def getMonthActionQueryString(argname, month):
1.8 + if month is not None:
1.9 + return "%s=%04d-%02d" % ((argname,) + month)
1.10 + else:
1.11 + return ""
1.12 +
1.13 +def getMonthQueryString(calendar_name, argname, month):
1.14 + if month is not None:
1.15 + return "%s-%s=%04d-%02d" % ((calendar_name, argname) + month)
1.16 + else:
1.17 + return ""
1.18 +
1.19 # Macro functions.
1.20
1.21 def execute(macro, args):
1.22 @@ -139,6 +151,25 @@
1.23
1.24 output = []
1.25
1.26 + # Output download controls.
1.27 +
1.28 + download_all_link = "action=EventAggregatorSummary&doit=1&%s" % (
1.29 + "&".join([("category=%s" % name) for name in category_names])
1.30 + )
1.31 + download_link = download_all_link + ("&%s&%s" % (
1.32 + getMonthActionQueryString("start", calendar_start),
1.33 + getMonthActionQueryString("end", calendar_end)
1.34 + ))
1.35 +
1.36 + output.append(fmt.div(on=1, css_class="event-controls"))
1.37 + output.append(fmt.span(on=1, css_class="event-download-calendar"))
1.38 + output.append(page.link_to_raw(request, wikiutil.escape(_("Download this calendar in iCalendar format")), download_link))
1.39 + output.append(fmt.span(on=0))
1.40 + output.append(fmt.span(on=1, css_class="event-download-all"))
1.41 + output.append(page.link_to_raw(request, wikiutil.escape(_("Download all events in iCalendar format")), download_all_link))
1.42 + output.append(fmt.span(on=0))
1.43 + output.append(fmt.div(on=0))
1.44 +
1.45 # Output top-level information.
1.46
1.47 if mode == "list":
1.48 @@ -169,11 +200,13 @@
1.49 # Links to the previous set of months and to a calendar shifted
1.50 # back one month.
1.51
1.52 - previous_set_link = "%s-start=%04d-%02d&%s-end=%04d-%02d" % (
1.53 - (calendar_name,) + previous_set_start + (calendar_name,) + previous_set_end
1.54 + previous_set_link = "%s&%s" % (
1.55 + getMonthQueryString(calendar_name, "start", previous_set_start),
1.56 + getMonthQueryString(calendar_name, "end", previous_set_end)
1.57 )
1.58 - previous_month_link = "%s-start=%04d-%02d&%s-end=%04d-%02d" % (
1.59 - (calendar_name,) + previous_month_start + (calendar_name,) + previous_month_end
1.60 + previous_month_link = "%s&%s" % (
1.61 + getMonthQueryString(calendar_name, "start", previous_month_start),
1.62 + getMonthQueryString(calendar_name, "end", previous_month_end)
1.63 )
1.64
1.65 output.append(fmt.span(on=1, css_class="previous-month"))
1.66 @@ -185,11 +218,13 @@
1.67 # Links to the next set of months and to a calendar shifted
1.68 # forward one month.
1.69
1.70 - next_set_link = "%s-start=%04d-%02d&%s-end=%04d-%02d" % (
1.71 - (calendar_name,) + next_set_start + (calendar_name,) + next_set_end
1.72 + next_set_link = "%s&%s" % (
1.73 + getMonthQueryString(calendar_name, "start", next_set_start),
1.74 + getMonthQueryString(calendar_name, "end", next_set_end)
1.75 )
1.76 - next_month_link = "%s-start=%04d-%02d&%s-end=%04d-%02d" % (
1.77 - (calendar_name,) + next_month_start + (calendar_name,) + next_month_end
1.78 + next_month_link = "%s&%s" % (
1.79 + getMonthQueryString(calendar_name, "start", next_month_start),
1.80 + getMonthQueryString(calendar_name, "end", next_month_end)
1.81 )
1.82
1.83 output.append(fmt.span(on=1, css_class="next-month"))
1.84 @@ -201,9 +236,11 @@
1.85 # A link leading to this month being at the top of the calendar.
1.86
1.87 full_month_label = "%s %s" % (month_label, year)
1.88 - month_link = "%s-start=%04d-%02d&%s-end=%04d-%02d" % (
1.89 - (calendar_name, year, month, calendar_name) +
1.90 - EventAggregatorSupport.monthupdate((year, month), number_of_months - 1)
1.91 + end_month = EventAggregatorSupport.monthupdate((year, month), number_of_months - 1)
1.92 +
1.93 + month_link = "%s&%s" % (
1.94 + getMonthQueryString(calendar_name, "start", (year, month)),
1.95 + getMonthQueryString(calendar_name, "end", end_month)
1.96 )
1.97 output.append(page.link_to_raw(request, wikiutil.escape(full_month_label), month_link))
1.98
1.99 @@ -418,16 +455,11 @@
1.100
1.101 # Get the events in order.
1.102
1.103 - ordered_events = []
1.104 -
1.105 - for event_page, event_details in shown_events.get((year, month), []):
1.106 - ordered_events.append((event_details["start"], event_details["end"], (event_page, event_details)))
1.107 -
1.108 - ordered_events.sort(lambda x, y: cmp((x[0], x[1]), (y[0], y[1])))
1.109 + ordered_events = EventAggregatorSummary.getOrderedEvents(shown_events.get((year, month), []))
1.110
1.111 # Show the events in order.
1.112
1.113 - for start, end, (event_page, event_details) in ordered_events:
1.114 + for event_page, event_details in ordered_events:
1.115 event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details)
1.116
1.117 output.append(fmt.listitem(on=1, attr={"class" : "event-listing"}))