# HG changeset patch # User Paul Boddie # Date 1352245286 -3600 # Node ID eb70f4e054cfeae9b1cd477053a4ea87b0fe44e3 # Parent 6e0ac368dee229627b117a2ee26f66cbe13fe42b Added support for highlighting the current day in the calendar view. diff -r 6e0ac368dee2 -r eb70f4e054cf EventAggregatorSupport.py --- a/EventAggregatorSupport.py Sun Oct 21 18:44:16 2012 +0200 +++ b/EventAggregatorSupport.py Wed Nov 07 00:41:26 2012 +0100 @@ -1903,9 +1903,11 @@ # Output the heading class. + today_attr = date == getCurrentDate() and "event-day-current" or "" + append( fmt.table_cell(on=1, attrs={ - "class" : "event-day-heading event-day-%s" % (busy and "busy" or "empty"), + "class" : "event-day-heading event-day-%s %s" % (busy and "busy" or "empty", today_attr), "colspan" : "3" })) @@ -2058,7 +2060,7 @@ append(fmt.table_row(on=0)) return "".join(output) - def writeEmptyWeek(self, first_day, number_of_days): + def writeEmptyWeek(self, first_day, number_of_days, month): page = self.page fmt = page.request.formatter @@ -2069,19 +2071,22 @@ for weekday in range(0, 7): day = first_day + weekday + date = month.as_date(day) + + today_attr = date == getCurrentDate() and "event-day-current" or "" # Output out-of-month days. if day < 1 or day > number_of_days: append(fmt.table_cell(on=1, - attrs={"class" : "event-day-content event-day-excluded", "colspan" : "3"})) + attrs={"class" : "event-day-content event-day-excluded %s" % today_attr, "colspan" : "3"})) append(fmt.table_cell(on=0)) # Output empty days. else: append(fmt.table_cell(on=1, - attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"})) + attrs={"class" : "event-day-content event-day-empty %s" % today_attr, "colspan" : "3"})) append(fmt.table_row(on=0)) return "".join(output) @@ -2107,7 +2112,7 @@ # Add a spacer. - append(self.writeWeekSpacer(first_day, number_of_days)) + append(self.writeWeekSpacer(first_day, number_of_days, month)) return "".join(output) @@ -2136,10 +2141,15 @@ continue # Output the day. + # Where a day does not contain an event, a single cell is used. + # Otherwise, multiple cells are used to provide space before, during + # and after events. + + today_attr = date == getCurrentDate() and "event-day-current" or "" if date not in events: append(fmt.table_cell(on=1, - attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"})) + attrs={"class" : "event-day-content event-day-empty %s" % today_attr, "colspan" : "3"})) # Get event details for the current day. @@ -2181,7 +2191,7 @@ # Events starting today... else: - append(fmt.table_cell(on=1, attrs={"class" : "event-day-start-gap"})) + append(fmt.table_cell(on=1, attrs={"class" : "event-day-start-gap %s" % today_attr})) append(fmt.table_cell(on=0)) # Calculate the span of this cell. @@ -2259,7 +2269,7 @@ # Colour the cell for continuing events. attrs={ - "class" : "event-day-content event-day-busy %s" % event_day_type, + "class" : "event-day-content event-day-busy %s %s" % (event_day_type, today_attr), "colspan" : str(colspan) } @@ -2278,7 +2288,7 @@ # Output end of day gap. if ends_today and not starts_today: - append(fmt.table_cell(on=1, attrs={"class" : "event-day-end-gap"})) + append(fmt.table_cell(on=1, attrs={"class" : "event-day-end-gap %s" % today_attr})) append(fmt.table_cell(on=0)) # End of set. @@ -2286,7 +2296,7 @@ append(fmt.table_row(on=0)) return "".join(output) - def writeWeekSpacer(self, first_day, number_of_days): + def writeWeekSpacer(self, first_day, number_of_days, month): page = self.page fmt = page.request.formatter @@ -2297,7 +2307,10 @@ for weekday in range(0, 7): day = first_day + weekday - css_classes = "event-day-spacer" + date = month.as_date(day) + today_attr = date == getCurrentDate() and "event-day-current" or "" + + css_classes = "event-day-spacer %s" % today_attr # Skip out-of-month days. @@ -3103,7 +3116,7 @@ # Either generate empty days... if not week_slots: - append(self.writeEmptyWeek(first_day, number_of_days)) + append(self.writeEmptyWeek(first_day, number_of_days, month)) # Or generate each set of scheduled events... diff -r 6e0ac368dee2 -r eb70f4e054cf css/event-aggregator.css --- a/css/event-aggregator.css Sun Oct 21 18:44:16 2012 +0200 +++ b/css/event-aggregator.css Wed Nov 07 00:41:26 2012 +0100 @@ -180,7 +180,13 @@ border: 1px solid #dddddd; } -/* Day types: days with content (busy), unused days (excluded or empty). */ +/* Day types: days with content (busy), unused days (excluded or empty), + current (today). */ + +.event-day-current.event-day-busy, +.event-day-current.event-day-empty { + background-color: #ffdddd; +} .event-day-busy, .event-timespan-busy { @@ -206,6 +212,10 @@ /* Day headings and numbers. */ +.event-day-current.event-day-heading { + background-color: #ffdddd; +} + .event-day-heading { width: 14%; vertical-align: top; @@ -272,6 +282,11 @@ border-right: 1px solid #dddddd; } +.event-day-current.event-day-start-gap, +.event-day-current.event-day-end-gap { + background-color: #ffdddd; +} + .event-day-start-gap { width: 2%; border-top: 0; @@ -335,6 +350,10 @@ /* Day spacers. */ +.event-day-current.event-day-spacer { + background-color: #ffdddd; +} + .event-day-spacer { min-height: 0.5em; border-top: 0;