# HG changeset patch # User Paul Boddie # Date 1256948646 -3600 # Node ID 1840106b3f875def58046cb63e55014e70be4de8 # Parent df75a72e54fe2c226a38c9cea05c88e10da82af2 Added parent page and template default support. Made new events assume the categories of the calendar in which they were created, at least by default. Fixed the styles for pop-up elements, avoiding re-wrapping and hiding the original link text. Updated the help pages. diff -r df75a72e54fe -r 1840106b3f87 EventAggregatorSupport.py --- a/EventAggregatorSupport.py Fri Oct 30 20:36:04 2009 +0100 +++ b/EventAggregatorSupport.py Sat Oct 31 01:24:06 2009 +0100 @@ -277,12 +277,16 @@ else: return body -def getEventSummary(event_page, event_details): +def getEventSummary(event_page, event_details, event_parent=None): """ Return either the given title or summary of the event described by the given 'event_page', according to the given 'event_details', or return the pretty version of the page name. + + If the optional 'event_parent' is specified, any page beneath the given + 'event_parent' page in the page hierarchy will omit this parent information + if its name is used as the summary. """ if event_details.has_key("title"): @@ -290,7 +294,14 @@ elif event_details.has_key("summary"): return event_details["summary"] else: - return getPrettyPageName(event_page) + # If appropriate, remove the parent details and "/" character. + + title = event_page.page_name + + if event_parent is not None and title.startswith(event_parent): + title = title[len(event_parent.rstrip("/")) + 1:] + + return getPrettyTitle(title) def getDate(s): @@ -679,8 +690,8 @@ # User interface functions. -def getParameter(request, name): - return request.form.get(name, [None])[0] +def getParameter(request, name, default=None): + return request.form.get(name, [default])[0] def getParameterMonth(arg): n = None @@ -737,6 +748,12 @@ else: title = page.split_title(force=1) + return getPrettyTitle(title) + +def getPrettyTitle(title): + + "Return a nicely formatted version of the given 'title'." + return title.replace("_", " ").replace("/", u" » ") def getMonthLabel(month): diff -r df75a72e54fe -r 1840106b3f87 actions/EventAggregatorNewEvent.py --- a/actions/EventAggregatorNewEvent.py Fri Oct 30 20:36:04 2009 +0100 +++ b/actions/EventAggregatorNewEvent.py Sat Oct 31 01:24:06 2009 +0100 @@ -82,7 +82,7 @@ "start_label" : _("Start date (day, month, year)"), "start_day_default" : form.get("start-day", [""])[0], "start_year_default" : form.get("start-year", [""])[0] or EventAggregatorSupport.getCurrentYear(), - "end_label" : _("End date (day, month, year)"), + "end_label" : _("End date (day, month, year) - if different"), "end_day_default" : form.get("end-day", [""])[0], "end_year_default" : form.get("end-year", [""])[0], "title_label" : _("Event title/summary"), @@ -91,6 +91,8 @@ "description_default" : form.get("description", [""])[0], "template_label" : _("Event template"), "template_default" : form.get("template", [""])[0] or template_default, + "parent_label" : _("Parent page"), + "parent_default" : form.get("parent", [""])[0], } return ''' @@ -142,6 +144,12 @@ + + + + + + %(buttons_html)s @@ -193,6 +201,7 @@ try: title = form["title"][0] template = form["template"][0] + parent = form["parent"][0] start_day = self._get_input(form, "start-day", 0) start_month = self._get_input(form, "start-month", 0) @@ -222,6 +231,11 @@ body = page.get_raw_body() + # Use any parent page information. + + if parent: + title = "%s/%s" % (parent.rstrip("/"), title) + # Load the new page and replace the event details in the body. new_page = PageEditor(request, title) diff -r df75a72e54fe -r 1840106b3f87 css/event-aggregator.css --- a/css/event-aggregator.css Fri Oct 30 20:36:04 2009 +0100 +++ b/css/event-aggregator.css Sat Oct 31 01:24:06 2009 +0100 @@ -183,12 +183,17 @@ top: 0; z-index: 2; padding: 0.75em 0.25em 0.75em 0.25em; + margin-right: 0.5em; } .event-summary-box:hover > .event-summary-popup { display: block; } +.event-summary-box:hover > .event-summary a { + visibility: hidden; +} + /* Day spacers. */ .event-day-spacer { diff -r df75a72e54fe -r 1840106b3f87 macros/EventAggregator.py --- a/macros/EventAggregator.py Fri Oct 30 20:36:04 2009 +0100 +++ b/macros/EventAggregator.py Sat Oct 31 01:24:06 2009 +0100 @@ -181,6 +181,12 @@ calendar=NAME uses the given NAME to provide request parameters which can be used to control the calendar view + + template=PAGE uses the given PAGE as the default template for new + events (or the default template from the configuration + if not specified) + + parent=PAGE uses the given PAGE as the parent of any new event page """ request = macro.request @@ -205,6 +211,8 @@ mode = "calendar" name_usage = "weekly" calendar_name = None + template_name = getattr(request.cfg, "event_aggregator_new_event_template", "EventTemplate") + parent_name = None for arg in parsed_args: if arg.startswith("start="): @@ -222,6 +230,12 @@ elif arg.startswith("calendar="): calendar_name = arg[9:] + elif arg.startswith("template="): + template_name = arg[9:] + + elif arg.startswith("parent="): + parent_name = arg[7:] + else: category_names.append(arg) @@ -231,6 +245,10 @@ calendar_start = EventAggregatorSupport.getFormMonth(request, calendar_name, "start") or calendar_start calendar_end = EventAggregatorSupport.getFormMonth(request, calendar_name, "end") or calendar_end + # HTML link fragments. + + category_name_parameters = "&".join([("category=%s" % name) for name in category_names]) + # Get the events. events, shown_events, all_shown_events, earliest, latest = \ @@ -250,9 +268,7 @@ # Output download controls. - download_all_link = "action=EventAggregatorSummary&doit=1&%s" % ( - "&".join([("category=%s" % name) for name in category_names]) - ) + download_all_link = "action=EventAggregatorSummary&doit=1&%s" % category_name_parameters download_link = download_all_link + ("&%s&%s" % ( getMonthActionQueryString("start", calendar_start), getMonthActionQueryString("end", calendar_end) @@ -382,8 +398,9 @@ # Make a link to a new event action. - new_event_link = "action=EventAggregatorNewEvent&start-day=%d&start-month=%d&start-year=%d" % ( - day, month, year) + new_event_link = "action=EventAggregatorNewEvent&start-day=%d&start-month=%d&start-year=%d" \ + "&%s&template=%s&parent=%s" % ( + day, month, year, category_name_parameters, template_name, parent_name or "") # Output the day number. @@ -464,7 +481,7 @@ starts_today = event_details["start"] == date ends_today = event_details["end"] == date - event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details) + event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details, parent_name) # Generate a colour for the event. @@ -669,7 +686,7 @@ # Show the events in order. for event_page, event_details in ordered_events: - event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details) + event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details, parent_name) output.append(fmt.listitem(on=1, attr={"class" : "event-listing"})) @@ -725,7 +742,7 @@ # Show the events in order. for event_page, event_details in ordered_events: - event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details) + event_summary = EventAggregatorSupport.getEventSummary(event_page, event_details, parent_name) # Prepare CSS classes with category-related styling. diff -r df75a72e54fe -r 1840106b3f87 pages/HelpOnEventAggregator --- a/pages/HelpOnEventAggregator Fri Oct 30 20:36:04 2009 +0100 +++ b/pages/HelpOnEventAggregator Sat Oct 31 01:24:06 2009 +0100 @@ -116,6 +116,24 @@ 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. +=== Assigning Templates and Parent Pages === + +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: + +{{{ +## Specify a particular template page as the default event page template. +<> +}}} + +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: + +{{{ +## Specify a particular parent page as the default container for new events. +<> +}}} + +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'''. + == Showing Event Lists and Tables == A more plain view of events can be displayed by specifying the `mode` parameter as follows: diff -r df75a72e54fe -r 1840106b3f87 pages/HelpOnEventAggregatorNewEvent --- a/pages/HelpOnEventAggregatorNewEvent Fri Oct 30 20:36:04 2009 +0100 +++ b/pages/HelpOnEventAggregatorNewEvent Sat Oct 31 01:24:06 2009 +0100 @@ -19,7 +19,13 @@ /!\ 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. -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. +== Categories and Templates == + +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. + +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. + +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. == See Also ==