1.1 --- a/EventAggregatorSupport.py Sun Jan 22 00:45:28 2012 +0100
1.2 +++ b/EventAggregatorSupport.py Sun Feb 05 01:29:45 2012 +0100
1.3 @@ -13,7 +13,7 @@
1.4 from MoinSupport import *
1.5
1.6 from MoinMoin.Page import Page
1.7 -from MoinMoin.action import cache
1.8 +from MoinMoin.action import AttachFile, cache
1.9 from MoinMoin import caching
1.10 from MoinMoin import search
1.11 from MoinMoin import wikiutil
1.12 @@ -1362,4 +1362,1851 @@
1.13
1.14 return new_event_page.getBody()
1.15
1.16 +# Colour-related functions.
1.17 +
1.18 +def getColour(s):
1.19 + colour = [0, 0, 0]
1.20 + digit = 0
1.21 + for c in s:
1.22 + colour[digit] += ord(c)
1.23 + colour[digit] = colour[digit] % 256
1.24 + digit += 1
1.25 + digit = digit % 3
1.26 + return tuple(colour)
1.27 +
1.28 +def getBlackOrWhite(colour):
1.29 + if sum(colour) / 3.0 > 127:
1.30 + return (0, 0, 0)
1.31 + else:
1.32 + return (255, 255, 255)
1.33 +
1.34 +# User interface abstractions.
1.35 +
1.36 +class View:
1.37 +
1.38 + "A view of the event calendar."
1.39 +
1.40 + def __init__(self, page, calendar_name, raw_calendar_start, raw_calendar_end,
1.41 + original_calendar_start, original_calendar_end, calendar_start, calendar_end,
1.42 + first, last, category_names, remote_sources, template_name, parent_name, mode,
1.43 + resolution, name_usage, map_name):
1.44 +
1.45 + """
1.46 + Initialise the view with the current 'page', a 'calendar_name' (which
1.47 + may be None), the 'raw_calendar_start' and 'raw_calendar_end' (which
1.48 + are the actual start and end values provided by the request), the
1.49 + calculated 'original_calendar_start' and 'original_calendar_end' (which
1.50 + are the result of calculating the calendar's limits from the raw start
1.51 + and end values), and the requested, calculated 'calendar_start' and
1.52 + 'calendar_end' (which may involve different start and end values due to
1.53 + navigation in the user interface), along with the 'first' and 'last'
1.54 + months of event coverage.
1.55 +
1.56 + The additional 'category_names', 'remote_sources', 'template_name',
1.57 + 'parent_name' and 'mode' parameters are used to configure the links
1.58 + employed by the view.
1.59 +
1.60 + The 'resolution' affects the view for certain modes and is also used to
1.61 + parameterise links.
1.62 +
1.63 + The 'name_usage' parameter controls how names are shown on calendar mode
1.64 + events, such as how often labels are repeated.
1.65 +
1.66 + The 'map_name' parameter provides the name of a map to be used in the
1.67 + map mode.
1.68 + """
1.69 +
1.70 + self.page = page
1.71 + self.calendar_name = calendar_name
1.72 + self.raw_calendar_start = raw_calendar_start
1.73 + self.raw_calendar_end = raw_calendar_end
1.74 + self.original_calendar_start = original_calendar_start
1.75 + self.original_calendar_end = original_calendar_end
1.76 + self.calendar_start = calendar_start
1.77 + self.calendar_end = calendar_end
1.78 + self.template_name = template_name
1.79 + self.parent_name = parent_name
1.80 + self.mode = mode
1.81 + self.resolution = resolution
1.82 + self.name_usage = name_usage
1.83 + self.map_name = map_name
1.84 +
1.85 + self.category_name_parameters = "&".join([("category=%s" % name) for name in category_names])
1.86 + self.remote_source_parameters = "&".join([("source=%s" % source) for source in remote_sources])
1.87 +
1.88 + # Calculate the duration in terms of the highest common unit of time.
1.89 +
1.90 + self.first = first
1.91 + self.last = last
1.92 + self.duration = last - first
1.93 +
1.94 + if self.calendar_name is not None:
1.95 +
1.96 + # Store the view parameters.
1.97 +
1.98 + self.previous_start = first.previous()
1.99 + self.next_start = first.next()
1.100 + self.previous_end = last.previous()
1.101 + self.next_end = last.next()
1.102 +
1.103 + self.previous_set_start = first.update(-self.duration)
1.104 + self.next_set_start = first.update(self.duration)
1.105 + self.previous_set_end = last.update(-self.duration)
1.106 + self.next_set_end = last.update(self.duration)
1.107 +
1.108 + def getIdentifier(self):
1.109 +
1.110 + "Return a unique identifier to be used to refer to this view."
1.111 +
1.112 + # NOTE: Nasty hack to get a unique identifier if no name is given.
1.113 +
1.114 + return self.calendar_name or str(id(self))
1.115 +
1.116 + def getQualifiedParameterName(self, argname):
1.117 +
1.118 + "Return the 'argname' qualified using the calendar name."
1.119 +
1.120 + return getQualifiedParameterName(self.calendar_name, argname)
1.121 +
1.122 + def getDateQueryString(self, argname, date, prefix=1):
1.123 +
1.124 + """
1.125 + Return a query string fragment for the given 'argname', referring to the
1.126 + month given by the specified 'year_month' object, appropriate for this
1.127 + calendar.
1.128 +
1.129 + If 'prefix' is specified and set to a false value, the parameters in the
1.130 + query string will not be calendar-specific, but could be used with the
1.131 + summary action.
1.132 + """
1.133 +
1.134 + suffixes = ["year", "month", "day"]
1.135 +
1.136 + if date is not None:
1.137 + args = []
1.138 + for suffix, value in zip(suffixes, date.as_tuple()):
1.139 + suffixed_argname = "%s-%s" % (argname, suffix)
1.140 + if prefix:
1.141 + suffixed_argname = self.getQualifiedParameterName(suffixed_argname)
1.142 + args.append("%s=%s" % (suffixed_argname, value))
1.143 + return "&".join(args)
1.144 + else:
1.145 + return ""
1.146 +
1.147 + def getRawDateQueryString(self, argname, date, prefix=1):
1.148 +
1.149 + """
1.150 + Return a query string fragment for the given 'argname', referring to the
1.151 + date given by the specified 'date' value, appropriate for this
1.152 + calendar.
1.153 +
1.154 + If 'prefix' is specified and set to a false value, the parameters in the
1.155 + query string will not be calendar-specific, but could be used with the
1.156 + summary action.
1.157 + """
1.158 +
1.159 + if date is not None:
1.160 + if prefix:
1.161 + argname = self.getQualifiedParameterName(argname)
1.162 + return "%s=%s" % (argname, wikiutil.url_quote_plus(date))
1.163 + else:
1.164 + return ""
1.165 +
1.166 + def getNavigationLink(self, start, end, mode=None, resolution=None):
1.167 +
1.168 + """
1.169 + Return a query string fragment for navigation to a view showing months
1.170 + from 'start' to 'end' inclusive, with the optional 'mode' indicating the
1.171 + view style and the optional 'resolution' indicating the resolution of a
1.172 + view, if configurable.
1.173 + """
1.174 +
1.175 + return "%s&%s&%s=%s&%s=%s" % (
1.176 + self.getRawDateQueryString("start", start),
1.177 + self.getRawDateQueryString("end", end),
1.178 + self.getQualifiedParameterName("mode"), mode or self.mode,
1.179 + self.getQualifiedParameterName("resolution"), resolution or self.resolution
1.180 + )
1.181 +
1.182 + def getUpdateLink(self, start, end, mode=None, resolution=None):
1.183 +
1.184 + """
1.185 + Return a query string fragment for navigation to a view showing months
1.186 + from 'start' to 'end' inclusive, with the optional 'mode' indicating the
1.187 + view style and the optional 'resolution' indicating the resolution of a
1.188 + view, if configurable. This link differs from the conventional
1.189 + navigation link in that it is sufficient to activate the update action
1.190 + and produce an updated region of the page without needing to locate and
1.191 + process the page or any macro invocation.
1.192 + """
1.193 +
1.194 + return "calendar=%s&%s&%s&%s=%s&%s=%s" % (
1.195 + self.calendar_name,
1.196 + self.getRawDateQueryString("start", start),
1.197 + self.getRawDateQueryString("end", end),
1.198 + self.getQualifiedParameterName("mode"), mode or self.mode,
1.199 + self.getQualifiedParameterName("resolution"), resolution or self.resolution
1.200 + )
1.201 +
1.202 + def getNewEventLink(self, start):
1.203 +
1.204 + """
1.205 + Return a query string activating the new event form, incorporating the
1.206 + calendar parameters, specialising the form for the given 'start' date or
1.207 + month.
1.208 + """
1.209 +
1.210 + if start is not None:
1.211 + details = start.as_tuple()
1.212 + pairs = zip(["start-year=%d", "start-month=%d", "start-day=%d"], details)
1.213 + args = [(param % value) for (param, value) in pairs]
1.214 + args = "&".join(args)
1.215 + else:
1.216 + args = ""
1.217 +
1.218 + # Prepare navigation details for the calendar shown with the new event
1.219 + # form.
1.220 +
1.221 + navigation_link = self.getNavigationLink(
1.222 + self.calendar_start, self.calendar_end
1.223 + )
1.224 +
1.225 + return "action=EventAggregatorNewEvent&%s&%s&template=%s&parent=%s&%s" % (
1.226 + args, self.category_name_parameters, self.template_name, self.parent_name or "",
1.227 + navigation_link)
1.228 +
1.229 + def getFullDateLabel(self, date):
1.230 + page = self.page
1.231 + request = page.request
1.232 + return getFullDateLabel(request, date)
1.233 +
1.234 + def getFullMonthLabel(self, year_month):
1.235 + page = self.page
1.236 + request = page.request
1.237 + return getFullMonthLabel(request, year_month)
1.238 +
1.239 + def getFullLabel(self, arg):
1.240 + return self.resolution == "date" and self.getFullDateLabel(arg) or self.getFullMonthLabel(arg)
1.241 +
1.242 + def _getCalendarPeriod(self, start_label, end_label, default_label):
1.243 + output = []
1.244 + if start_label:
1.245 + output.append(start_label)
1.246 + if end_label and start_label != end_label:
1.247 + if output:
1.248 + output.append(" - ")
1.249 + output.append(end_label)
1.250 + return "".join(output) or default_label
1.251 +
1.252 + def getCalendarPeriod(self):
1.253 + _ = self.page.request.getText
1.254 + return self._getCalendarPeriod(
1.255 + self.calendar_start and self.getFullLabel(self.calendar_start),
1.256 + self.calendar_end and self.getFullLabel(self.calendar_end),
1.257 + _("All events")
1.258 + )
1.259 +
1.260 + def getOriginalCalendarPeriod(self):
1.261 + _ = self.page.request.getText
1.262 + return self._getCalendarPeriod(
1.263 + self.original_calendar_start and self.getFullLabel(self.original_calendar_start),
1.264 + self.original_calendar_end and self.getFullLabel(self.original_calendar_end),
1.265 + _("All events")
1.266 + )
1.267 +
1.268 + def getRawCalendarPeriod(self):
1.269 + _ = self.page.request.getText
1.270 + return self._getCalendarPeriod(
1.271 + self.raw_calendar_start,
1.272 + self.raw_calendar_end,
1.273 + _("No period specified")
1.274 + )
1.275 +
1.276 + def writeDownloadControls(self):
1.277 +
1.278 + """
1.279 + Return a representation of the download controls, featuring links for
1.280 + view, calendar and customised downloads and subscriptions.
1.281 + """
1.282 +
1.283 + page = self.page
1.284 + request = page.request
1.285 + fmt = page.formatter
1.286 + _ = request.getText
1.287 +
1.288 + output = []
1.289 +
1.290 + # The full URL is needed for webcal links.
1.291 +
1.292 + full_url = "%s%s" % (request.getBaseURL(), getPathInfo(request))
1.293 +
1.294 + # Generate the links.
1.295 +
1.296 + download_dialogue_link = "action=EventAggregatorSummary&parent=%s&resolution=%s&%s&%s" % (
1.297 + self.parent_name or "",
1.298 + self.resolution,
1.299 + self.category_name_parameters,
1.300 + self.remote_source_parameters
1.301 + )
1.302 + download_all_link = download_dialogue_link + "&doit=1"
1.303 + download_link = download_all_link + ("&%s&%s" % (
1.304 + self.getDateQueryString("start", self.calendar_start, prefix=0),
1.305 + self.getDateQueryString("end", self.calendar_end, prefix=0)
1.306 + ))
1.307 +
1.308 + # Subscription links just explicitly select the RSS format.
1.309 +
1.310 + subscribe_dialogue_link = download_dialogue_link + "&format=RSS"
1.311 + subscribe_all_link = download_all_link + "&format=RSS"
1.312 + subscribe_link = download_link + "&format=RSS"
1.313 +
1.314 + # Adjust the "download all" and "subscribe all" links if the calendar
1.315 + # has an inherent period associated with it.
1.316 +
1.317 + period_limits = []
1.318 +
1.319 + if self.raw_calendar_start:
1.320 + period_limits.append("&%s" %
1.321 + self.getRawDateQueryString("start", self.raw_calendar_start, prefix=0)
1.322 + )
1.323 + if self.raw_calendar_end:
1.324 + period_limits.append("&%s" %
1.325 + self.getRawDateQueryString("end", self.raw_calendar_end, prefix=0)
1.326 + )
1.327 +
1.328 + period_limits = "".join(period_limits)
1.329 +
1.330 + download_dialogue_link += period_limits
1.331 + download_all_link += period_limits
1.332 + subscribe_dialogue_link += period_limits
1.333 + subscribe_all_link += period_limits
1.334 +
1.335 + # Pop-up descriptions of the downloadable calendars.
1.336 +
1.337 + calendar_period = self.getCalendarPeriod()
1.338 + original_calendar_period = self.getOriginalCalendarPeriod()
1.339 + raw_calendar_period = self.getRawCalendarPeriod()
1.340 +
1.341 + # Write the controls.
1.342 +
1.343 + # Download controls.
1.344 +
1.345 + output.append(fmt.div(on=1, css_class="event-download-controls"))
1.346 +
1.347 + output.append(fmt.span(on=1, css_class="event-download"))
1.348 + output.append(fmt.text(_("Download...")))
1.349 + output.append(fmt.div(on=1, css_class="event-download-popup"))
1.350 +
1.351 + output.append(fmt.div(on=1, css_class="event-download-item"))
1.352 + output.append(fmt.span(on=1, css_class="event-download-types"))
1.353 + output.append(fmt.span(on=1, css_class="event-download-webcal"))
1.354 + output.append(linkToResource(full_url.replace("http", "webcal", 1), request, _("webcal"), download_link))
1.355 + output.append(fmt.span(on=0))
1.356 + output.append(fmt.span(on=1, css_class="event-download-http"))
1.357 + output.append(linkToPage(request, page, _("http"), download_link))
1.358 + output.append(fmt.span(on=0))
1.359 + output.append(fmt.span(on=0)) # end types
1.360 + output.append(fmt.span(on=1, css_class="event-download-label"))
1.361 + output.append(fmt.text(_("Download this view")))
1.362 + output.append(fmt.span(on=0)) # end label
1.363 + output.append(fmt.span(on=1, css_class="event-download-period"))
1.364 + output.append(fmt.text(calendar_period))
1.365 + output.append(fmt.span(on=0))
1.366 + output.append(fmt.div(on=0))
1.367 +
1.368 + output.append(fmt.div(on=1, css_class="event-download-item"))
1.369 + output.append(fmt.span(on=1, css_class="event-download-types"))
1.370 + output.append(fmt.span(on=1, css_class="event-download-webcal"))
1.371 + output.append(linkToResource(full_url.replace("http", "webcal", 1), request, _("webcal"), download_all_link))
1.372 + output.append(fmt.span(on=0))
1.373 + output.append(fmt.span(on=1, css_class="event-download-http"))
1.374 + output.append(linkToPage(request, page, _("http"), download_all_link))
1.375 + output.append(fmt.span(on=0))
1.376 + output.append(fmt.span(on=0)) # end types
1.377 + output.append(fmt.span(on=1, css_class="event-download-label"))
1.378 + output.append(fmt.text(_("Download this calendar")))
1.379 + output.append(fmt.span(on=0)) # end label
1.380 + output.append(fmt.span(on=1, css_class="event-download-period"))
1.381 + output.append(fmt.text(original_calendar_period))
1.382 + output.append(fmt.span(on=0))
1.383 + output.append(fmt.span(on=1, css_class="event-download-period-raw"))
1.384 + output.append(fmt.text(raw_calendar_period))
1.385 + output.append(fmt.span(on=0))
1.386 + output.append(fmt.div(on=0))
1.387 +
1.388 + output.append(fmt.div(on=1, css_class="event-download-item"))
1.389 + output.append(fmt.span(on=1, css_class="event-download-link"))
1.390 + output.append(linkToPage(request, page, _("Edit download options..."), download_dialogue_link))
1.391 + output.append(fmt.span(on=0)) # end label
1.392 + output.append(fmt.div(on=0))
1.393 +
1.394 + output.append(fmt.div(on=0)) # end of pop-up
1.395 + output.append(fmt.span(on=0)) # end of download
1.396 +
1.397 + # Subscription controls.
1.398 +
1.399 + output.append(fmt.span(on=1, css_class="event-download"))
1.400 + output.append(fmt.text(_("Subscribe...")))
1.401 + output.append(fmt.div(on=1, css_class="event-download-popup"))
1.402 +
1.403 + output.append(fmt.div(on=1, css_class="event-download-item"))
1.404 + output.append(fmt.span(on=1, css_class="event-download-label"))
1.405 + output.append(linkToPage(request, page, _("Subscribe to this view"), subscribe_link))
1.406 + output.append(fmt.span(on=0)) # end label
1.407 + output.append(fmt.span(on=1, css_class="event-download-period"))
1.408 + output.append(fmt.text(calendar_period))
1.409 + output.append(fmt.span(on=0))
1.410 + output.append(fmt.div(on=0))
1.411 +
1.412 + output.append(fmt.div(on=1, css_class="event-download-item"))
1.413 + output.append(fmt.span(on=1, css_class="event-download-label"))
1.414 + output.append(linkToPage(request, page, _("Subscribe to this calendar"), subscribe_all_link))
1.415 + output.append(fmt.span(on=0)) # end label
1.416 + output.append(fmt.span(on=1, css_class="event-download-period"))
1.417 + output.append(fmt.text(original_calendar_period))
1.418 + output.append(fmt.span(on=0))
1.419 + output.append(fmt.span(on=1, css_class="event-download-period-raw"))
1.420 + output.append(fmt.text(raw_calendar_period))
1.421 + output.append(fmt.span(on=0))
1.422 + output.append(fmt.div(on=0))
1.423 +
1.424 + output.append(fmt.div(on=1, css_class="event-download-item"))
1.425 + output.append(fmt.span(on=1, css_class="event-download-link"))
1.426 + output.append(linkToPage(request, page, _("Edit subscription options..."), subscribe_dialogue_link))
1.427 + output.append(fmt.span(on=0)) # end label
1.428 + output.append(fmt.div(on=0))
1.429 +
1.430 + output.append(fmt.div(on=0)) # end of pop-up
1.431 + output.append(fmt.span(on=0)) # end of download
1.432 +
1.433 + output.append(fmt.div(on=0)) # end of controls
1.434 +
1.435 + return "".join(output)
1.436 +
1.437 + def writeViewControls(self):
1.438 +
1.439 + """
1.440 + Return a representation of the view mode controls, permitting viewing of
1.441 + aggregated events in calendar, list or table form.
1.442 + """
1.443 +
1.444 + page = self.page
1.445 + request = page.request
1.446 + fmt = page.formatter
1.447 + _ = request.getText
1.448 +
1.449 + output = []
1.450 +
1.451 + start = self.calendar_start
1.452 + end = self.calendar_end
1.453 +
1.454 + help_page = Page(request, "HelpOnEventAggregator")
1.455 + calendar_link = self.getNavigationLink(start and start.as_month(), end and end.as_month(), "calendar", "month")
1.456 + list_link = self.getNavigationLink(start, end, "list")
1.457 + table_link = self.getNavigationLink(start, end, "table")
1.458 + map_link = self.getNavigationLink(start, end, "map")
1.459 + new_event_link = self.getNewEventLink(start)
1.460 +
1.461 + # Write the controls.
1.462 +
1.463 + output.append(fmt.div(on=1, css_class="event-view-controls"))
1.464 +
1.465 + output.append(fmt.span(on=1, css_class="event-view"))
1.466 + output.append(linkToPage(request, help_page, _("Help")))
1.467 + output.append(fmt.span(on=0))
1.468 +
1.469 + output.append(fmt.span(on=1, css_class="event-view"))
1.470 + output.append(linkToPage(request, page, _("New event"), new_event_link))
1.471 + output.append(fmt.span(on=0))
1.472 +
1.473 + if self.mode != "calendar":
1.474 + output.append(fmt.span(on=1, css_class="event-view"))
1.475 + output.append(linkToPage(request, page, _("View as calendar"), calendar_link))
1.476 + output.append(fmt.span(on=0))
1.477 +
1.478 + if self.mode != "list":
1.479 + output.append(fmt.span(on=1, css_class="event-view"))
1.480 + output.append(linkToPage(request, page, _("View as list"), list_link))
1.481 + output.append(fmt.span(on=0))
1.482 +
1.483 + if self.mode != "table":
1.484 + output.append(fmt.span(on=1, css_class="event-view"))
1.485 + output.append(linkToPage(request, page, _("View as table"), table_link))
1.486 + output.append(fmt.span(on=0))
1.487 +
1.488 + if self.mode != "map" and self.map_name is not None:
1.489 + output.append(fmt.span(on=1, css_class="event-view"))
1.490 + output.append(linkToPage(request, page, _("View as map"), map_link))
1.491 + output.append(fmt.span(on=0))
1.492 +
1.493 + output.append(fmt.div(on=0))
1.494 +
1.495 + return "".join(output)
1.496 +
1.497 + def writeMapHeading(self):
1.498 +
1.499 + """
1.500 + Return the calendar heading for the current calendar, providing links
1.501 + permitting navigation to other periods.
1.502 + """
1.503 +
1.504 + label = self.getCalendarPeriod()
1.505 +
1.506 + if self.raw_calendar_start is None or self.raw_calendar_end is None:
1.507 + fmt = self.page.formatter
1.508 + output = []
1.509 + output.append(fmt.span(on=1))
1.510 + output.append(fmt.text(label))
1.511 + output.append(fmt.span(on=0))
1.512 + return "".join(output)
1.513 + else:
1.514 + return self._writeCalendarHeading(label, self.calendar_start, self.calendar_end)
1.515 +
1.516 + def writeDateHeading(self, date):
1.517 + if isinstance(date, Date):
1.518 + return self.writeDayHeading(date)
1.519 + else:
1.520 + return self.writeMonthHeading(date)
1.521 +
1.522 + def writeMonthHeading(self, year_month):
1.523 +
1.524 + """
1.525 + Return the calendar heading for the given 'year_month' (a Month object)
1.526 + providing links permitting navigation to other months.
1.527 + """
1.528 +
1.529 + full_month_label = self.getFullMonthLabel(year_month)
1.530 + end_month = year_month.update(self.duration - 1)
1.531 + return self._writeCalendarHeading(full_month_label, year_month, end_month)
1.532 +
1.533 + def writeDayHeading(self, date):
1.534 +
1.535 + """
1.536 + Return the calendar heading for the given 'date' (a Date object)
1.537 + providing links permitting navigation to other dates.
1.538 + """
1.539 +
1.540 + full_date_label = self.getFullDateLabel(date)
1.541 + end_date = date.update(self.duration - 1)
1.542 + return self._writeCalendarHeading(full_date_label, date, end_date)
1.543 +
1.544 + def _writeCalendarHeading(self, label, start, end):
1.545 +
1.546 + """
1.547 + Write a calendar heading providing links permitting navigation to other
1.548 + periods, using the given 'label' along with the 'start' and 'end' dates
1.549 + to provide a link to a particular period.
1.550 + """
1.551 +
1.552 + page = self.page
1.553 + request = page.request
1.554 + fmt = page.formatter
1.555 + _ = request.getText
1.556 +
1.557 + output = []
1.558 +
1.559 + # Prepare navigation links.
1.560 +
1.561 + if self.calendar_name is not None:
1.562 + calendar_name = self.calendar_name
1.563 +
1.564 + # Links to the previous set of months and to a calendar shifted
1.565 + # back one month.
1.566 +
1.567 + previous_set_link = self.getNavigationLink(
1.568 + self.previous_set_start, self.previous_set_end
1.569 + )
1.570 + previous_link = self.getNavigationLink(
1.571 + self.previous_start, self.previous_end
1.572 + )
1.573 +
1.574 + # Links to the next set of months and to a calendar shifted
1.575 + # forward one month.
1.576 +
1.577 + next_set_link = self.getNavigationLink(
1.578 + self.next_set_start, self.next_set_end
1.579 + )
1.580 + next_link = self.getNavigationLink(
1.581 + self.next_start, self.next_end
1.582 + )
1.583 +
1.584 + # A link leading to this date being at the top of the calendar.
1.585 +
1.586 + date_link = self.getNavigationLink(start, end)
1.587 +
1.588 + output.append(fmt.span(on=1, css_class="previous"))
1.589 + output.append(linkToPage(request, page, "<<", previous_set_link))
1.590 + output.append(fmt.text(" "))
1.591 + output.append(linkToPage(request, page, "<", previous_link))
1.592 + output.append(fmt.span(on=0))
1.593 +
1.594 + output.append(fmt.span(on=1, css_class="next"))
1.595 + output.append(linkToPage(request, page, ">", next_link))
1.596 + output.append(fmt.text(" "))
1.597 + output.append(linkToPage(request, page, ">>", next_set_link))
1.598 + output.append(fmt.span(on=0))
1.599 +
1.600 + output.append(linkToPage(request, page, label, date_link))
1.601 +
1.602 + else:
1.603 + output.append(fmt.span(on=1))
1.604 + output.append(fmt.text(label))
1.605 + output.append(fmt.span(on=0))
1.606 +
1.607 + return "".join(output)
1.608 +
1.609 + def writeDayNumberHeading(self, date, busy):
1.610 +
1.611 + """
1.612 + Return a link for the given 'date' which will activate the new event
1.613 + action for the given day. If 'busy' is given as a true value, the
1.614 + heading will be marked as busy.
1.615 + """
1.616 +
1.617 + page = self.page
1.618 + request = page.request
1.619 + fmt = page.formatter
1.620 + _ = request.getText
1.621 +
1.622 + output = []
1.623 +
1.624 + year, month, day = date.as_tuple()
1.625 + new_event_link = self.getNewEventLink(date)
1.626 +
1.627 + # Prepare a link to the day view for this day.
1.628 +
1.629 + day_view_link = self.getNavigationLink(date, date, "day", "date")
1.630 +
1.631 + # Output the heading class.
1.632 +
1.633 + output.append(
1.634 + fmt.table_cell(on=1, attrs={
1.635 + "class" : "event-day-heading event-day-%s" % (busy and "busy" or "empty"),
1.636 + "colspan" : "3"
1.637 + }))
1.638 +
1.639 + # Output the number and pop-up menu.
1.640 +
1.641 + output.append(fmt.div(on=1, css_class="event-day-box"))
1.642 +
1.643 + output.append(fmt.span(on=1, css_class="event-day-number-popup"))
1.644 + output.append(fmt.span(on=1, css_class="event-day-number-link"))
1.645 + output.append(linkToPage(request, page, _("View day"), day_view_link))
1.646 + output.append(fmt.span(on=0))
1.647 + output.append(fmt.span(on=1, css_class="event-day-number-link"))
1.648 + output.append(linkToPage(request, page, _("New event"), new_event_link))
1.649 + output.append(fmt.span(on=0))
1.650 + output.append(fmt.span(on=0))
1.651 +
1.652 + output.append(fmt.span(on=1, css_class="event-day-number"))
1.653 + output.append(fmt.text(unicode(day)))
1.654 + output.append(fmt.span(on=0))
1.655 +
1.656 + output.append(fmt.div(on=0))
1.657 +
1.658 + # End of heading.
1.659 +
1.660 + output.append(fmt.table_cell(on=0))
1.661 +
1.662 + return "".join(output)
1.663 +
1.664 + # Common layout methods.
1.665 +
1.666 + def getEventStyle(self, colour_seed):
1.667 +
1.668 + "Generate colour style information using the given 'colour_seed'."
1.669 +
1.670 + bg = getColour(colour_seed)
1.671 + fg = getBlackOrWhite(bg)
1.672 + return "background-color: rgb(%d, %d, %d); color: rgb(%d, %d, %d);" % (bg + fg)
1.673 +
1.674 + def writeEventSummaryBox(self, event):
1.675 +
1.676 + "Return an event summary box linking to the given 'event'."
1.677 +
1.678 + page = self.page
1.679 + request = page.request
1.680 + fmt = page.formatter
1.681 +
1.682 + output = []
1.683 +
1.684 + event_details = event.getDetails()
1.685 + event_summary = event.getSummary(self.parent_name)
1.686 +
1.687 + is_ambiguous = event.as_timespan().ambiguous()
1.688 + style = self.getEventStyle(event_summary)
1.689 +
1.690 + # The event box contains the summary, alongside
1.691 + # other elements.
1.692 +
1.693 + output.append(fmt.div(on=1, css_class="event-summary-box"))
1.694 + output.append(fmt.div(on=1, css_class="event-summary", style=style))
1.695 +
1.696 + if is_ambiguous:
1.697 + output.append(fmt.icon("/!\\"))
1.698 +
1.699 + output.append(event.linkToEvent(request, event_summary))
1.700 + output.append(fmt.div(on=0))
1.701 +
1.702 + # Add a pop-up element for long summaries.
1.703 +
1.704 + output.append(fmt.div(on=1, css_class="event-summary-popup", style=style))
1.705 +
1.706 + if is_ambiguous:
1.707 + output.append(fmt.icon("/!\\"))
1.708 +
1.709 + output.append(event.linkToEvent(request, event_summary))
1.710 + output.append(fmt.div(on=0))
1.711 +
1.712 + output.append(fmt.div(on=0))
1.713 +
1.714 + return "".join(output)
1.715 +
1.716 + # Calendar layout methods.
1.717 +
1.718 + def writeMonthTableHeading(self, year_month):
1.719 + page = self.page
1.720 + fmt = page.formatter
1.721 +
1.722 + output = []
1.723 + output.append(fmt.table_row(on=1))
1.724 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-month-heading", "colspan" : "21"}))
1.725 +
1.726 + output.append(self.writeMonthHeading(year_month))
1.727 +
1.728 + output.append(fmt.table_cell(on=0))
1.729 + output.append(fmt.table_row(on=0))
1.730 +
1.731 + return "".join(output)
1.732 +
1.733 + def writeWeekdayHeadings(self):
1.734 + page = self.page
1.735 + request = page.request
1.736 + fmt = page.formatter
1.737 + _ = request.getText
1.738 +
1.739 + output = []
1.740 + output.append(fmt.table_row(on=1))
1.741 +
1.742 + for weekday in range(0, 7):
1.743 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-weekday-heading", "colspan" : "3"}))
1.744 + output.append(fmt.text(_(getDayLabel(weekday))))
1.745 + output.append(fmt.table_cell(on=0))
1.746 +
1.747 + output.append(fmt.table_row(on=0))
1.748 + return "".join(output)
1.749 +
1.750 + def writeDayNumbers(self, first_day, number_of_days, month, coverage):
1.751 + page = self.page
1.752 + fmt = page.formatter
1.753 +
1.754 + output = []
1.755 + output.append(fmt.table_row(on=1))
1.756 +
1.757 + for weekday in range(0, 7):
1.758 + day = first_day + weekday
1.759 + date = month.as_date(day)
1.760 +
1.761 + # Output out-of-month days.
1.762 +
1.763 + if day < 1 or day > number_of_days:
1.764 + output.append(fmt.table_cell(on=1,
1.765 + attrs={"class" : "event-day-heading event-day-excluded", "colspan" : "3"}))
1.766 + output.append(fmt.table_cell(on=0))
1.767 +
1.768 + # Output normal days.
1.769 +
1.770 + else:
1.771 + # Output the day heading, making a link to a new event
1.772 + # action.
1.773 +
1.774 + output.append(self.writeDayNumberHeading(date, date in coverage))
1.775 +
1.776 + # End of day numbers.
1.777 +
1.778 + output.append(fmt.table_row(on=0))
1.779 + return "".join(output)
1.780 +
1.781 + def writeEmptyWeek(self, first_day, number_of_days):
1.782 + page = self.page
1.783 + fmt = page.formatter
1.784 +
1.785 + output = []
1.786 + output.append(fmt.table_row(on=1))
1.787 +
1.788 + for weekday in range(0, 7):
1.789 + day = first_day + weekday
1.790 +
1.791 + # Output out-of-month days.
1.792 +
1.793 + if day < 1 or day > number_of_days:
1.794 + output.append(fmt.table_cell(on=1,
1.795 + attrs={"class" : "event-day-content event-day-excluded", "colspan" : "3"}))
1.796 + output.append(fmt.table_cell(on=0))
1.797 +
1.798 + # Output empty days.
1.799 +
1.800 + else:
1.801 + output.append(fmt.table_cell(on=1,
1.802 + attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"}))
1.803 +
1.804 + output.append(fmt.table_row(on=0))
1.805 + return "".join(output)
1.806 +
1.807 + def writeWeekSlots(self, first_day, number_of_days, month, week_end, week_slots):
1.808 + output = []
1.809 +
1.810 + locations = week_slots.keys()
1.811 + locations.sort(sort_none_first)
1.812 +
1.813 + # Visit each slot corresponding to a location (or no location).
1.814 +
1.815 + for location in locations:
1.816 +
1.817 + # Visit each coverage span, presenting the events in the span.
1.818 +
1.819 + for events in week_slots[location]:
1.820 +
1.821 + # Output each set.
1.822 +
1.823 + output.append(self.writeWeekSlot(first_day, number_of_days, month, week_end, events))
1.824 +
1.825 + # Add a spacer.
1.826 +
1.827 + output.append(self.writeWeekSpacer(first_day, number_of_days))
1.828 +
1.829 + return "".join(output)
1.830 +
1.831 + def writeWeekSlot(self, first_day, number_of_days, month, week_end, events):
1.832 + page = self.page
1.833 + request = page.request
1.834 + fmt = page.formatter
1.835 +
1.836 + output = []
1.837 + output.append(fmt.table_row(on=1))
1.838 +
1.839 + # Then, output day details.
1.840 +
1.841 + for weekday in range(0, 7):
1.842 + day = first_day + weekday
1.843 + date = month.as_date(day)
1.844 +
1.845 + # Skip out-of-month days.
1.846 +
1.847 + if day < 1 or day > number_of_days:
1.848 + output.append(fmt.table_cell(on=1,
1.849 + attrs={"class" : "event-day-content event-day-excluded", "colspan" : "3"}))
1.850 + output.append(fmt.table_cell(on=0))
1.851 + continue
1.852 +
1.853 + # Output the day.
1.854 +
1.855 + if date not in events:
1.856 + output.append(fmt.table_cell(on=1,
1.857 + attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"}))
1.858 +
1.859 + # Get event details for the current day.
1.860 +
1.861 + for event in events:
1.862 + event_details = event.getDetails()
1.863 +
1.864 + if date not in event:
1.865 + continue
1.866 +
1.867 + # Get basic properties of the event.
1.868 +
1.869 + starts_today = event_details["start"] == date
1.870 + ends_today = event_details["end"] == date
1.871 + event_summary = event.getSummary(self.parent_name)
1.872 +
1.873 + style = self.getEventStyle(event_summary)
1.874 +
1.875 + # Determine if the event name should be shown.
1.876 +
1.877 + start_of_period = starts_today or weekday == 0 or day == 1
1.878 +
1.879 + if self.name_usage == "daily" or start_of_period:
1.880 + hide_text = 0
1.881 + else:
1.882 + hide_text = 1
1.883 +
1.884 + # Output start of day gap and determine whether
1.885 + # any event content should be explicitly output
1.886 + # for this day.
1.887 +
1.888 + if starts_today:
1.889 +
1.890 + # Single day events...
1.891 +
1.892 + if ends_today:
1.893 + colspan = 3
1.894 + event_day_type = "event-day-single"
1.895 +
1.896 + # Events starting today...
1.897 +
1.898 + else:
1.899 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-start-gap"}))
1.900 + output.append(fmt.table_cell(on=0))
1.901 +
1.902 + # Calculate the span of this cell.
1.903 + # Events whose names appear on every day...
1.904 +
1.905 + if self.name_usage == "daily":
1.906 + colspan = 2
1.907 + event_day_type = "event-day-starting"
1.908 +
1.909 + # Events whose names appear once per week...
1.910 +
1.911 + else:
1.912 + if event_details["end"] <= week_end:
1.913 + event_length = event_details["end"].day() - day + 1
1.914 + colspan = (event_length - 2) * 3 + 4
1.915 + else:
1.916 + event_length = week_end.day() - day + 1
1.917 + colspan = (event_length - 1) * 3 + 2
1.918 +
1.919 + event_day_type = "event-day-multiple"
1.920 +
1.921 + # Events continuing from a previous week...
1.922 +
1.923 + elif start_of_period:
1.924 +
1.925 + # End of continuing event...
1.926 +
1.927 + if ends_today:
1.928 + colspan = 2
1.929 + event_day_type = "event-day-ending"
1.930 +
1.931 + # Events continuing for at least one more day...
1.932 +
1.933 + else:
1.934 +
1.935 + # Calculate the span of this cell.
1.936 + # Events whose names appear on every day...
1.937 +
1.938 + if self.name_usage == "daily":
1.939 + colspan = 3
1.940 + event_day_type = "event-day-full"
1.941 +
1.942 + # Events whose names appear once per week...
1.943 +
1.944 + else:
1.945 + if event_details["end"] <= week_end:
1.946 + event_length = event_details["end"].day() - day + 1
1.947 + colspan = (event_length - 1) * 3 + 2
1.948 + else:
1.949 + event_length = week_end.day() - day + 1
1.950 + colspan = event_length * 3
1.951 +
1.952 + event_day_type = "event-day-multiple"
1.953 +
1.954 + # Continuing events whose names appear on every day...
1.955 +
1.956 + elif self.name_usage == "daily":
1.957 + if ends_today:
1.958 + colspan = 2
1.959 + event_day_type = "event-day-ending"
1.960 + else:
1.961 + colspan = 3
1.962 + event_day_type = "event-day-full"
1.963 +
1.964 + # Continuing events whose names appear once per week...
1.965 +
1.966 + else:
1.967 + colspan = None
1.968 +
1.969 + # Output the main content only if it is not
1.970 + # continuing from a previous day.
1.971 +
1.972 + if colspan is not None:
1.973 +
1.974 + # Colour the cell for continuing events.
1.975 +
1.976 + attrs={
1.977 + "class" : "event-day-content event-day-busy %s" % event_day_type,
1.978 + "colspan" : str(colspan)
1.979 + }
1.980 +
1.981 + if not (starts_today and ends_today):
1.982 + attrs["style"] = style
1.983 +
1.984 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.985 +
1.986 + # Output the event.
1.987 +
1.988 + if starts_today and ends_today or not hide_text:
1.989 + output.append(self.writeEventSummaryBox(event))
1.990 +
1.991 + output.append(fmt.table_cell(on=0))
1.992 +
1.993 + # Output end of day gap.
1.994 +
1.995 + if ends_today and not starts_today:
1.996 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-end-gap"}))
1.997 + output.append(fmt.table_cell(on=0))
1.998 +
1.999 + # End of set.
1.1000 +
1.1001 + output.append(fmt.table_row(on=0))
1.1002 + return "".join(output)
1.1003 +
1.1004 + def writeWeekSpacer(self, first_day, number_of_days):
1.1005 + page = self.page
1.1006 + fmt = page.formatter
1.1007 +
1.1008 + output = []
1.1009 + output.append(fmt.table_row(on=1))
1.1010 +
1.1011 + for weekday in range(0, 7):
1.1012 + day = first_day + weekday
1.1013 + css_classes = "event-day-spacer"
1.1014 +
1.1015 + # Skip out-of-month days.
1.1016 +
1.1017 + if day < 1 or day > number_of_days:
1.1018 + css_classes += " event-day-excluded"
1.1019 +
1.1020 + output.append(fmt.table_cell(on=1, attrs={"class" : css_classes, "colspan" : "3"}))
1.1021 + output.append(fmt.table_cell(on=0))
1.1022 +
1.1023 + output.append(fmt.table_row(on=0))
1.1024 + return "".join(output)
1.1025 +
1.1026 + # Day layout methods.
1.1027 +
1.1028 + def writeDayTableHeading(self, date, colspan=1):
1.1029 + page = self.page
1.1030 + fmt = page.formatter
1.1031 +
1.1032 + output = []
1.1033 + output.append(fmt.table_row(on=1))
1.1034 +
1.1035 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-full-day-heading", "colspan" : str(colspan)}))
1.1036 + output.append(self.writeDayHeading(date))
1.1037 + output.append(fmt.table_cell(on=0))
1.1038 +
1.1039 + output.append(fmt.table_row(on=0))
1.1040 + return "".join(output)
1.1041 +
1.1042 + def writeEmptyDay(self, date):
1.1043 + page = self.page
1.1044 + fmt = page.formatter
1.1045 +
1.1046 + output = []
1.1047 + output.append(fmt.table_row(on=1))
1.1048 +
1.1049 + output.append(fmt.table_cell(on=1,
1.1050 + attrs={"class" : "event-day-content event-day-empty"}))
1.1051 +
1.1052 + output.append(fmt.table_row(on=0))
1.1053 + return "".join(output)
1.1054 +
1.1055 + def writeDaySlots(self, date, full_coverage, day_slots):
1.1056 +
1.1057 + """
1.1058 + Given a 'date', non-empty 'full_coverage' for the day concerned, and a
1.1059 + non-empty mapping of 'day_slots' (from locations to event collections),
1.1060 + output the day slots for the day.
1.1061 + """
1.1062 +
1.1063 + page = self.page
1.1064 + fmt = page.formatter
1.1065 +
1.1066 + output = []
1.1067 +
1.1068 + locations = day_slots.keys()
1.1069 + locations.sort(sort_none_first)
1.1070 +
1.1071 + # Traverse the time scale of the full coverage, visiting each slot to
1.1072 + # determine whether it provides content for each period.
1.1073 +
1.1074 + scale = getCoverageScale(full_coverage)
1.1075 +
1.1076 + # Define a mapping of events to rowspans.
1.1077 +
1.1078 + rowspans = {}
1.1079 +
1.1080 + # Populate each period with event details, recording how many periods
1.1081 + # each event populates.
1.1082 +
1.1083 + day_rows = []
1.1084 +
1.1085 + for period in scale:
1.1086 +
1.1087 + # Ignore timespans before this day.
1.1088 +
1.1089 + if period != date:
1.1090 + continue
1.1091 +
1.1092 + # Visit each slot corresponding to a location (or no location).
1.1093 +
1.1094 + day_row = []
1.1095 +
1.1096 + for location in locations:
1.1097 +
1.1098 + # Visit each coverage span, presenting the events in the span.
1.1099 +
1.1100 + for events in day_slots[location]:
1.1101 + event = self.getActiveEvent(period, events)
1.1102 + if event is not None:
1.1103 + if not rowspans.has_key(event):
1.1104 + rowspans[event] = 1
1.1105 + else:
1.1106 + rowspans[event] += 1
1.1107 + day_row.append((location, event))
1.1108 +
1.1109 + day_rows.append((period, day_row))
1.1110 +
1.1111 + # Output the locations.
1.1112 +
1.1113 + output.append(fmt.table_row(on=1))
1.1114 +
1.1115 + # Add a spacer.
1.1116 +
1.1117 + output.append(self.writeDaySpacer(colspan=2, cls="location"))
1.1118 +
1.1119 + for location in locations:
1.1120 +
1.1121 + # Add spacers to the column spans.
1.1122 +
1.1123 + columns = len(day_slots[location]) * 2 - 1
1.1124 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-location-heading", "colspan" : str(columns)}))
1.1125 + output.append(fmt.text(location or ""))
1.1126 + output.append(fmt.table_cell(on=0))
1.1127 +
1.1128 + # Add a trailing spacer.
1.1129 +
1.1130 + output.append(self.writeDaySpacer(cls="location"))
1.1131 +
1.1132 + output.append(fmt.table_row(on=0))
1.1133 +
1.1134 + # Output the periods with event details.
1.1135 +
1.1136 + period = None
1.1137 + events_written = set()
1.1138 +
1.1139 + for period, day_row in day_rows:
1.1140 +
1.1141 + # Write an empty heading for the start of the day where the first
1.1142 + # applicable timespan starts before this day.
1.1143 +
1.1144 + if period.start < date:
1.1145 + output.append(fmt.table_row(on=1))
1.1146 + output.append(self.writeDayScaleHeading(""))
1.1147 +
1.1148 + # Otherwise, write a heading describing the time.
1.1149 +
1.1150 + else:
1.1151 + output.append(fmt.table_row(on=1))
1.1152 + output.append(self.writeDayScaleHeading(period.start.time_string()))
1.1153 +
1.1154 + output.append(self.writeDaySpacer())
1.1155 +
1.1156 + # Visit each slot corresponding to a location (or no location).
1.1157 +
1.1158 + for location, event in day_row:
1.1159 +
1.1160 + # Output each location slot's contribution.
1.1161 +
1.1162 + if event is None or event not in events_written:
1.1163 + output.append(self.writeDaySlot(period, event, event is None and 1 or rowspans[event]))
1.1164 + if event is not None:
1.1165 + events_written.add(event)
1.1166 +
1.1167 + # Add a trailing spacer.
1.1168 +
1.1169 + output.append(self.writeDaySpacer())
1.1170 +
1.1171 + output.append(fmt.table_row(on=0))
1.1172 +
1.1173 + # Write a final time heading if the last period ends in the current day.
1.1174 +
1.1175 + if period is not None:
1.1176 + if period.end == date:
1.1177 + output.append(fmt.table_row(on=1))
1.1178 + output.append(self.writeDayScaleHeading(period.end.time_string()))
1.1179 +
1.1180 + for slot in day_row:
1.1181 + output.append(self.writeDaySpacer())
1.1182 + output.append(self.writeEmptyDaySlot())
1.1183 +
1.1184 + output.append(fmt.table_row(on=0))
1.1185 +
1.1186 + return "".join(output)
1.1187 +
1.1188 + def writeDayScaleHeading(self, heading):
1.1189 + page = self.page
1.1190 + fmt = page.formatter
1.1191 +
1.1192 + output = []
1.1193 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-scale-heading"}))
1.1194 + output.append(fmt.text(heading))
1.1195 + output.append(fmt.table_cell(on=0))
1.1196 +
1.1197 + return "".join(output)
1.1198 +
1.1199 + def getActiveEvent(self, period, events):
1.1200 + for event in events:
1.1201 + if period not in event:
1.1202 + continue
1.1203 + return event
1.1204 + else:
1.1205 + return None
1.1206 +
1.1207 + def writeDaySlot(self, period, event, rowspan):
1.1208 + page = self.page
1.1209 + fmt = page.formatter
1.1210 +
1.1211 + output = []
1.1212 +
1.1213 + if event is not None:
1.1214 + event_summary = event.getSummary(self.parent_name)
1.1215 + style = self.getEventStyle(event_summary)
1.1216 +
1.1217 + output.append(fmt.table_cell(on=1, attrs={
1.1218 + "class" : "event-timespan-content event-timespan-busy",
1.1219 + "style" : style,
1.1220 + "rowspan" : str(rowspan)
1.1221 + }))
1.1222 + output.append(self.writeEventSummaryBox(event))
1.1223 + output.append(fmt.table_cell(on=0))
1.1224 + else:
1.1225 + output.append(self.writeEmptyDaySlot())
1.1226 +
1.1227 + return "".join(output)
1.1228 +
1.1229 + def writeEmptyDaySlot(self):
1.1230 + page = self.page
1.1231 + fmt = page.formatter
1.1232 +
1.1233 + output = []
1.1234 +
1.1235 + output.append(fmt.table_cell(on=1,
1.1236 + attrs={"class" : "event-timespan-content event-timespan-empty"}))
1.1237 + output.append(fmt.table_cell(on=0))
1.1238 +
1.1239 + return "".join(output)
1.1240 +
1.1241 + def writeDaySpacer(self, colspan=1, cls="timespan"):
1.1242 + page = self.page
1.1243 + fmt = page.formatter
1.1244 +
1.1245 + output = []
1.1246 + output.append(fmt.table_cell(on=1, attrs={
1.1247 + "class" : "event-%s-spacer" % cls,
1.1248 + "colspan" : str(colspan)}))
1.1249 + output.append(fmt.table_cell(on=0))
1.1250 + return "".join(output)
1.1251 +
1.1252 + # Map layout methods.
1.1253 +
1.1254 + def writeMapTableHeading(self):
1.1255 + page = self.page
1.1256 + fmt = page.formatter
1.1257 +
1.1258 + output = []
1.1259 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-map-heading"}))
1.1260 + output.append(self.writeMapHeading())
1.1261 + output.append(fmt.table_cell(on=0))
1.1262 +
1.1263 + return "".join(output)
1.1264 +
1.1265 + def showDictError(self, text, pagename):
1.1266 + page = self.page
1.1267 + fmt = page.formatter
1.1268 + request = page.request
1.1269 +
1.1270 + output = []
1.1271 +
1.1272 + output.append(fmt.div(on=1, attrs={"class" : "event-aggregator-error"}))
1.1273 + output.append(fmt.paragraph(on=1))
1.1274 + output.append(fmt.text(text))
1.1275 + output.append(fmt.paragraph(on=0))
1.1276 + output.append(fmt.paragraph(on=1))
1.1277 + output.append(linkToPage(request, Page(request, pagename), pagename))
1.1278 + output.append(fmt.paragraph(on=0))
1.1279 +
1.1280 + return "".join(output)
1.1281 +
1.1282 + def writeMapEventSummaries(self, events):
1.1283 + page = self.page
1.1284 + fmt = page.formatter
1.1285 + request = page.request
1.1286 +
1.1287 + # Sort the events by date.
1.1288 +
1.1289 + events.sort(sort_start_first)
1.1290 +
1.1291 + # Write out a self-contained list of events.
1.1292 +
1.1293 + output = []
1.1294 + output.append(fmt.bullet_list(on=1, attr={"class" : "event-map-location-events"}))
1.1295 +
1.1296 + for event in events:
1.1297 +
1.1298 + # Get the event details.
1.1299 +
1.1300 + event_summary = event.getSummary(self.parent_name)
1.1301 + start, end = event.as_limits()
1.1302 + event_period = self._getCalendarPeriod(
1.1303 + start and self.getFullDateLabel(start),
1.1304 + end and self.getFullDateLabel(end),
1.1305 + "")
1.1306 +
1.1307 + output.append(fmt.listitem(on=1))
1.1308 +
1.1309 + # Link to the page using the summary.
1.1310 +
1.1311 + output.append(event.linkToEvent(request, event_summary))
1.1312 +
1.1313 + # Add the event period.
1.1314 +
1.1315 + output.append(fmt.text(" "))
1.1316 + output.append(fmt.span(on=1, css_class="event-map-period"))
1.1317 + output.append(fmt.text(event_period))
1.1318 + output.append(fmt.span(on=0))
1.1319 +
1.1320 + output.append(fmt.listitem(on=0))
1.1321 +
1.1322 + output.append(fmt.bullet_list(on=0))
1.1323 +
1.1324 + return "".join(output)
1.1325 +
1.1326 + def render(self, all_shown_events):
1.1327 +
1.1328 + """
1.1329 + Render the view, returning the rendered representation as a string.
1.1330 + The view will show a list of 'all_shown_events'.
1.1331 + """
1.1332 +
1.1333 + page = self.page
1.1334 + fmt = page.formatter
1.1335 + request = page.request
1.1336 + _ = request.getText
1.1337 +
1.1338 + # Make a calendar.
1.1339 +
1.1340 + output = []
1.1341 +
1.1342 + output.append(fmt.div(on=1, css_class="event-calendar"))
1.1343 +
1.1344 + # Output download controls.
1.1345 +
1.1346 + output.append(fmt.div(on=1, css_class="event-controls"))
1.1347 + output.append(self.writeDownloadControls())
1.1348 + output.append(fmt.div(on=0))
1.1349 +
1.1350 + # Output a table.
1.1351 +
1.1352 + if self.mode == "table":
1.1353 +
1.1354 + # Start of table view output.
1.1355 +
1.1356 + output.append(fmt.table(on=1, attrs={"tableclass" : "event-table"}))
1.1357 +
1.1358 + output.append(fmt.table_row(on=1))
1.1359 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-table-heading"}))
1.1360 + output.append(fmt.text(_("Event dates")))
1.1361 + output.append(fmt.table_cell(on=0))
1.1362 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-table-heading"}))
1.1363 + output.append(fmt.text(_("Event location")))
1.1364 + output.append(fmt.table_cell(on=0))
1.1365 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-table-heading"}))
1.1366 + output.append(fmt.text(_("Event details")))
1.1367 + output.append(fmt.table_cell(on=0))
1.1368 + output.append(fmt.table_row(on=0))
1.1369 +
1.1370 + # Show the events in order.
1.1371 +
1.1372 + all_shown_events.sort(sort_start_first)
1.1373 +
1.1374 + for event in all_shown_events:
1.1375 + event_page = event.getPage()
1.1376 + event_summary = event.getSummary(self.parent_name)
1.1377 + event_details = event.getDetails()
1.1378 +
1.1379 + # Prepare CSS classes with category-related styling.
1.1380 +
1.1381 + css_classes = ["event-table-details"]
1.1382 +
1.1383 + for topic in event_details.get("topics") or event_details.get("categories") or []:
1.1384 +
1.1385 + # Filter the category text to avoid illegal characters.
1.1386 +
1.1387 + css_classes.append("event-table-category-%s" % "".join(filter(lambda c: c.isalnum(), topic)))
1.1388 +
1.1389 + attrs = {"class" : " ".join(css_classes)}
1.1390 +
1.1391 + output.append(fmt.table_row(on=1))
1.1392 +
1.1393 + # Start and end dates.
1.1394 +
1.1395 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.1396 + output.append(fmt.span(on=1))
1.1397 + output.append(fmt.text(str(event_details["start"])))
1.1398 + output.append(fmt.span(on=0))
1.1399 +
1.1400 + if event_details["start"] != event_details["end"]:
1.1401 + output.append(fmt.text(" - "))
1.1402 + output.append(fmt.span(on=1))
1.1403 + output.append(fmt.text(str(event_details["end"])))
1.1404 + output.append(fmt.span(on=0))
1.1405 +
1.1406 + output.append(fmt.table_cell(on=0))
1.1407 +
1.1408 + # Location.
1.1409 +
1.1410 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.1411 +
1.1412 + if event_details.has_key("location"):
1.1413 + output.append(event_page.formatText(event_details["location"], request, fmt))
1.1414 +
1.1415 + output.append(fmt.table_cell(on=0))
1.1416 +
1.1417 + # Link to the page using the summary.
1.1418 +
1.1419 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.1420 + output.append(event.linkToEvent(request, event_summary))
1.1421 + output.append(fmt.table_cell(on=0))
1.1422 +
1.1423 + output.append(fmt.table_row(on=0))
1.1424 +
1.1425 + # End of table view output.
1.1426 +
1.1427 + output.append(fmt.table(on=0))
1.1428 +
1.1429 + # Output a map view.
1.1430 +
1.1431 + elif self.mode == "map":
1.1432 +
1.1433 + # Special dictionary pages.
1.1434 +
1.1435 + maps_page = getattr(request.cfg, "event_aggregator_maps_page", "EventMapsDict")
1.1436 + locations_page = getattr(request.cfg, "event_aggregator_locations_page", "EventLocationsDict")
1.1437 +
1.1438 + map_image = None
1.1439 +
1.1440 + # Get the maps and locations.
1.1441 +
1.1442 + maps = getWikiDict(maps_page, request)
1.1443 + locations = getWikiDict(locations_page, request)
1.1444 +
1.1445 + # Get the map image definition.
1.1446 +
1.1447 + if maps is not None and self.map_name is not None:
1.1448 + try:
1.1449 + map_details = maps[self.map_name].split()
1.1450 +
1.1451 + map_bottom_left_latitude, map_bottom_left_longitude, map_top_right_latitude, map_top_right_longitude = \
1.1452 + map(getMapReference, map_details[:4])
1.1453 + map_width, map_height = map(int, map_details[4:6])
1.1454 + map_image = map_details[6]
1.1455 +
1.1456 + map_x_scale = map_width / (map_top_right_longitude - map_bottom_left_longitude).to_degrees()
1.1457 + map_y_scale = map_height / (map_top_right_latitude - map_bottom_left_latitude).to_degrees()
1.1458 +
1.1459 + except (KeyError, ValueError):
1.1460 + pass
1.1461 +
1.1462 + # Report errors.
1.1463 +
1.1464 + if maps is None:
1.1465 + output.append(self.showDictError(
1.1466 + _("You do not have read access to the maps page:"),
1.1467 + maps_page))
1.1468 +
1.1469 + elif self.map_name is None:
1.1470 + output.append(self.showDictError(
1.1471 + _("Please specify a valid map name corresponding to an entry on the following page:"),
1.1472 + maps_page))
1.1473 +
1.1474 + elif map_image is None:
1.1475 + output.append(self.showDictError(
1.1476 + _("Please specify a valid entry for %s on the following page:") % self.map_name,
1.1477 + maps_page))
1.1478 +
1.1479 + elif locations is None:
1.1480 + output.append(self.showDictError(
1.1481 + _("You do not have read access to the locations page:"),
1.1482 + locations_page))
1.1483 +
1.1484 + # Attempt to show the map.
1.1485 +
1.1486 + else:
1.1487 +
1.1488 + # Get events by position.
1.1489 +
1.1490 + events_by_location = {}
1.1491 + event_locations = {}
1.1492 +
1.1493 + for event in all_shown_events:
1.1494 + event_details = event.getDetails()
1.1495 +
1.1496 + location = event_details.get("location")
1.1497 +
1.1498 + if location is not None and not event_locations.has_key(location):
1.1499 +
1.1500 + # Get any explicit position of an event.
1.1501 +
1.1502 + if event_details.has_key("geo"):
1.1503 + latitude, longitude = event_details["geo"]
1.1504 +
1.1505 + # Or look up the position of a location using the locations
1.1506 + # page.
1.1507 +
1.1508 + else:
1.1509 + latitude, longitude = getLocationPosition(location, locations)
1.1510 +
1.1511 + # Use a normalised location if necessary.
1.1512 +
1.1513 + if latitude is None and longitude is None:
1.1514 + normalised_location = getNormalisedLocation(location)
1.1515 + if normalised_location is not None:
1.1516 + latitude, longitude = getLocationPosition(normalised_location, locations)
1.1517 + if latitude is not None and longitude is not None:
1.1518 + location = normalised_location
1.1519 +
1.1520 + # Only remember positioned locations.
1.1521 +
1.1522 + if latitude is not None and longitude is not None:
1.1523 + event_locations[location] = latitude, longitude
1.1524 +
1.1525 + # Record events according to location.
1.1526 +
1.1527 + if not events_by_location.has_key(location):
1.1528 + events_by_location[location] = []
1.1529 +
1.1530 + events_by_location[location].append(event)
1.1531 +
1.1532 + # Get the map image URL.
1.1533 +
1.1534 + map_image_url = AttachFile.getAttachUrl(maps_page, map_image, request)
1.1535 +
1.1536 + # Start of map view output.
1.1537 +
1.1538 + map_identifier = "map-%s" % self.getIdentifier()
1.1539 + output.append(fmt.div(on=1, css_class="event-map", id=map_identifier))
1.1540 +
1.1541 + output.append(fmt.table(on=1))
1.1542 +
1.1543 + output.append(fmt.table_row(on=1))
1.1544 + output.append(self.writeMapTableHeading())
1.1545 + output.append(fmt.table_row(on=0))
1.1546 +
1.1547 + output.append(fmt.table_row(on=1))
1.1548 + output.append(fmt.table_cell(on=1))
1.1549 +
1.1550 + output.append(fmt.div(on=1, css_class="event-map-container"))
1.1551 + output.append(fmt.image(map_image_url))
1.1552 + output.append(fmt.number_list(on=1))
1.1553 +
1.1554 + # Events with no location are unpositioned.
1.1555 +
1.1556 + if events_by_location.has_key(None):
1.1557 + unpositioned_events = events_by_location[None]
1.1558 + del events_by_location[None]
1.1559 + else:
1.1560 + unpositioned_events = []
1.1561 +
1.1562 + # Events whose location is unpositioned are themselves considered
1.1563 + # unpositioned.
1.1564 +
1.1565 + for location in set(events_by_location.keys()).difference(event_locations.keys()):
1.1566 + unpositioned_events += events_by_location[location]
1.1567 +
1.1568 + # Sort the locations before traversing them.
1.1569 +
1.1570 + event_locations = event_locations.items()
1.1571 + event_locations.sort()
1.1572 +
1.1573 + # Show the events in the map.
1.1574 +
1.1575 + for location, (latitude, longitude) in event_locations:
1.1576 + events = events_by_location[location]
1.1577 +
1.1578 + # Skip unpositioned locations and locations outside the map.
1.1579 +
1.1580 + if latitude is None or longitude is None or \
1.1581 + latitude < map_bottom_left_latitude or \
1.1582 + longitude < map_bottom_left_longitude or \
1.1583 + latitude > map_top_right_latitude or \
1.1584 + longitude > map_top_right_longitude:
1.1585 +
1.1586 + unpositioned_events += events
1.1587 + continue
1.1588 +
1.1589 + # Get the position and dimensions of the map marker.
1.1590 + # NOTE: Use one degree as the marker size.
1.1591 +
1.1592 + marker_x, marker_y = getPositionForCentrePoint(
1.1593 + getPositionForReference(map_top_right_latitude, longitude, latitude, map_bottom_left_longitude,
1.1594 + map_x_scale, map_y_scale),
1.1595 + map_x_scale, map_y_scale)
1.1596 +
1.1597 + # Put a marker on the map.
1.1598 +
1.1599 + output.append(fmt.listitem(on=1, css_class="event-map-label"))
1.1600 +
1.1601 + # Have a positioned marker for the print mode.
1.1602 +
1.1603 + output.append(fmt.div(on=1, css_class="event-map-label-only",
1.1604 + style="left:%dpx; top:%dpx; min-width:%dpx; min-height:%dpx") % (
1.1605 + marker_x, marker_y, map_x_scale, map_y_scale))
1.1606 + output.append(fmt.div(on=0))
1.1607 +
1.1608 + # Have a marker containing a pop-up when using the screen mode,
1.1609 + # providing a normal block when using the print mode.
1.1610 +
1.1611 + output.append(fmt.div(on=1, css_class="event-map-label",
1.1612 + style="left:%dpx; top:%dpx; min-width:%dpx; min-height:%dpx") % (
1.1613 + marker_x, marker_y, map_x_scale, map_y_scale))
1.1614 + output.append(fmt.div(on=1, css_class="event-map-details"))
1.1615 + output.append(fmt.div(on=1, css_class="event-map-shadow"))
1.1616 + output.append(fmt.div(on=1, css_class="event-map-location"))
1.1617 +
1.1618 + output.append(fmt.heading(on=1, depth=2))
1.1619 + output.append(fmt.text(location))
1.1620 + output.append(fmt.heading(on=0, depth=2))
1.1621 +
1.1622 + output.append(self.writeMapEventSummaries(events))
1.1623 +
1.1624 + output.append(fmt.div(on=0))
1.1625 + output.append(fmt.div(on=0))
1.1626 + output.append(fmt.div(on=0))
1.1627 + output.append(fmt.div(on=0))
1.1628 + output.append(fmt.listitem(on=0))
1.1629 +
1.1630 + output.append(fmt.number_list(on=0))
1.1631 + output.append(fmt.div(on=0))
1.1632 + output.append(fmt.table_cell(on=0))
1.1633 + output.append(fmt.table_row(on=0))
1.1634 +
1.1635 + # Write unpositioned events.
1.1636 +
1.1637 + if unpositioned_events:
1.1638 + unpositioned_identifier = "unpositioned-%s" % self.getIdentifier()
1.1639 +
1.1640 + output.append(fmt.table_row(on=1, css_class="event-map-unpositioned",
1.1641 + id=unpositioned_identifier))
1.1642 + output.append(fmt.table_cell(on=1))
1.1643 +
1.1644 + output.append(fmt.heading(on=1, depth=2))
1.1645 + output.append(fmt.text(_("Events not shown on the map")))
1.1646 + output.append(fmt.heading(on=0, depth=2))
1.1647 +
1.1648 + # Show and hide controls.
1.1649 +
1.1650 + output.append(fmt.div(on=1, css_class="event-map-show-control"))
1.1651 + output.append(fmt.anchorlink(on=1, name=unpositioned_identifier))
1.1652 + output.append(fmt.text(_("Show unpositioned events")))
1.1653 + output.append(fmt.anchorlink(on=0))
1.1654 + output.append(fmt.div(on=0))
1.1655 +
1.1656 + output.append(fmt.div(on=1, css_class="event-map-hide-control"))
1.1657 + output.append(fmt.anchorlink(on=1, name=map_identifier))
1.1658 + output.append(fmt.text(_("Hide unpositioned events")))
1.1659 + output.append(fmt.anchorlink(on=0))
1.1660 + output.append(fmt.div(on=0))
1.1661 +
1.1662 + output.append(self.writeMapEventSummaries(unpositioned_events))
1.1663 +
1.1664 + # End of map view output.
1.1665 +
1.1666 + output.append(fmt.table_cell(on=0))
1.1667 + output.append(fmt.table_row(on=0))
1.1668 + output.append(fmt.table(on=0))
1.1669 + output.append(fmt.div(on=0))
1.1670 +
1.1671 + # Output a list.
1.1672 +
1.1673 + elif self.mode == "list":
1.1674 +
1.1675 + # Start of list view output.
1.1676 +
1.1677 + output.append(fmt.bullet_list(on=1, attr={"class" : "event-listings"}))
1.1678 +
1.1679 + # Output a list.
1.1680 +
1.1681 + for period in self.first.until(self.last):
1.1682 +
1.1683 + output.append(fmt.listitem(on=1, attr={"class" : "event-listings-period"}))
1.1684 + output.append(fmt.div(on=1, attr={"class" : "event-listings-heading"}))
1.1685 +
1.1686 + # Either write a date heading or produce links for navigable
1.1687 + # calendars.
1.1688 +
1.1689 + output.append(self.writeDateHeading(period))
1.1690 +
1.1691 + output.append(fmt.div(on=0))
1.1692 +
1.1693 + output.append(fmt.bullet_list(on=1, attr={"class" : "event-period-listings"}))
1.1694 +
1.1695 + # Show the events in order.
1.1696 +
1.1697 + events_in_period = getEventsInPeriod(all_shown_events, getCalendarPeriod(period, period))
1.1698 + events_in_period.sort(sort_start_first)
1.1699 +
1.1700 + for event in events_in_period:
1.1701 + event_page = event.getPage()
1.1702 + event_details = event.getDetails()
1.1703 + event_summary = event.getSummary(self.parent_name)
1.1704 +
1.1705 + output.append(fmt.listitem(on=1, attr={"class" : "event-listing"}))
1.1706 +
1.1707 + # Link to the page using the summary.
1.1708 +
1.1709 + output.append(fmt.paragraph(on=1))
1.1710 + output.append(event.linkToEvent(request, event_summary))
1.1711 + output.append(fmt.paragraph(on=0))
1.1712 +
1.1713 + # Start and end dates.
1.1714 +
1.1715 + output.append(fmt.paragraph(on=1))
1.1716 + output.append(fmt.span(on=1))
1.1717 + output.append(fmt.text(str(event_details["start"])))
1.1718 + output.append(fmt.span(on=0))
1.1719 + output.append(fmt.text(" - "))
1.1720 + output.append(fmt.span(on=1))
1.1721 + output.append(fmt.text(str(event_details["end"])))
1.1722 + output.append(fmt.span(on=0))
1.1723 + output.append(fmt.paragraph(on=0))
1.1724 +
1.1725 + # Location.
1.1726 +
1.1727 + if event_details.has_key("location"):
1.1728 + output.append(fmt.paragraph(on=1))
1.1729 + output.append(event_page.formatText(event_details["location"], request, fmt))
1.1730 + output.append(fmt.paragraph(on=1))
1.1731 +
1.1732 + # Topics.
1.1733 +
1.1734 + if event_details.has_key("topics") or event_details.has_key("categories"):
1.1735 + output.append(fmt.bullet_list(on=1, attr={"class" : "event-topics"}))
1.1736 +
1.1737 + for topic in event_details.get("topics") or event_details.get("categories") or []:
1.1738 + output.append(fmt.listitem(on=1))
1.1739 + output.append(event_page.formatText(topic, request, fmt))
1.1740 + output.append(fmt.listitem(on=0))
1.1741 +
1.1742 + output.append(fmt.bullet_list(on=0))
1.1743 +
1.1744 + output.append(fmt.listitem(on=0))
1.1745 +
1.1746 + output.append(fmt.bullet_list(on=0))
1.1747 +
1.1748 + # End of list view output.
1.1749 +
1.1750 + output.append(fmt.bullet_list(on=0))
1.1751 +
1.1752 + # Output a month calendar. This shows month-by-month data.
1.1753 +
1.1754 + elif self.mode == "calendar":
1.1755 +
1.1756 + # Visit all months in the requested range, or across known events.
1.1757 +
1.1758 + for month in self.first.months_until(self.last):
1.1759 +
1.1760 + # Output a month.
1.1761 +
1.1762 + output.append(fmt.table(on=1, attrs={"tableclass" : "event-month"}))
1.1763 +
1.1764 + # Either write a month heading or produce links for navigable
1.1765 + # calendars.
1.1766 +
1.1767 + output.append(self.writeMonthTableHeading(month))
1.1768 +
1.1769 + # Weekday headings.
1.1770 +
1.1771 + output.append(self.writeWeekdayHeadings())
1.1772 +
1.1773 + # Process the days of the month.
1.1774 +
1.1775 + start_weekday, number_of_days = month.month_properties()
1.1776 +
1.1777 + # The start weekday is the weekday of day number 1.
1.1778 + # Find the first day of the week, counting from below zero, if
1.1779 + # necessary, in order to land on the first day of the month as
1.1780 + # day number 1.
1.1781 +
1.1782 + first_day = 1 - start_weekday
1.1783 +
1.1784 + while first_day <= number_of_days:
1.1785 +
1.1786 + # Find events in this week and determine how to mark them on the
1.1787 + # calendar.
1.1788 +
1.1789 + week_start = month.as_date(max(first_day, 1))
1.1790 + week_end = month.as_date(min(first_day + 6, number_of_days))
1.1791 +
1.1792 + full_coverage, week_slots = getCoverage(
1.1793 + getEventsInPeriod(all_shown_events, getCalendarPeriod(week_start, week_end)))
1.1794 +
1.1795 + # Output a week, starting with the day numbers.
1.1796 +
1.1797 + output.append(self.writeDayNumbers(first_day, number_of_days, month, full_coverage))
1.1798 +
1.1799 + # Either generate empty days...
1.1800 +
1.1801 + if not week_slots:
1.1802 + output.append(self.writeEmptyWeek(first_day, number_of_days))
1.1803 +
1.1804 + # Or generate each set of scheduled events...
1.1805 +
1.1806 + else:
1.1807 + output.append(self.writeWeekSlots(first_day, number_of_days, month, week_end, week_slots))
1.1808 +
1.1809 + # Process the next week...
1.1810 +
1.1811 + first_day += 7
1.1812 +
1.1813 + # End of month.
1.1814 +
1.1815 + output.append(fmt.table(on=0))
1.1816 +
1.1817 + # Output a day view.
1.1818 +
1.1819 + elif self.mode == "day":
1.1820 +
1.1821 + # Visit all days in the requested range, or across known events.
1.1822 +
1.1823 + for date in self.first.days_until(self.last):
1.1824 +
1.1825 + output.append(fmt.table(on=1, attrs={"tableclass" : "event-calendar-day"}))
1.1826 +
1.1827 + full_coverage, day_slots = getCoverage(
1.1828 + getEventsInPeriod(all_shown_events, getCalendarPeriod(date, date)), "datetime")
1.1829 +
1.1830 + # Work out how many columns the day title will need.
1.1831 + # Include spacers after the scale and each event column.
1.1832 +
1.1833 + colspan = sum(map(len, day_slots.values())) * 2 + 2
1.1834 +
1.1835 + output.append(self.writeDayTableHeading(date, colspan))
1.1836 +
1.1837 + # Either generate empty days...
1.1838 +
1.1839 + if not day_slots:
1.1840 + output.append(self.writeEmptyDay(date))
1.1841 +
1.1842 + # Or generate each set of scheduled events...
1.1843 +
1.1844 + else:
1.1845 + output.append(self.writeDaySlots(date, full_coverage, day_slots))
1.1846 +
1.1847 + # End of day.
1.1848 +
1.1849 + output.append(fmt.table(on=0))
1.1850 +
1.1851 + # Output view controls.
1.1852 +
1.1853 + output.append(fmt.div(on=1, css_class="event-controls"))
1.1854 + output.append(self.writeViewControls())
1.1855 + output.append(fmt.div(on=0))
1.1856 +
1.1857 + # Close the calendar region.
1.1858 +
1.1859 + output.append(fmt.div(on=0))
1.1860 +
1.1861 + return ''.join(output)
1.1862 +
1.1863 # vim: tabstop=4 expandtab shiftwidth=4