1.1 --- a/EventAggregatorSupport.py Fri Oct 30 20:36:04 2009 +0100
1.2 +++ b/EventAggregatorSupport.py Sat Oct 31 01:24:06 2009 +0100
1.3 @@ -277,12 +277,16 @@
1.4 else:
1.5 return body
1.6
1.7 -def getEventSummary(event_page, event_details):
1.8 +def getEventSummary(event_page, event_details, event_parent=None):
1.9
1.10 """
1.11 Return either the given title or summary of the event described by the given
1.12 'event_page', according to the given 'event_details', or return the pretty
1.13 version of the page name.
1.14 +
1.15 + If the optional 'event_parent' is specified, any page beneath the given
1.16 + 'event_parent' page in the page hierarchy will omit this parent information
1.17 + if its name is used as the summary.
1.18 """
1.19
1.20 if event_details.has_key("title"):
1.21 @@ -290,7 +294,14 @@
1.22 elif event_details.has_key("summary"):
1.23 return event_details["summary"]
1.24 else:
1.25 - return getPrettyPageName(event_page)
1.26 + # If appropriate, remove the parent details and "/" character.
1.27 +
1.28 + title = event_page.page_name
1.29 +
1.30 + if event_parent is not None and title.startswith(event_parent):
1.31 + title = title[len(event_parent.rstrip("/")) + 1:]
1.32 +
1.33 + return getPrettyTitle(title)
1.34
1.35 def getDate(s):
1.36
1.37 @@ -679,8 +690,8 @@
1.38
1.39 # User interface functions.
1.40
1.41 -def getParameter(request, name):
1.42 - return request.form.get(name, [None])[0]
1.43 +def getParameter(request, name, default=None):
1.44 + return request.form.get(name, [default])[0]
1.45
1.46 def getParameterMonth(arg):
1.47 n = None
1.48 @@ -737,6 +748,12 @@
1.49 else:
1.50 title = page.split_title(force=1)
1.51
1.52 + return getPrettyTitle(title)
1.53 +
1.54 +def getPrettyTitle(title):
1.55 +
1.56 + "Return a nicely formatted version of the given 'title'."
1.57 +
1.58 return title.replace("_", " ").replace("/", u" » ")
1.59
1.60 def getMonthLabel(month):
2.1 --- a/actions/EventAggregatorNewEvent.py Fri Oct 30 20:36:04 2009 +0100
2.2 +++ b/actions/EventAggregatorNewEvent.py Sat Oct 31 01:24:06 2009 +0100
2.3 @@ -82,7 +82,7 @@
2.4 "start_label" : _("Start date (day, month, year)"),
2.5 "start_day_default" : form.get("start-day", [""])[0],
2.6 "start_year_default" : form.get("start-year", [""])[0] or EventAggregatorSupport.getCurrentYear(),
2.7 - "end_label" : _("End date (day, month, year)"),
2.8 + "end_label" : _("End date (day, month, year) - if different"),
2.9 "end_day_default" : form.get("end-day", [""])[0],
2.10 "end_year_default" : form.get("end-year", [""])[0],
2.11 "title_label" : _("Event title/summary"),
2.12 @@ -91,6 +91,8 @@
2.13 "description_default" : form.get("description", [""])[0],
2.14 "template_label" : _("Event template"),
2.15 "template_default" : form.get("template", [""])[0] or template_default,
2.16 + "parent_label" : _("Parent page"),
2.17 + "parent_default" : form.get("parent", [""])[0],
2.18 }
2.19
2.20 return '''
2.21 @@ -142,6 +144,12 @@
2.22 </td>
2.23 </tr>
2.24 <tr>
2.25 + <td class="label"><label>%(parent_label)s</label></td>
2.26 + <td>
2.27 + <input name="parent" type="text" size="40" value="%(parent_default)s" />
2.28 + </td>
2.29 + </tr>
2.30 + <tr>
2.31 <td></td>
2.32 <td class="buttons">
2.33 %(buttons_html)s
2.34 @@ -193,6 +201,7 @@
2.35 try:
2.36 title = form["title"][0]
2.37 template = form["template"][0]
2.38 + parent = form["parent"][0]
2.39
2.40 start_day = self._get_input(form, "start-day", 0)
2.41 start_month = self._get_input(form, "start-month", 0)
2.42 @@ -222,6 +231,11 @@
2.43
2.44 body = page.get_raw_body()
2.45
2.46 + # Use any parent page information.
2.47 +
2.48 + if parent:
2.49 + title = "%s/%s" % (parent.rstrip("/"), title)
2.50 +
2.51 # Load the new page and replace the event details in the body.
2.52
2.53 new_page = PageEditor(request, title)
3.1 --- a/css/event-aggregator.css Fri Oct 30 20:36:04 2009 +0100
3.2 +++ b/css/event-aggregator.css Sat Oct 31 01:24:06 2009 +0100
3.3 @@ -183,12 +183,17 @@
3.4 top: 0;
3.5 z-index: 2;
3.6 padding: 0.75em 0.25em 0.75em 0.25em;
3.7 + margin-right: 0.5em;
3.8 }
3.9
3.10 .event-summary-box:hover > .event-summary-popup {
3.11 display: block;
3.12 }
3.13
3.14 +.event-summary-box:hover > .event-summary a {
3.15 + visibility: hidden;
3.16 +}
3.17 +
3.18 /* Day spacers. */
3.19
3.20 .event-day-spacer {
4.1 --- a/macros/EventAggregator.py Fri Oct 30 20:36:04 2009 +0100
4.2 +++ b/macros/EventAggregator.py Sat Oct 31 01:24:06 2009 +0100
4.3 @@ -181,6 +181,12 @@
4.4
4.5 calendar=NAME uses the given NAME to provide request parameters which
4.6 can be used to control the calendar view
4.7 +
4.8 + template=PAGE uses the given PAGE as the default template for new
4.9 + events (or the default template from the configuration
4.10 + if not specified)
4.11 +
4.12 + parent=PAGE uses the given PAGE as the parent of any new event page
4.13 """
4.14
4.15 request = macro.request
4.16 @@ -205,6 +211,8 @@
4.17 mode = "calendar"
4.18 name_usage = "weekly"
4.19 calendar_name = None
4.20 + template_name = getattr(request.cfg, "event_aggregator_new_event_template", "EventTemplate")
4.21 + parent_name = None
4.22
4.23 for arg in parsed_args:
4.24 if arg.startswith("start="):
4.25 @@ -222,6 +230,12 @@
4.26 elif arg.startswith("calendar="):
4.27 calendar_name = arg[9:]
4.28
4.29 + elif arg.startswith("template="):
4.30 + template_name = arg[9:]
4.31 +
4.32 + elif arg.startswith("parent="):
4.33 + parent_name = arg[7:]
4.34 +
4.35 else:
4.36 category_names.append(arg)
4.37
4.38 @@ -231,6 +245,10 @@
4.39 calendar_start = EventAggregatorSupport.getFormMonth(request, calendar_name, "start") or calendar_start
4.40 calendar_end = EventAggregatorSupport.getFormMonth(request, calendar_name, "end") or calendar_end
4.41
4.42 + # HTML link fragments.
4.43 +
4.44 + category_name_parameters = "&".join([("category=%s" % name) for name in category_names])
4.45 +
4.46 # Get the events.
4.47
4.48 events, shown_events, all_shown_events, earliest, latest = \
4.49 @@ -250,9 +268,7 @@
4.50
4.51 # Output download controls.
4.52
4.53 - download_all_link = "action=EventAggregatorSummary&doit=1&%s" % (
4.54 - "&".join([("category=%s" % name) for name in category_names])
4.55 - )
4.56 + download_all_link = "action=EventAggregatorSummary&doit=1&%s" % category_name_parameters
4.57 download_link = download_all_link + ("&%s&%s" % (
4.58 getMonthActionQueryString("start", calendar_start),
4.59 getMonthActionQueryString("end", calendar_end)
4.60 @@ -382,8 +398,9 @@
4.61
4.62 # Make a link to a new event action.
4.63
4.64 - new_event_link = "action=EventAggregatorNewEvent&start-day=%d&start-month=%d&start-year=%d" % (
4.65 - day, month, year)
4.66 + new_event_link = "action=EventAggregatorNewEvent&start-day=%d&start-month=%d&start-year=%d" \
4.67 + "&%s&template=%s&parent=%s" % (
4.68 + day, month, year, category_name_parameters, template_name, parent_name or "")
4.69
4.70 # Output the day number.
4.71
4.72 @@ -464,7 +481,7 @@
4.73
4.74 starts_today = event_details["start"] == date
4.75 ends_today = event_details["end"] == date
4.76 - event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details)
4.77 + event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details, parent_name)
4.78
4.79 # Generate a colour for the event.
4.80
4.81 @@ -669,7 +686,7 @@
4.82 # Show the events in order.
4.83
4.84 for event_page, event_details in ordered_events:
4.85 - event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details)
4.86 + event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details, parent_name)
4.87
4.88 output.append(fmt.listitem(on=1, attr={"class" : "event-listing"}))
4.89
4.90 @@ -725,7 +742,7 @@
4.91 # Show the events in order.
4.92
4.93 for event_page, event_details in ordered_events:
4.94 - event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details)
4.95 + event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details, parent_name)
4.96
4.97 # Prepare CSS classes with category-related styling.
4.98
5.1 --- a/pages/HelpOnEventAggregator Fri Oct 30 20:36:04 2009 +0100
5.2 +++ b/pages/HelpOnEventAggregator Sat Oct 31 01:24:06 2009 +0100
5.3 @@ -116,6 +116,24 @@
5.4
5.5 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.
5.6
5.7 +=== Assigning Templates and Parent Pages ===
5.8 +
5.9 +New events can be added to a calendar by following the links on each of the day numbers; this opens the form provided by the !EventAggregatorNewEvent action. For all events belonging to a particular calendar, it can be convenient to assign a default template page, so that the information provided by such events is consistent. Thus, it is possible to specify such a template page using the `template` parameter. For example:
5.10 +
5.11 +{{{
5.12 +## Specify a particular template page as the default event page template.
5.13 +<<EventAggregator(CategoryEvents,template=SpecialEventTemplate)>>
5.14 +}}}
5.15 +
5.16 +It can also be convenient to add new event pages under a common parent page. This can be achieved by specifying such a page using the `parent` parameter. For example:
5.17 +
5.18 +{{{
5.19 +## Specify a particular parent page as the default container for new events.
5.20 +<<EventAggregator(CategoryEvents,parent=Events)>>
5.21 +}}}
5.22 +
5.23 +Creating an event called '''Meeting''' under a parent called '''Events''' will make the page '''Events/Meeting''', and this will be shown as '''Meeting''' in the calendar. However, if a different parent is chosen, such as '''Meetings''', then the full path to the page will be shown in the calendar: '''Meetings » Meeting'''.
5.24 +
5.25 == Showing Event Lists and Tables ==
5.26
5.27 A more plain view of events can be displayed by specifying the `mode` parameter as follows:
6.1 --- a/pages/HelpOnEventAggregatorNewEvent Fri Oct 30 20:36:04 2009 +0100
6.2 +++ b/pages/HelpOnEventAggregatorNewEvent Sat Oct 31 01:24:06 2009 +0100
6.3 @@ -19,7 +19,13 @@
6.4
6.5 /!\ If no changes are made to the new page during editing and the editing process is cancelled, the new page will still exist. Event pages created in error should therefore be deleted manually.
6.6
6.7 -A technical note: new event pages are derived from the EventTemplate page by default; this can be overridden by setting the `event_aggregator_new_event_template` configuration setting for the Wiki.
6.8 +== Categories and Templates ==
6.9 +
6.10 +If the action has been invoked by following a link from a calendar, then the default categories assigned to a new event are derived from those used to present events in the calendar. Otherwise, no categories are selected by default for a new event.
6.11 +
6.12 +New event pages are derived from a particular template page. If the action has been invoked by a link provided by a calendar, the `template` parameter of the !EventAggregator macro may specify the default template page for the new event. If no such parameter was used for the calendar, or if no calendar was involved (such as when the action is invoked from the editing menu), the EventTemplate page is chosen to be the default template page for the event.
6.13 +
6.14 +A technical note: this underlying default setting (the use of EventTemplate) can be changed by setting or editing the `event_aggregator_new_event_template` configuration setting for the Wiki.
6.15
6.16 == See Also ==
6.17