# HG changeset patch # User Paul Boddie # Date 1302216140 -7200 # Node ID 8f7fa1414b1fab1edbc08370ccd3e0f7fc691205 # Parent 7e20045d29791fd54f9343f7fed31f184ba744a5 Added location information to the day view along with some more spacing. Introduced timespan reversal where ambiguous times cause a period to be uncomparable to other periods (because the start is later than the end). Tidied up some styles and day spacer generation. diff -r 7e20045d2979 -r 8f7fa1414b1f EventAggregatorSupport.py --- a/EventAggregatorSupport.py Thu Apr 07 23:44:06 2011 +0200 +++ b/EventAggregatorSupport.py Fri Apr 08 00:42:20 2011 +0200 @@ -515,7 +515,7 @@ # Labels which may well be quoted. elif term in ("title", "summary", "description", "location"): - desc = getSimpleWikiText(desc) + desc = getSimpleWikiText(desc.strip()) if desc is not None: @@ -1557,6 +1557,11 @@ self.start = start self.end = end + # NOTE: Should perhaps catch ambiguous time problems elsewhere. + + if self.ambiguous() and start > end: + self.start, self.end = end, start + def __repr__(self): return "%s(%r, %r)" % (self.__class__.__name__, self.start, self.end) @@ -1569,6 +1574,9 @@ def as_limits(self): return self.start, self.end + def ambiguous(self): + return self.start.ambiguous() or self.end.ambiguous() + def convert(self, resolution): return Timespan(*map(self._get_converter(resolution), self.as_limits())) diff -r 7e20045d2979 -r 8f7fa1414b1f css/event-aggregator.css --- a/css/event-aggregator.css Thu Apr 07 23:44:06 2011 +0200 +++ b/css/event-aggregator.css Fri Apr 08 00:42:20 2011 +0200 @@ -274,21 +274,40 @@ border-bottom: 1px solid #dddddd; } -.event-scale-heading { - vertical-align: top; +.event-scale-heading, +.event-timespan-content, +.event-timespan-spacer { border-top: 1px solid #dddddd; border-bottom: 1px solid #dddddd; border-left: 0; border-right: 0; +} + +.event-location-heading, +.event-location-spacer { + border: 0; +} + +.event-location-heading, +.event-location-spacer, +.event-timespan-spacer, +.event-full-day-spacer { + background-color: #ffffff; +} + +.event-location-heading { + text-align: center; + border: 0; + background-color: #ffffff; +} + +.event-scale-heading { padding-bottom: 2em; } +.event-scale-heading, .event-timespan-content { vertical-align: top; - border-left: 0; - border-right: 0; - border-top: 1px solid #dddddd; - border-bottom: 1px solid #dddddd; } .event-timespan-content a:link, @@ -299,16 +318,6 @@ .event-timespan-spacer { width: 2%; - border-left: 0; - border-right: 0; - border-top: 1px solid #dddddd; - border-bottom: 1px solid #dddddd; - background-color: #ffffff; -} - -.event-full-day-spacer { - border: 0; - background-color: #ffffff; } /* List/summary view. */ diff -r 7e20045d2979 -r 8f7fa1414b1f macros/EventAggregator.py --- a/macros/EventAggregator.py Thu Apr 07 23:44:06 2011 +0200 +++ b/macros/EventAggregator.py Fri Apr 08 00:42:20 2011 +0200 @@ -478,7 +478,7 @@ event_details = event.getDetails() event_summary = event.getSummary(self.parent_name) - is_ambiguous = event_details["start"].ambiguous() or event_details["end"].ambiguous() + is_ambiguous = event.as_timespan().ambiguous() style = self.getEventStyle(event_summary) # The event box contains the summary, alongside @@ -851,6 +851,13 @@ return "".join(output) def writeDaySlots(self, date, full_coverage, day_slots): + + """ + Given a 'date', non-empty 'full_coverage' for the day concerned, and a + non-empty mapping of 'day_slots' (from locations to event collections), + output the day slots for the day. + """ + page = self.page fmt = page.formatter @@ -899,6 +906,29 @@ day_rows.append((period, day_row)) + # Output the locations. + + output.append(fmt.table_row(on=1)) + + # Add a spacer. + + output.append(self.writeDaySpacer(colspan=2, cls="location")) + + for location in locations: + + # Add spacers to the column spans. + + columns = len(day_slots[location]) * 2 - 1 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-location-heading", "colspan" : str(columns)})) + output.append(fmt.text(location)) + output.append(fmt.table_cell(on=0)) + + # Add a trailing spacer. + + output.append(self.writeDaySpacer(cls="location")) + + output.append(fmt.table_row(on=0)) + # Output the periods with event details. period = None @@ -919,14 +949,12 @@ output.append(fmt.table_row(on=1)) output.append(self.writeDayScaleHeading(period.start.time_string())) + output.append(self.writeDaySpacer()) + # Visit each slot corresponding to a location (or no location). for location, event in day_row: - # Add a spacer. - - output.append(self.writeDaySpacer()) - # Output each location slot's contribution. if event is None or event not in events_written: @@ -934,6 +962,10 @@ if event is not None: events_written.add(event) + # Add a trailing spacer. + + output.append(self.writeDaySpacer()) + output.append(fmt.table_row(on=0)) # Write a final time heading if the last period ends in the current day. @@ -1004,13 +1036,13 @@ return "".join(output) - def writeDaySpacer(self, colspan=1, full_day=0): + def writeDaySpacer(self, colspan=1, cls="timespan"): page = self.page fmt = page.formatter output = [] output.append(fmt.table_cell(on=1, attrs={ - "class" : "event-%s-spacer" % (full_day and "full-day" or "timespan"), + "class" : "event-%s-spacer" % cls, "colspan" : str(colspan)})) output.append(fmt.table_cell(on=0)) return "".join(output) @@ -1413,12 +1445,11 @@ getEventsInPeriod(all_shown_events, getCalendarPeriod(date, date)), "datetime") # Work out how many columns the day title will need. - # Include spacers before each event column. + # Include spacers after the scale and each event column. - colspan = sum(map(len, day_slots.values())) * 2 + 1 + colspan = sum(map(len, day_slots.values())) * 2 + 2 output.append(view.writeDayHeading(date, colspan)) - output.append(view.writeDaySpacer(colspan, full_day=1)) # Either generate empty days...