1.1 --- a/EventAggregatorSupport.py Wed Apr 13 00:32:04 2011 +0200
1.2 +++ b/EventAggregatorSupport.py Fri Apr 15 00:14:04 2011 +0200
1.3 @@ -888,7 +888,7 @@
1.4
1.5 return Timespan(calendar_start, calendar_end)
1.6
1.7 -def getConcretePeriod(calendar_start, calendar_end, earliest, latest):
1.8 +def getConcretePeriod(calendar_start, calendar_end, earliest, latest, resolution):
1.9
1.10 """
1.11 From the requested 'calendar_start' and 'calendar_end', which may be None,
1.12 @@ -910,7 +910,7 @@
1.13 # requested period. If all events were to be shown but none were found show
1.14 # the current month.
1.15
1.16 - if isinstance(first, Date):
1.17 + if resolution == "date":
1.18 get_current = getCurrentDate
1.19 else:
1.20 get_current = getCurrentMonth
1.21 @@ -920,6 +920,10 @@
1.22 if last is None:
1.23 last = first or get_current()
1.24
1.25 + if resolution == "month":
1.26 + first = first.as_month()
1.27 + last = last.as_month()
1.28 +
1.29 # Permit "expiring" periods (where the start date approaches the end date).
1.30
1.31 return min(first, last), last
1.32 @@ -1052,7 +1056,7 @@
1.33 def __init__(self, data):
1.34 self.data = data
1.35
1.36 - def months(self):
1.37 + def count(self):
1.38 return self.data[0] * 12 + self.data[1]
1.39
1.40 class Convertible:
1.41 @@ -1106,7 +1110,7 @@
1.42 length = min(len(data), len(other_data))
1.43 return cmp(data[:length], other_data[:length])
1.44
1.45 - def until(self, start, end, nextfn, prevfn):
1.46 + def _until(self, start, end, nextfn, prevfn):
1.47
1.48 """
1.49 Return a collection of units of time by starting from the given 'start'
1.50 @@ -1171,18 +1175,24 @@
1.51 year, month = self.as_tuple()[:2]
1.52 return Month((year + (month - 1 + n) / 12, (month - 1 + n) % 12 + 1))
1.53
1.54 + update = month_update
1.55 +
1.56 def next_month(self):
1.57
1.58 "Return the month following this one."
1.59
1.60 return self.month_update(1)
1.61
1.62 + next = next_month
1.63 +
1.64 def previous_month(self):
1.65
1.66 "Return the month preceding this one."
1.67
1.68 return self.month_update(-1)
1.69
1.70 + previous = previous_month
1.71 +
1.72 def __sub__(self, start):
1.73
1.74 """
1.75 @@ -1196,7 +1206,9 @@
1.76
1.77 "Return the collection of months from this month until 'end'."
1.78
1.79 - return self.until(self.as_month(), end.as_month(), Month.next_month, Month.previous_month)
1.80 + return self._until(self.as_month(), end.as_month(), Month.next_month, Month.previous_month)
1.81 +
1.82 + until = months_until
1.83
1.84 class Date(Month):
1.85
1.86 @@ -1238,6 +1250,8 @@
1.87 dt_new = dt + delta
1.88 return Date((dt_new.year, dt_new.month, dt_new.day))
1.89
1.90 + update = day_update
1.91 +
1.92 def next_day(self):
1.93
1.94 "Return the date following this one."
1.95 @@ -1252,6 +1266,8 @@
1.96 else:
1.97 return Date((year, month, day + 1))
1.98
1.99 + next = next_day
1.100 +
1.101 def previous_day(self):
1.102
1.103 "Return the date preceding this one."
1.104 @@ -1266,11 +1282,15 @@
1.105 else:
1.106 return Date((year, month, day - 1))
1.107
1.108 + previous = previous_day
1.109 +
1.110 def days_until(self, end):
1.111
1.112 "Return the collection of days from this date until 'end'."
1.113
1.114 - return self.until(self.as_date(), end.as_date(), Date.next_day, Date.previous_day)
1.115 + return self._until(self.as_date(), end.as_date(), Date.next_day, Date.previous_day)
1.116 +
1.117 + until = days_until
1.118
1.119 class DateTime(Date):
1.120
3.1 --- a/macros/EventAggregator.py Wed Apr 13 00:32:04 2011 +0200
3.2 +++ b/macros/EventAggregator.py Fri Apr 15 00:14:04 2011 +0200
3.3 @@ -23,7 +23,8 @@
3.4
3.5 def __init__(self, page, calendar_name, raw_calendar_start, raw_calendar_end,
3.6 original_calendar_start, original_calendar_end, calendar_start, calendar_end,
3.7 - first, last, category_names, template_name, parent_name, mode, name_usage):
3.8 + first, last, category_names, template_name, parent_name, mode, resolution,
3.9 + name_usage, map_name):
3.10
3.11 """
3.12 Initialise the view with the current 'page', a 'calendar_name' (which
3.13 @@ -39,8 +40,14 @@
3.14 The additional 'category_names', 'template_name', 'parent_name' and
3.15 'mode' parameters are used to configure the links employed by the view.
3.16
3.17 + The 'resolution' affects the view for certain modes and is also used to
3.18 + parameterise links.
3.19 +
3.20 The 'name_usage' parameter controls how names are shown on calendar mode
3.21 events, such as how often labels are repeated.
3.22 +
3.23 + The 'map_name' parameter provides the name of a map to be used in the
3.24 + map mode.
3.25 """
3.26
3.27 self.page = page
3.28 @@ -54,7 +61,9 @@
3.29 self.template_name = template_name
3.30 self.parent_name = parent_name
3.31 self.mode = mode
3.32 + self.resolution = resolution
3.33 self.name_usage = name_usage
3.34 + self.map_name = map_name
3.35
3.36 self.category_name_parameters = "&".join([("category=%s" % name) for name in category_names])
3.37
3.38 @@ -62,17 +71,17 @@
3.39
3.40 # Store the view parameters.
3.41
3.42 - self.number_of_months = (last - first).months() + 1
3.43 + self.duration = (last - first).count() + 1
3.44
3.45 - self.previous_month_start = first.previous_month()
3.46 - self.next_month_start = first.next_month()
3.47 - self.previous_month_end = last.previous_month()
3.48 - self.next_month_end = last.next_month()
3.49 + self.previous_start = first.previous()
3.50 + self.next_start = first.next()
3.51 + self.previous_end = last.previous()
3.52 + self.next_end = last.next()
3.53
3.54 - self.previous_set_start = first.month_update(-self.number_of_months)
3.55 - self.next_set_start = first.month_update(self.number_of_months)
3.56 - self.previous_set_end = last.month_update(-self.number_of_months)
3.57 - self.next_set_end = last.month_update(self.number_of_months)
3.58 + self.previous_set_start = first.update(-self.duration)
3.59 + self.next_set_start = first.update(self.duration)
3.60 + self.previous_set_end = last.update(-self.duration)
3.61 + self.next_set_end = last.update(self.duration)
3.62
3.63 def getQualifiedParameterName(self, argname):
3.64
3.65 @@ -124,18 +133,20 @@
3.66 else:
3.67 return ""
3.68
3.69 - def getNavigationLink(self, start, end, mode=None):
3.70 + def getNavigationLink(self, start, end, mode=None, resolution=None):
3.71
3.72 """
3.73 Return a query string fragment for navigation to a view showing months
3.74 from 'start' to 'end' inclusive, with the optional 'mode' indicating the
3.75 - view style.
3.76 + view style and the optional 'resolution' indicating the resolution of a
3.77 + view, if configurable.
3.78 """
3.79
3.80 - return "%s&%s&%s=%s" % (
3.81 + return "%s&%s&%s=%s&%s=%s" % (
3.82 self.getRawDateQueryString("start", start),
3.83 self.getRawDateQueryString("end", end),
3.84 - self.getQualifiedParameterName("mode"), mode or self.mode
3.85 + self.getQualifiedParameterName("mode"), mode or self.mode,
3.86 + self.getQualifiedParameterName("resolution"), resolution or self.resolution
3.87 )
3.88
3.89 def getFullDateLabel(self, date):
3.90 @@ -148,6 +159,43 @@
3.91 request = page.request
3.92 return getFullMonthLabel(request, year_month)
3.93
3.94 + def getFullLabel(self, arg):
3.95 + return self.resolution == "date" and self.getFullDateLabel(arg) or self.getFullMonthLabel(arg)
3.96 +
3.97 + def _getCalendarPeriod(self, start_label, end_label, default_label):
3.98 + output = []
3.99 + if start_label:
3.100 + output.append(start_label)
3.101 + if self.calendar_end and start_label != end_label:
3.102 + if output:
3.103 + output.append(" - ")
3.104 + output.append(end_label)
3.105 + return "".join(output) or default_label
3.106 +
3.107 + def getCalendarPeriod(self):
3.108 + _ = self.page.request.getText
3.109 + return self._getCalendarPeriod(
3.110 + self.calendar_start and self.getFullLabel(self.calendar_start),
3.111 + self.calendar_end and self.getFullLabel(self.calendar_end),
3.112 + _("All events")
3.113 + )
3.114 +
3.115 + def getOriginalCalendarPeriod(self):
3.116 + _ = self.page.request.getText
3.117 + return self._getCalendarPeriod(
3.118 + self.original_calendar_start and self.getFullLabel(self.original_calendar_start),
3.119 + self.original_calendar_end and self.getFullLabel(self.original_calendar_end),
3.120 + _("All events")
3.121 + )
3.122 +
3.123 + def getRawCalendarPeriod(self):
3.124 + _ = self.page.request.getText
3.125 + return self._getCalendarPeriod(
3.126 + self.raw_calendar_start,
3.127 + self.raw_calendar_end,
3.128 + _("No period specified")
3.129 + )
3.130 +
3.131 def writeDownloadControls(self):
3.132
3.133 """
3.134 @@ -166,7 +214,7 @@
3.135
3.136 download_dialogue_link = "action=EventAggregatorSummary&parent=%s&resolution=%s&%s" % (
3.137 self.parent_name or "",
3.138 - self.mode == "day" and "date" or "month",
3.139 + self.resolution,
3.140 self.category_name_parameters
3.141 )
3.142 download_all_link = download_dialogue_link + "&doit=1"
3.143 @@ -204,22 +252,9 @@
3.144
3.145 # Pop-up descriptions of the downloadable calendars.
3.146
3.147 - get_label = self.mode == "day" and self.getFullDateLabel or self.getFullMonthLabel
3.148 -
3.149 - calendar_period = (self.calendar_start or self.calendar_end) and \
3.150 - "%s - %s" % (
3.151 - get_label(self.calendar_start),
3.152 - get_label(self.calendar_end)
3.153 - ) or _("All events")
3.154 -
3.155 - original_calendar_period = (self.original_calendar_start or self.original_calendar_end) and \
3.156 - "%s - %s" % (
3.157 - get_label(self.original_calendar_start),
3.158 - get_label(self.original_calendar_end)
3.159 - ) or _("All events")
3.160 -
3.161 - raw_calendar_period = (self.raw_calendar_start or self.raw_calendar_end) and \
3.162 - "%s - %s" % (self.raw_calendar_start, self.raw_calendar_end) or _("No period specified")
3.163 + calendar_period = self.getCalendarPeriod()
3.164 + original_calendar_period = self.getOriginalCalendarPeriod()
3.165 + raw_calendar_period = self.getRawCalendarPeriod()
3.166
3.167 # Write the controls.
3.168
3.169 @@ -297,29 +332,67 @@
3.170
3.171 output = []
3.172
3.173 - start = self.calendar_start and self.calendar_start.as_month()
3.174 - end = self.calendar_end and self.calendar_end.as_month()
3.175 + start = self.calendar_start
3.176 + end = self.calendar_end
3.177
3.178 - calendar_link = self.getNavigationLink(start, end, "calendar")
3.179 + calendar_link = self.getNavigationLink(start and start.as_month(), end and end.as_month(), "calendar", "month")
3.180 list_link = self.getNavigationLink(start, end, "list")
3.181 table_link = self.getNavigationLink(start, end, "table")
3.182 + map_link = self.getNavigationLink(start, end, "map")
3.183
3.184 # Write the controls.
3.185
3.186 output.append(fmt.div(on=1, css_class="event-view-controls"))
3.187 - output.append(fmt.span(on=1, css_class="event-view"))
3.188 - output.append(linkToPage(request, page, _("View as calendar"), calendar_link))
3.189 - output.append(fmt.span(on=0))
3.190 - output.append(fmt.span(on=1, css_class="event-view"))
3.191 - output.append(linkToPage(request, page, _("View as list"), list_link))
3.192 - output.append(fmt.span(on=0))
3.193 - output.append(fmt.span(on=1, css_class="event-view"))
3.194 - output.append(linkToPage(request, page, _("View as table"), table_link))
3.195 - output.append(fmt.span(on=0))
3.196 +
3.197 + if self.mode != "calendar":
3.198 + output.append(fmt.span(on=1, css_class="event-view"))
3.199 + output.append(linkToPage(request, page, _("View as calendar"), calendar_link))
3.200 + output.append(fmt.span(on=0))
3.201 +
3.202 + if self.mode != "list":
3.203 + output.append(fmt.span(on=1, css_class="event-view"))
3.204 + output.append(linkToPage(request, page, _("View as list"), list_link))
3.205 + output.append(fmt.span(on=0))
3.206 +
3.207 + if self.mode != "table":
3.208 + output.append(fmt.span(on=1, css_class="event-view"))
3.209 + output.append(linkToPage(request, page, _("View as table"), table_link))
3.210 + output.append(fmt.span(on=0))
3.211 +
3.212 + if self.mode != "map" and self.map_name is not None:
3.213 + output.append(fmt.span(on=1, css_class="event-view"))
3.214 + output.append(linkToPage(request, page, _("View as map"), map_link))
3.215 + output.append(fmt.span(on=0))
3.216 +
3.217 output.append(fmt.div(on=0))
3.218
3.219 return "".join(output)
3.220
3.221 + def writeMapHeading(self):
3.222 +
3.223 + """
3.224 + Return the calendar heading for the current calendar, providing links
3.225 + permitting navigation to other periods.
3.226 + """
3.227 +
3.228 + label = self.getCalendarPeriod()
3.229 +
3.230 + if self.raw_calendar_start is None or self.raw_calendar_end is None:
3.231 + fmt = self.page.formatter
3.232 + output = []
3.233 + output.append(fmt.span(on=1))
3.234 + output.append(fmt.text(label))
3.235 + output.append(fmt.span(on=0))
3.236 + return "".join(output)
3.237 + else:
3.238 + return self._writeCalendarHeading(label, self.calendar_start, self.calendar_end)
3.239 +
3.240 + def writeDateHeading(self, date):
3.241 + if isinstance(date, Date):
3.242 + return self.writeDayHeading(date)
3.243 + else:
3.244 + return self.writeMonthHeading(date)
3.245 +
3.246 def writeMonthHeading(self, year_month):
3.247
3.248 """
3.249 @@ -327,11 +400,33 @@
3.250 providing links permitting navigation to other months.
3.251 """
3.252
3.253 + full_month_label = self.getFullMonthLabel(year_month)
3.254 + end_month = year_month.update(self.duration - 1)
3.255 + return self._writeCalendarHeading(full_month_label, year_month, end_month)
3.256 +
3.257 + def writeDayHeading(self, date):
3.258 +
3.259 + """
3.260 + Return the calendar heading for the given 'date' (a Date object)
3.261 + providing links permitting navigation to other dates.
3.262 + """
3.263 +
3.264 + full_date_label = self.getFullDateLabel(date)
3.265 + end_date = date.update(self.duration - 1)
3.266 + return self._writeCalendarHeading(full_date_label, date, end_date)
3.267 +
3.268 + def _writeCalendarHeading(self, label, start, end):
3.269 +
3.270 + """
3.271 + Write a calendar heading providing links permitting navigation to other
3.272 + periods, using the given 'label' along with the 'start' and 'end' dates
3.273 + to provide a link to a particular period.
3.274 + """
3.275 +
3.276 page = self.page
3.277 request = page.request
3.278 fmt = page.formatter
3.279 _ = request.getText
3.280 - full_month_label = self.getFullMonthLabel(year_month)
3.281
3.282 output = []
3.283
3.284 @@ -346,8 +441,8 @@
3.285 previous_set_link = self.getNavigationLink(
3.286 self.previous_set_start, self.previous_set_end
3.287 )
3.288 - previous_month_link = self.getNavigationLink(
3.289 - self.previous_month_start, self.previous_month_end
3.290 + previous_link = self.getNavigationLink(
3.291 + self.previous_start, self.previous_end
3.292 )
3.293
3.294 # Links to the next set of months and to a calendar shifted
3.295 @@ -356,33 +451,31 @@
3.296 next_set_link = self.getNavigationLink(
3.297 self.next_set_start, self.next_set_end
3.298 )
3.299 - next_month_link = self.getNavigationLink(
3.300 - self.next_month_start, self.next_month_end
3.301 + next_link = self.getNavigationLink(
3.302 + self.next_start, self.next_end
3.303 )
3.304
3.305 - # A link leading to this month being at the top of the calendar.
3.306 -
3.307 - end_month = year_month.month_update(self.number_of_months - 1)
3.308 + # A link leading to this date being at the top of the calendar.
3.309
3.310 - month_link = self.getNavigationLink(year_month, end_month)
3.311 + date_link = self.getNavigationLink(start, end)
3.312
3.313 - output.append(fmt.span(on=1, css_class="previous-month"))
3.314 + output.append(fmt.span(on=1, css_class="previous"))
3.315 output.append(linkToPage(request, page, "<<", previous_set_link))
3.316 output.append(fmt.text(" "))
3.317 - output.append(linkToPage(request, page, "<", previous_month_link))
3.318 + output.append(linkToPage(request, page, "<", previous_link))
3.319 output.append(fmt.span(on=0))
3.320
3.321 - output.append(fmt.span(on=1, css_class="next-month"))
3.322 - output.append(linkToPage(request, page, ">", next_month_link))
3.323 + output.append(fmt.span(on=1, css_class="next"))
3.324 + output.append(linkToPage(request, page, ">", next_link))
3.325 output.append(fmt.text(" "))
3.326 output.append(linkToPage(request, page, ">>", next_set_link))
3.327 output.append(fmt.span(on=0))
3.328
3.329 - output.append(linkToPage(request, page, full_month_label, month_link))
3.330 + output.append(linkToPage(request, page, label, date_link))
3.331
3.332 else:
3.333 output.append(fmt.span(on=1))
3.334 - output.append(fmt.text(full_month_label))
3.335 + output.append(fmt.text(label))
3.336 output.append(fmt.span(on=0))
3.337
3.338 return "".join(output)
3.339 @@ -407,7 +500,7 @@
3.340 # form.
3.341
3.342 navigation_link = self.getNavigationLink(
3.343 - self.calendar_start, self.calendar_end, self.mode
3.344 + self.calendar_start, self.calendar_end
3.345 )
3.346
3.347 # Prepare the link to the new event form, incorporating the above
3.348 @@ -420,7 +513,7 @@
3.349
3.350 # Prepare a link to the day view for this day.
3.351
3.352 - day_view_link = self.getNavigationLink(date, date, "day")
3.353 + day_view_link = self.getNavigationLink(date, date, "day", "date")
3.354
3.355 # Output the heading class.
3.356
3.357 @@ -821,18 +914,15 @@
3.358
3.359 # Day layout methods.
3.360
3.361 - def writeDayHeading(self, date, colspan=1):
3.362 + def writeDayTableHeading(self, date, colspan=1):
3.363 page = self.page
3.364 - request = page.request
3.365 fmt = page.formatter
3.366 - _ = request.getText
3.367 - full_date_label = self.getFullDateLabel(date)
3.368
3.369 output = []
3.370 output.append(fmt.table_row(on=1))
3.371
3.372 output.append(fmt.table_cell(on=1, attrs={"class" : "event-full-day-heading", "colspan" : str(colspan)}))
3.373 - output.append(fmt.text(full_date_label))
3.374 + output.append(self.writeDayHeading(date))
3.375 output.append(fmt.table_cell(on=0))
3.376
3.377 output.append(fmt.table_row(on=0))
3.378 @@ -921,7 +1011,7 @@
3.379
3.380 columns = len(day_slots[location]) * 2 - 1
3.381 output.append(fmt.table_cell(on=1, attrs={"class" : "event-location-heading", "colspan" : str(columns)}))
3.382 - output.append(fmt.text(location))
3.383 + output.append(fmt.text(location or ""))
3.384 output.append(fmt.table_cell(on=0))
3.385
3.386 # Add a trailing spacer.
3.387 @@ -1048,6 +1138,19 @@
3.388 output.append(fmt.table_cell(on=0))
3.389 return "".join(output)
3.390
3.391 + # Map layout methods.
3.392 +
3.393 + def writeMapTableHeading(self):
3.394 + page = self.page
3.395 + fmt = page.formatter
3.396 +
3.397 + output = []
3.398 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-map-heading"}))
3.399 + output.append(self.writeMapHeading())
3.400 + output.append(fmt.table_cell(on=0))
3.401 +
3.402 + return "".join(output)
3.403 +
3.404 def showDictError(self, text, pagename):
3.405 page = self.page
3.406 fmt = page.formatter
3.407 @@ -1192,9 +1295,12 @@
3.408
3.409 mode = getQualifiedParameter(request, calendar_name, "mode", mode or "calendar")
3.410
3.411 - # Different modes require different levels of precision.
3.412 + # Different modes require different levels of precision by default.
3.413
3.414 - if mode == "day":
3.415 + resolution = getQualifiedParameter(request, calendar_name, "resolution", mode == "day" and "date" or "month")
3.416 + resolution = mode == "calendar" and "month" or resolution
3.417 +
3.418 + if resolution == "date":
3.419 get_date = getParameterDate
3.420 get_form_date = getFormDate
3.421 else:
3.422 @@ -1218,13 +1324,14 @@
3.423
3.424 # Get a concrete period of time.
3.425
3.426 - first, last = getConcretePeriod(calendar_start, calendar_end, earliest, latest)
3.427 + first, last = getConcretePeriod(calendar_start, calendar_end, earliest, latest, resolution)
3.428
3.429 # Define a view of the calendar, retaining useful navigational information.
3.430
3.431 view = View(page, calendar_name, raw_calendar_start, raw_calendar_end,
3.432 original_calendar_start, original_calendar_end, calendar_start, calendar_end,
3.433 - first, last, category_names, template_name, parent_name, mode, name_usage)
3.434 + first, last, category_names, template_name, parent_name, mode, resolution,
3.435 + name_usage, map_name)
3.436
3.437 # Make a calendar.
3.438
3.439 @@ -1401,6 +1508,15 @@
3.440
3.441 output.append(fmt.div(on=1, css_class="event-map"))
3.442
3.443 + output.append(fmt.table(on=1))
3.444 +
3.445 + output.append(fmt.table_row(on=1))
3.446 + output.append(view.writeMapTableHeading())
3.447 + output.append(fmt.table_row(on=0))
3.448 +
3.449 + output.append(fmt.table_row(on=1))
3.450 + output.append(fmt.table_cell(on=1))
3.451 +
3.452 output.append(fmt.div(on=1, css_class="event-map-container",
3.453 style="width: %spx; height: %spx; background-image: url('%s')" % (
3.454 escattr(map_width), escattr(map_height), map_image_url)
3.455 @@ -1472,158 +1588,153 @@
3.456 # End of map view output.
3.457
3.458 output.append(fmt.div(on=0))
3.459 + output.append(fmt.table_cell(on=0))
3.460 + output.append(fmt.table_row(on=0))
3.461 + output.append(fmt.table(on=0))
3.462 output.append(fmt.div(on=0))
3.463
3.464 - # Output a list or month calendar. These views show month-by-month data.
3.465 + # Output a list.
3.466
3.467 - elif mode in ("list", "calendar"):
3.468 -
3.469 - # Output top-level information.
3.470 + elif mode == "list":
3.471
3.472 # Start of list view output.
3.473
3.474 - if mode == "list":
3.475 - output.append(fmt.bullet_list(on=1, attr={"class" : "event-listings"}))
3.476 + output.append(fmt.bullet_list(on=1, attr={"class" : "event-listings"}))
3.477 +
3.478 + # Output a list.
3.479 +
3.480 + for period in first.until(last):
3.481 +
3.482 + output.append(fmt.listitem(on=1, attr={"class" : "event-listings-period"}))
3.483 + output.append(fmt.div(on=1, attr={"class" : "event-listings-heading"}))
3.484 +
3.485 + # Either write a date heading or produce links for navigable
3.486 + # calendars.
3.487 +
3.488 + output.append(view.writeDateHeading(period))
3.489 +
3.490 + output.append(fmt.div(on=0))
3.491 +
3.492 + output.append(fmt.bullet_list(on=1, attr={"class" : "event-period-listings"}))
3.493 +
3.494 + # Show the events in order.
3.495 +
3.496 + for event in getEventsInPeriod(all_shown_events, getCalendarPeriod(period, period)):
3.497 + event_page = event.getPage()
3.498 + event_details = event.getDetails()
3.499 + event_summary = event.getSummary(parent_name)
3.500 +
3.501 + output.append(fmt.listitem(on=1, attr={"class" : "event-listing"}))
3.502 +
3.503 + # Link to the page using the summary.
3.504 +
3.505 + output.append(fmt.paragraph(on=1))
3.506 + output.append(event_page.linkToPage(request, event_summary))
3.507 + output.append(fmt.paragraph(on=0))
3.508 +
3.509 + # Start and end dates.
3.510 +
3.511 + output.append(fmt.paragraph(on=1))
3.512 + output.append(fmt.span(on=1))
3.513 + output.append(fmt.text(str(event_details["start"])))
3.514 + output.append(fmt.span(on=0))
3.515 + output.append(fmt.text(" - "))
3.516 + output.append(fmt.span(on=1))
3.517 + output.append(fmt.text(str(event_details["end"])))
3.518 + output.append(fmt.span(on=0))
3.519 + output.append(fmt.paragraph(on=0))
3.520 +
3.521 + # Location.
3.522 +
3.523 + if event_details.has_key("location"):
3.524 + output.append(fmt.paragraph(on=1))
3.525 + output.append(formatText(event_details["location"], request, fmt, parser_cls))
3.526 + output.append(fmt.paragraph(on=1))
3.527 +
3.528 + # Topics.
3.529 +
3.530 + if event_details.has_key("topics") or event_details.has_key("categories"):
3.531 + output.append(fmt.bullet_list(on=1, attr={"class" : "event-topics"}))
3.532 +
3.533 + for topic in event_details.get("topics") or event_details.get("categories") or []:
3.534 + output.append(fmt.listitem(on=1))
3.535 + output.append(formatText(topic, request, fmt, parser_cls))
3.536 + output.append(fmt.listitem(on=0))
3.537 +
3.538 + output.append(fmt.bullet_list(on=0))
3.539 +
3.540 + output.append(fmt.listitem(on=0))
3.541 +
3.542 + output.append(fmt.bullet_list(on=0))
3.543 +
3.544 + # End of list view output.
3.545 +
3.546 + output.append(fmt.bullet_list(on=0))
3.547 +
3.548 + # Output a month calendar. This shows month-by-month data.
3.549 +
3.550 + elif mode == "calendar":
3.551
3.552 # Visit all months in the requested range, or across known events.
3.553
3.554 for month in first.months_until(last):
3.555
3.556 - # Either output a calendar view...
3.557 -
3.558 - if mode == "calendar":
3.559 -
3.560 - # Output a month.
3.561 + # Output a month.
3.562
3.563 - output.append(fmt.table(on=1, attrs={"tableclass" : "event-month"}))
3.564 -
3.565 - # Either write a month heading or produce links for navigable
3.566 - # calendars.
3.567 -
3.568 - output.append(view.writeMonthTableHeading(month))
3.569 -
3.570 - # Weekday headings.
3.571 + output.append(fmt.table(on=1, attrs={"tableclass" : "event-month"}))
3.572
3.573 - output.append(view.writeWeekdayHeadings())
3.574 -
3.575 - # Process the days of the month.
3.576 -
3.577 - start_weekday, number_of_days = month.month_properties()
3.578 + # Either write a month heading or produce links for navigable
3.579 + # calendars.
3.580
3.581 - # The start weekday is the weekday of day number 1.
3.582 - # Find the first day of the week, counting from below zero, if
3.583 - # necessary, in order to land on the first day of the month as
3.584 - # day number 1.
3.585 + output.append(view.writeMonthTableHeading(month))
3.586
3.587 - first_day = 1 - start_weekday
3.588 + # Weekday headings.
3.589
3.590 - while first_day <= number_of_days:
3.591 -
3.592 - # Find events in this week and determine how to mark them on the
3.593 - # calendar.
3.594 + output.append(view.writeWeekdayHeadings())
3.595
3.596 - week_start = month.as_date(max(first_day, 1))
3.597 - week_end = month.as_date(min(first_day + 6, number_of_days))
3.598 -
3.599 - full_coverage, week_slots = getCoverage(
3.600 - getEventsInPeriod(all_shown_events, getCalendarPeriod(week_start, week_end)))
3.601 -
3.602 - # Output a week, starting with the day numbers.
3.603 + # Process the days of the month.
3.604
3.605 - output.append(view.writeDayNumbers(first_day, number_of_days, month, full_coverage))
3.606 -
3.607 - # Either generate empty days...
3.608 -
3.609 - if not week_slots:
3.610 - output.append(view.writeEmptyWeek(first_day, number_of_days))
3.611 -
3.612 - # Or generate each set of scheduled events...
3.613 + start_weekday, number_of_days = month.month_properties()
3.614
3.615 - else:
3.616 - output.append(view.writeWeekSlots(first_day, number_of_days, month, week_end, week_slots))
3.617 -
3.618 - # Process the next week...
3.619 -
3.620 - first_day += 7
3.621 + # The start weekday is the weekday of day number 1.
3.622 + # Find the first day of the week, counting from below zero, if
3.623 + # necessary, in order to land on the first day of the month as
3.624 + # day number 1.
3.625
3.626 - # End of month.
3.627 -
3.628 - output.append(fmt.table(on=0))
3.629 + first_day = 1 - start_weekday
3.630
3.631 - # Or output a summary view...
3.632 -
3.633 - elif mode == "list":
3.634 -
3.635 - # Output a list.
3.636 + while first_day <= number_of_days:
3.637
3.638 - output.append(fmt.listitem(on=1, attr={"class" : "event-listings-month"}))
3.639 - output.append(fmt.div(on=1, attr={"class" : "event-listings-month-heading"}))
3.640 -
3.641 - # Either write a month heading or produce links for navigable
3.642 - # calendars.
3.643 + # Find events in this week and determine how to mark them on the
3.644 + # calendar.
3.645
3.646 - output.append(view.writeMonthHeading(month))
3.647 -
3.648 - output.append(fmt.div(on=0))
3.649 -
3.650 - output.append(fmt.bullet_list(on=1, attr={"class" : "event-month-listings"}))
3.651 -
3.652 - # Show the events in order.
3.653 + week_start = month.as_date(max(first_day, 1))
3.654 + week_end = month.as_date(min(first_day + 6, number_of_days))
3.655
3.656 - for event in getEventsInPeriod(all_shown_events, getCalendarPeriod(month, month)):
3.657 - event_page = event.getPage()
3.658 - event_details = event.getDetails()
3.659 - event_summary = event.getSummary(parent_name)
3.660 -
3.661 - output.append(fmt.listitem(on=1, attr={"class" : "event-listing"}))
3.662 + full_coverage, week_slots = getCoverage(
3.663 + getEventsInPeriod(all_shown_events, getCalendarPeriod(week_start, week_end)))
3.664
3.665 - # Link to the page using the summary.
3.666 + # Output a week, starting with the day numbers.
3.667
3.668 - output.append(fmt.paragraph(on=1))
3.669 - output.append(event_page.linkToPage(request, event_summary))
3.670 - output.append(fmt.paragraph(on=0))
3.671 + output.append(view.writeDayNumbers(first_day, number_of_days, month, full_coverage))
3.672
3.673 - # Start and end dates.
3.674 + # Either generate empty days...
3.675
3.676 - output.append(fmt.paragraph(on=1))
3.677 - output.append(fmt.span(on=1))
3.678 - output.append(fmt.text(str(event_details["start"])))
3.679 - output.append(fmt.span(on=0))
3.680 - output.append(fmt.text(" - "))
3.681 - output.append(fmt.span(on=1))
3.682 - output.append(fmt.text(str(event_details["end"])))
3.683 - output.append(fmt.span(on=0))
3.684 - output.append(fmt.paragraph(on=0))
3.685 + if not week_slots:
3.686 + output.append(view.writeEmptyWeek(first_day, number_of_days))
3.687
3.688 - # Location.
3.689 + # Or generate each set of scheduled events...
3.690
3.691 - if event_details.has_key("location"):
3.692 - output.append(fmt.paragraph(on=1))
3.693 - output.append(formatText(event_details["location"], request, fmt, parser_cls))
3.694 - output.append(fmt.paragraph(on=1))
3.695 -
3.696 - # Topics.
3.697 + else:
3.698 + output.append(view.writeWeekSlots(first_day, number_of_days, month, week_end, week_slots))
3.699
3.700 - if event_details.has_key("topics") or event_details.has_key("categories"):
3.701 - output.append(fmt.bullet_list(on=1, attr={"class" : "event-topics"}))
3.702 + # Process the next week...
3.703
3.704 - for topic in event_details.get("topics") or event_details.get("categories") or []:
3.705 - output.append(fmt.listitem(on=1))
3.706 - output.append(formatText(topic, request, fmt, parser_cls))
3.707 - output.append(fmt.listitem(on=0))
3.708 -
3.709 - output.append(fmt.bullet_list(on=0))
3.710 + first_day += 7
3.711
3.712 - output.append(fmt.listitem(on=0))
3.713 -
3.714 - output.append(fmt.bullet_list(on=0))
3.715 + # End of month.
3.716
3.717 - # Output top-level information.
3.718 -
3.719 - # End of list view output.
3.720 -
3.721 - if mode == "list":
3.722 - output.append(fmt.bullet_list(on=0))
3.723 + output.append(fmt.table(on=0))
3.724
3.725 # Output a day view.
3.726
3.727 @@ -1643,7 +1754,7 @@
3.728
3.729 colspan = sum(map(len, day_slots.values())) * 2 + 2
3.730
3.731 - output.append(view.writeDayHeading(date, colspan))
3.732 + output.append(view.writeDayTableHeading(date, colspan))
3.733
3.734 # Either generate empty days...
3.735