# HG changeset patch # User Paul Boddie # Date 1238870988 -7200 # Node ID b22cad41be9c7a3b358b24243138efdba6455d49 # Parent 4a0d5ccca0289e3be7b7b677fa67d4c640869015 Changed the macro layout to use table cells potentially spanning many columns in order to present event details in a better fashion, dropping the previous start and end representation employing margins within cells, instead employing empty cells at the start and end of days. Made the "weekly" name policy the default, since it is superior to the "daily" policy. Added help on name policies and navigation controls. diff -r 4a0d5ccca028 -r b22cad41be9c css/event-aggregator.css --- a/css/event-aggregator.css Sat Apr 04 03:49:02 2009 +0200 +++ b/css/event-aggregator.css Sat Apr 04 20:49:48 2009 +0200 @@ -52,12 +52,36 @@ border: 1px solid #dddddd; } +/* Day types: days with content (busy), unused days (excluded or empty). */ + +.event-day-busy { + background-color: #ffffff; +} + +.event-day-excluded { + background-color: #dddddd; + border-left: 1px solid #dddddd; + border-right: 1px solid #dddddd; +} + +.event-day-empty { + background-color: #ffffff; + border-left: 1px solid #dddddd; + border-right: 1px solid #dddddd; +} + +.event-day-content.event-day-empty { + padding-bottom: 2em; +} + +/* Day headings and numbers. */ + .event-day-heading { - background-color: #ffffff; width: 14%; vertical-align: top; padding-top: 0; padding-left: 0; + padding-bottom: 0.5em; border-top: 1px solid #dddddd; border-bottom: 0; border-left: 1px solid #dddddd; @@ -77,61 +101,70 @@ padding: 0.25em; } -.event-day { +/* Day content. */ + +.event-day-content { width: 14%; vertical-align: top; - padding-left: 0; - padding-right: 0; + padding: 0; border-top: 0; border-bottom: 0; +} + +.event-day-starting { + border-left: 0; + border-right: 1px solid #dddddd; +} + +.event-day-ending { + border-left: 1px solid #dddddd; + border-right: 0; +} + +.event-day-full, +.event-day-single, +.event-day-multiple { border-left: 1px solid #dddddd; border-right: 1px solid #dddddd; } -.event-day-empty { - background-color: #ffffff; -} - -.event-day.event-day-empty { - padding-bottom: 2em; +.event-day-start-gap { + width: 2%; + border-top: 0; + border-bottom: 0; + border-left: 1px solid #dddddd; + border-right: 0; } -.event-day-busy { - background-color: #ffffff; +.event-day-end-gap { + width: 2%; + border-top: 0; + border-bottom: 0; + border-left: 0; + border-right: 1px solid #dddddd; } -.event-day-excluded { - background-color: #dddddd; -} +/* Event details. */ .event-summary-box { position: relative; } -.event-summary-box a:link, -.event-summary-box a:hover, -.event-summary-box a:visited { +.event-day-content a:link, +.event-day-content a:hover, +.event-day-content a:visited { color: inherit !important; } .event-summary { - padding: 0.25em 0.75em 0.25em 0.75em; - margin-bottom: 0.25em; - min-height: 2em; + padding: 0.5em; margin-left: 0; margin-right: 0; overflow: hidden; } -.event-summary.event-starts { - padding-left: 0.25em; - padding-right: 0.75em; +.event-day-single .event-summary { margin-left: 0.5em; -} - -.event-summary.event-ends { - padding-left: 0.75em; - padding-right: 0.25em; margin-right: 0.5em; } @@ -142,14 +175,23 @@ left: 0; top: 0; z-index: 2; - padding: 0.25em 0.75em 0.25em 0.75em; - min-height: 2em; + padding: 0.5em; } .event-summary-box:hover > .event-summary-popup { display: block; } +/* Day spacers. */ + +.event-day-spacer { + min-height: 0.5em; + border-top: 0; + border-bottom: 0; + border-left: 1px solid #dddddd; + border-right: 1px solid #dddddd; +} + /* List/summary view. */ .event-listings { diff -r 4a0d5ccca028 -r b22cad41be9c macros/EventAggregator.py --- a/macros/EventAggregator.py Sat Apr 04 03:49:02 2009 +0200 +++ b/macros/EventAggregator.py Sat Apr 04 20:49:48 2009 +0200 @@ -96,7 +96,7 @@ calendar_start = None calendar_end = None mode = "calendar" - name_usage = "daily" + name_usage = "weekly" calendar_name = None for arg in parsed_args: @@ -198,7 +198,7 @@ output.append(fmt.table(on=1, attrs={"tableclass" : "event-month"})) output.append(fmt.table_row(on=1)) - output.append(fmt.table_cell(on=1, attrs={"class" : "event-month-heading", "colspan" : "7"})) + output.append(fmt.table_cell(on=1, attrs={"class" : "event-month-heading", "colspan" : "21"})) # Either write a month heading or produce a link for navigable # calendars. @@ -271,7 +271,7 @@ output.append(fmt.table_row(on=1)) for weekday in range(0, 7): - output.append(fmt.table_cell(on=1, attrs={"class" : "event-weekday-heading"})) + output.append(fmt.table_cell(on=1, attrs={"class" : "event-weekday-heading", "colspan" : "3"})) output.append(fmt.text(_(EventAggregatorSupport.getDayLabel(weekday)))) output.append(fmt.table_cell(on=0)) @@ -310,16 +310,16 @@ # Output out-of-month days. if day < 1 or day > number_of_days: - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-excluded"})) + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-excluded", "colspan" : "3"})) output.append(fmt.table_cell(on=0)) # Output normal days. else: if date in week_coverage: - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-busy"})) + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-busy", "colspan" : "3"})) else: - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-empty"})) + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-empty", "colspan" : "3"})) output.append(fmt.div(on=1)) output.append(fmt.span(on=1, css_class="event-day-number")) @@ -347,13 +347,15 @@ # Output out-of-month days. if day < 1 or day > number_of_days: - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-excluded"})) + output.append(fmt.table_cell(on=1, + attrs={"class" : "event-day-content event-day-excluded", "colspan" : "3"})) output.append(fmt.table_cell(on=0)) # Output empty days. else: - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-empty"})) + output.append(fmt.table_cell(on=1, + attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"})) output.append(fmt.table_row(on=0)) @@ -375,16 +377,16 @@ # Skip out-of-month days. if day < 1 or day > number_of_days: - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-excluded"})) + output.append(fmt.table_cell(on=1, + attrs={"class" : "event-day-content event-day-excluded", "colspan" : "3"})) output.append(fmt.table_cell(on=0)) continue # Output the day. - if date in coverage: - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-busy"})) - else: - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-empty"})) + if date not in coverage: + output.append(fmt.table_cell(on=1, + attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"})) # Get event details for the current day. @@ -392,6 +394,10 @@ if not (event_details["start"] <= date <= event_details["end"]): continue + # Get basic properties of the event. + + starts_today = event_details["start"] == date + ends_today = event_details["end"] == date event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details) # Generate a colour for the event. @@ -401,43 +407,143 @@ style = ("background-color: rgb(%d, %d, %d); color: rgb(%d, %d, %d);" % (bg + fg)) hidden_style = ("background-color: rgb(%d, %d, %d); color: rgb(%d, %d, %d);" % (bg + bg)) - css_classes = ["event-summary"] + # Determine if the event name should be shown. - if event_details["start"] == date: - css_classes.append("event-starts") - start_of_event = 1 - else: - start_of_event = 0 + start_of_period = starts_today or weekday == 0 or day == 1 - if event_details["end"] == date: - css_classes.append("event-ends") - - # Output the event. - - if name_usage == "daily" or start_of_event or weekday == 0 or day == 1: + if name_usage == "daily" or start_of_period: hide_text = 0 else: hide_text = 1 - output.append(fmt.div(on=1, css_class="event-summary-box")) + # Output start of day gap and determine whether + # any event content should be explicitly output + # for this day. + + if starts_today: + + # Single day events... + + if ends_today: + colspan = 3 + event_day_type = "event-day-single" + + # Events starting today... + + else: + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-start-gap"})) + output.append(fmt.table_cell(on=0)) + + # Calculate the span of this cell. + # Events whose names appear on every day... + + if name_usage == "daily": + colspan = 2 + event_day_type = "event-day-starting" + + # Events whose names appear once per week... + + else: + if event_details["end"] <= week_end: + event_length = event_details["end"][2] - day + 1 + colspan = (event_length - 2) * 3 + 4 + else: + event_length = week_end[2] - day + 1 + colspan = (event_length - 1) * 3 + 2 + + event_day_type = "event-day-multiple" + + # Events continuing from a previous week... + + elif start_of_period: + + # End of continuing event... + + if ends_today: + colspan = 2 + event_day_type = "event-day-ending" + + # Events continuing for at least one more day... + + else: + + # Calculate the span of this cell. + # Events whose names appear on every day... + + if name_usage == "daily": + colspan = 3 + event_day_type = "event-day-full" + + # Events whose names appear once per week... - if not hide_text: - output.append(fmt.div(on=1, css_class=(" ".join(css_classes)), style=style)) - output.append(linkToPage(request, event_page, event_summary)) + else: + if event_details["end"] <= week_end: + event_length = event_details["end"][2] - day + 1 + colspan = (event_length - 1) * 3 + 2 + else: + event_length = week_end[2] - day + 1 + colspan = event_length * 3 + + event_day_type = "event-day-multiple" + + # Continuing events whose names appear on every day... + + elif name_usage == "daily": + if ends_today: + colspan = 2 + event_day_type = "event-day-ending" + else: + colspan = 3 + event_day_type = "event-day-full" + + # Continuing events whose names appear once per week... + + else: + colspan = None + + # Output the main content only if it is not + # continuing from a previous day. + + if colspan is not None: + + # Colour the cell for continuing events. + + attrs={ + "class" : "event-day-content event-day-busy %s" % event_day_type, + "colspan" : str(colspan) + } + + if not (starts_today and ends_today): + attrs["style"] = hide_text and hidden_style or style + + output.append(fmt.table_cell(on=1, attrs=attrs)) + + # Output the event. + + if starts_today and ends_today or not hide_text: + + output.append(fmt.div(on=1, css_class="event-summary-box")) + output.append(fmt.div(on=1, css_class="event-summary", style=style)) + output.append(linkToPage(request, event_page, event_summary)) + output.append(fmt.div(on=0)) + + # Add a pop-up element for long summaries. + + output.append(fmt.div(on=1, css_class="event-summary-popup", style=style)) + output.append(linkToPage(request, event_page, event_summary)) + output.append(fmt.div(on=0)) + + output.append(fmt.div(on=0)) + + # Output end of day content. + output.append(fmt.div(on=0)) - # Add a pop-up element for long summaries. - - output.append(fmt.div(on=1, css_class="event-summary-popup", style=style)) - output.append(linkToPage(request, event_page, event_summary)) - output.append(fmt.div(on=0)) + # Output end of day gap. - else: - output.append(fmt.div(on=1, css_class=(" ".join(css_classes)), style=hidden_style)) - output.append(fmt.text(event_summary)) - output.append(fmt.div(on=0)) - - output.append(fmt.div(on=0)) + if ends_today and not starts_today: + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-end-gap"})) + output.append(fmt.table_cell(on=0)) # End of day. @@ -447,6 +553,24 @@ output.append(fmt.table_row(on=0)) + # Add a spacer. + + output.append(fmt.table_row(on=1)) + + for weekday in range(0, 7): + day = first_day + weekday + css_classes = "event-day-spacer" + + # Skip out-of-month days. + + if day < 1 or day > number_of_days: + css_classes += " event-day-excluded" + + output.append(fmt.table_cell(on=1, attrs={"class" : css_classes, "colspan" : "3"})) + output.append(fmt.table_cell(on=0)) + + output.append(fmt.table_row(on=0)) + # Process the next week... first_day += 7 diff -r 4a0d5ccca028 -r b22cad41be9c pages/HelpOnEventAggregator --- a/pages/HelpOnEventAggregator Sat Apr 04 03:49:02 2009 +0200 +++ b/pages/HelpOnEventAggregator Sat Apr 04 20:49:48 2009 +0200 @@ -90,6 +90,28 @@ <> }}} +=== Event Naming === + +The default calendar view shows event names once per week. However, you can choose to show an event name on each day an event occurs: + +{{{ +## Show the name on every day. +<> +## Show the name once per week. +<> +}}} + +=== Navigation Controls === + +The above examples have all provided fixed views of known events. However, a set of controls can be added to a calendar in order to let users navigate different time periods. This is done by providing a `calendar` parameter, indicating the name of the calendar, and by specifying a period of time: + +{{{ +## Provide a navigable calendar. +<> +}}} + +Without any time period, the calendar would show all events, and there would be no real need to provide navigation, since there would be no events outside the displayed period to navigate to. It is possible to omit either the `start` or the `end` parameter and still provide navigation, however. + == Showing Event Lists == A more plain view of events can be displayed by specifying the `mode` parameter as follows: