1.1 --- a/macros/EventAggregator.py Sat Apr 04 03:49:02 2009 +0200
1.2 +++ b/macros/EventAggregator.py Sat Apr 04 20:49:48 2009 +0200
1.3 @@ -96,7 +96,7 @@
1.4 calendar_start = None
1.5 calendar_end = None
1.6 mode = "calendar"
1.7 - name_usage = "daily"
1.8 + name_usage = "weekly"
1.9 calendar_name = None
1.10
1.11 for arg in parsed_args:
1.12 @@ -198,7 +198,7 @@
1.13 output.append(fmt.table(on=1, attrs={"tableclass" : "event-month"}))
1.14
1.15 output.append(fmt.table_row(on=1))
1.16 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-month-heading", "colspan" : "7"}))
1.17 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-month-heading", "colspan" : "21"}))
1.18
1.19 # Either write a month heading or produce a link for navigable
1.20 # calendars.
1.21 @@ -271,7 +271,7 @@
1.22 output.append(fmt.table_row(on=1))
1.23
1.24 for weekday in range(0, 7):
1.25 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-weekday-heading"}))
1.26 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-weekday-heading", "colspan" : "3"}))
1.27 output.append(fmt.text(_(EventAggregatorSupport.getDayLabel(weekday))))
1.28 output.append(fmt.table_cell(on=0))
1.29
1.30 @@ -310,16 +310,16 @@
1.31 # Output out-of-month days.
1.32
1.33 if day < 1 or day > number_of_days:
1.34 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-excluded"}))
1.35 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-excluded", "colspan" : "3"}))
1.36 output.append(fmt.table_cell(on=0))
1.37
1.38 # Output normal days.
1.39
1.40 else:
1.41 if date in week_coverage:
1.42 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-busy"}))
1.43 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-busy", "colspan" : "3"}))
1.44 else:
1.45 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-empty"}))
1.46 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-heading event-day-empty", "colspan" : "3"}))
1.47
1.48 output.append(fmt.div(on=1))
1.49 output.append(fmt.span(on=1, css_class="event-day-number"))
1.50 @@ -347,13 +347,15 @@
1.51 # Output out-of-month days.
1.52
1.53 if day < 1 or day > number_of_days:
1.54 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-excluded"}))
1.55 + output.append(fmt.table_cell(on=1,
1.56 + attrs={"class" : "event-day-content event-day-excluded", "colspan" : "3"}))
1.57 output.append(fmt.table_cell(on=0))
1.58
1.59 # Output empty days.
1.60
1.61 else:
1.62 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-empty"}))
1.63 + output.append(fmt.table_cell(on=1,
1.64 + attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"}))
1.65
1.66 output.append(fmt.table_row(on=0))
1.67
1.68 @@ -375,16 +377,16 @@
1.69 # Skip out-of-month days.
1.70
1.71 if day < 1 or day > number_of_days:
1.72 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-excluded"}))
1.73 + output.append(fmt.table_cell(on=1,
1.74 + attrs={"class" : "event-day-content event-day-excluded", "colspan" : "3"}))
1.75 output.append(fmt.table_cell(on=0))
1.76 continue
1.77
1.78 # Output the day.
1.79
1.80 - if date in coverage:
1.81 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-busy"}))
1.82 - else:
1.83 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day event-day-empty"}))
1.84 + if date not in coverage:
1.85 + output.append(fmt.table_cell(on=1,
1.86 + attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"}))
1.87
1.88 # Get event details for the current day.
1.89
1.90 @@ -392,6 +394,10 @@
1.91 if not (event_details["start"] <= date <= event_details["end"]):
1.92 continue
1.93
1.94 + # Get basic properties of the event.
1.95 +
1.96 + starts_today = event_details["start"] == date
1.97 + ends_today = event_details["end"] == date
1.98 event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details)
1.99
1.100 # Generate a colour for the event.
1.101 @@ -401,43 +407,143 @@
1.102 style = ("background-color: rgb(%d, %d, %d); color: rgb(%d, %d, %d);" % (bg + fg))
1.103 hidden_style = ("background-color: rgb(%d, %d, %d); color: rgb(%d, %d, %d);" % (bg + bg))
1.104
1.105 - css_classes = ["event-summary"]
1.106 + # Determine if the event name should be shown.
1.107
1.108 - if event_details["start"] == date:
1.109 - css_classes.append("event-starts")
1.110 - start_of_event = 1
1.111 - else:
1.112 - start_of_event = 0
1.113 + start_of_period = starts_today or weekday == 0 or day == 1
1.114
1.115 - if event_details["end"] == date:
1.116 - css_classes.append("event-ends")
1.117 -
1.118 - # Output the event.
1.119 -
1.120 - if name_usage == "daily" or start_of_event or weekday == 0 or day == 1:
1.121 + if name_usage == "daily" or start_of_period:
1.122 hide_text = 0
1.123 else:
1.124 hide_text = 1
1.125
1.126 - output.append(fmt.div(on=1, css_class="event-summary-box"))
1.127 + # Output start of day gap and determine whether
1.128 + # any event content should be explicitly output
1.129 + # for this day.
1.130 +
1.131 + if starts_today:
1.132 +
1.133 + # Single day events...
1.134 +
1.135 + if ends_today:
1.136 + colspan = 3
1.137 + event_day_type = "event-day-single"
1.138 +
1.139 + # Events starting today...
1.140 +
1.141 + else:
1.142 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-start-gap"}))
1.143 + output.append(fmt.table_cell(on=0))
1.144 +
1.145 + # Calculate the span of this cell.
1.146 + # Events whose names appear on every day...
1.147 +
1.148 + if name_usage == "daily":
1.149 + colspan = 2
1.150 + event_day_type = "event-day-starting"
1.151 +
1.152 + # Events whose names appear once per week...
1.153 +
1.154 + else:
1.155 + if event_details["end"] <= week_end:
1.156 + event_length = event_details["end"][2] - day + 1
1.157 + colspan = (event_length - 2) * 3 + 4
1.158 + else:
1.159 + event_length = week_end[2] - day + 1
1.160 + colspan = (event_length - 1) * 3 + 2
1.161 +
1.162 + event_day_type = "event-day-multiple"
1.163 +
1.164 + # Events continuing from a previous week...
1.165 +
1.166 + elif start_of_period:
1.167 +
1.168 + # End of continuing event...
1.169 +
1.170 + if ends_today:
1.171 + colspan = 2
1.172 + event_day_type = "event-day-ending"
1.173 +
1.174 + # Events continuing for at least one more day...
1.175 +
1.176 + else:
1.177 +
1.178 + # Calculate the span of this cell.
1.179 + # Events whose names appear on every day...
1.180 +
1.181 + if name_usage == "daily":
1.182 + colspan = 3
1.183 + event_day_type = "event-day-full"
1.184 +
1.185 + # Events whose names appear once per week...
1.186
1.187 - if not hide_text:
1.188 - output.append(fmt.div(on=1, css_class=(" ".join(css_classes)), style=style))
1.189 - output.append(linkToPage(request, event_page, event_summary))
1.190 + else:
1.191 + if event_details["end"] <= week_end:
1.192 + event_length = event_details["end"][2] - day + 1
1.193 + colspan = (event_length - 1) * 3 + 2
1.194 + else:
1.195 + event_length = week_end[2] - day + 1
1.196 + colspan = event_length * 3
1.197 +
1.198 + event_day_type = "event-day-multiple"
1.199 +
1.200 + # Continuing events whose names appear on every day...
1.201 +
1.202 + elif name_usage == "daily":
1.203 + if ends_today:
1.204 + colspan = 2
1.205 + event_day_type = "event-day-ending"
1.206 + else:
1.207 + colspan = 3
1.208 + event_day_type = "event-day-full"
1.209 +
1.210 + # Continuing events whose names appear once per week...
1.211 +
1.212 + else:
1.213 + colspan = None
1.214 +
1.215 + # Output the main content only if it is not
1.216 + # continuing from a previous day.
1.217 +
1.218 + if colspan is not None:
1.219 +
1.220 + # Colour the cell for continuing events.
1.221 +
1.222 + attrs={
1.223 + "class" : "event-day-content event-day-busy %s" % event_day_type,
1.224 + "colspan" : str(colspan)
1.225 + }
1.226 +
1.227 + if not (starts_today and ends_today):
1.228 + attrs["style"] = hide_text and hidden_style or style
1.229 +
1.230 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.231 +
1.232 + # Output the event.
1.233 +
1.234 + if starts_today and ends_today or not hide_text:
1.235 +
1.236 + output.append(fmt.div(on=1, css_class="event-summary-box"))
1.237 + output.append(fmt.div(on=1, css_class="event-summary", style=style))
1.238 + output.append(linkToPage(request, event_page, event_summary))
1.239 + output.append(fmt.div(on=0))
1.240 +
1.241 + # Add a pop-up element for long summaries.
1.242 +
1.243 + output.append(fmt.div(on=1, css_class="event-summary-popup", style=style))
1.244 + output.append(linkToPage(request, event_page, event_summary))
1.245 + output.append(fmt.div(on=0))
1.246 +
1.247 + output.append(fmt.div(on=0))
1.248 +
1.249 + # Output end of day content.
1.250 +
1.251 output.append(fmt.div(on=0))
1.252
1.253 - # Add a pop-up element for long summaries.
1.254 -
1.255 - output.append(fmt.div(on=1, css_class="event-summary-popup", style=style))
1.256 - output.append(linkToPage(request, event_page, event_summary))
1.257 - output.append(fmt.div(on=0))
1.258 + # Output end of day gap.
1.259
1.260 - else:
1.261 - output.append(fmt.div(on=1, css_class=(" ".join(css_classes)), style=hidden_style))
1.262 - output.append(fmt.text(event_summary))
1.263 - output.append(fmt.div(on=0))
1.264 -
1.265 - output.append(fmt.div(on=0))
1.266 + if ends_today and not starts_today:
1.267 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-end-gap"}))
1.268 + output.append(fmt.table_cell(on=0))
1.269
1.270 # End of day.
1.271
1.272 @@ -447,6 +553,24 @@
1.273
1.274 output.append(fmt.table_row(on=0))
1.275
1.276 + # Add a spacer.
1.277 +
1.278 + output.append(fmt.table_row(on=1))
1.279 +
1.280 + for weekday in range(0, 7):
1.281 + day = first_day + weekday
1.282 + css_classes = "event-day-spacer"
1.283 +
1.284 + # Skip out-of-month days.
1.285 +
1.286 + if day < 1 or day > number_of_days:
1.287 + css_classes += " event-day-excluded"
1.288 +
1.289 + output.append(fmt.table_cell(on=1, attrs={"class" : css_classes, "colspan" : "3"}))
1.290 + output.append(fmt.table_cell(on=0))
1.291 +
1.292 + output.append(fmt.table_row(on=0))
1.293 +
1.294 # Process the next week...
1.295
1.296 first_day += 7