# HG changeset patch # User Paul Boddie # Date 1353269760 -3600 # Node ID 53fa1f193ebbf90b6a89e095224e5b09e446dd78 # Parent 56b7bd844f1e528a1fc06d1c56b8ea01b031ca71 Added support for the use of conventional search patterns to aggregate events. diff -r 56b7bd844f1e -r 53fa1f193ebb EventAggregatorSupport.py --- a/EventAggregatorSupport.py Sun Nov 18 19:22:17 2012 +0100 +++ b/EventAggregatorSupport.py Sun Nov 18 21:16:00 2012 +0100 @@ -1280,8 +1280,8 @@ def __init__(self, page, calendar_name, raw_calendar_start, raw_calendar_end, original_calendar_start, original_calendar_end, calendar_start, calendar_end, - first, last, category_names, remote_sources, template_name, parent_name, mode, - resolution, name_usage, map_name): + first, last, category_names, remote_sources, search_pattern, template_name, + parent_name, mode, resolution, name_usage, map_name): """ Initialise the view with the current 'page', a 'calendar_name' (which @@ -1294,9 +1294,9 @@ navigation in the user interface), along with the 'first' and 'last' months of event coverage. - The additional 'category_names', 'remote_sources', 'template_name', - 'parent_name' and 'mode' parameters are used to configure the links - employed by the view. + The additional 'category_names', 'remote_sources', 'search_pattern', + 'template_name', 'parent_name' and 'mode' parameters are used to + configure the links employed by the view. The 'resolution' affects the view for certain modes and is also used to parameterise links. @@ -1323,8 +1323,11 @@ self.name_usage = name_usage self.map_name = map_name + # Search-related parameters for links. + self.category_name_parameters = "&".join([("category=%s" % name) for name in category_names]) self.remote_source_parameters = "&".join([("source=%s" % source) for source in remote_sources]) + self.search_pattern = search_pattern # Calculate the duration in terms of the highest common unit of time. @@ -1449,6 +1452,7 @@ ("template", self.template_name or ""), ("names", self.name_usage), ("map", self.map_name or ""), + ("search", self.search_pattern or ""), ] url = self.page.url(self.page.request, @@ -1557,9 +1561,10 @@ # Generate the links. - download_dialogue_link = "action=EventAggregatorSummary&parent=%s&resolution=%s%s%s" % ( + download_dialogue_link = "action=EventAggregatorSummary&parent=%s&resolution=%s&search=%s%s%s" % ( self.parent_name or "", self.resolution, + self.search_pattern, self.category_name_parameters and "&%s" % self.category_name_parameters, self.remote_source_parameters and "&%s" % self.remote_source_parameters ) @@ -3220,6 +3225,31 @@ """ +# Event selection from request parameters. + +def getEventsUsingParameters(category_names, search_pattern, remote_sources, + calendar_start, calendar_end, resolution, request): + + "Get the events according to the resolution of the calendar." + + if search_pattern: + results = getPagesForSearch(search_pattern, request) + else: + results = [] + + results += getAllCategoryPages(category_names, request) + pages = getPagesFromResults(results, request) + events = getEventsFromResources(getEventPages(pages)) + events += getEventsFromResources(getEventResources(remote_sources, calendar_start, calendar_end, request)) + all_shown_events = getEventsInPeriod(events, getCalendarPeriod(calendar_start, calendar_end)) + earliest, latest = getEventLimits(all_shown_events) + + # Get a concrete period of time. + + first, last = getConcretePeriod(calendar_start, calendar_end, earliest, latest, resolution) + + return all_shown_events, first, last + # Event-only formatting. def formatEvent(event, request, fmt, write=None): diff -r 56b7bd844f1e -r 53fa1f193ebb README.txt --- a/README.txt Sun Nov 18 19:22:17 2012 +0100 +++ b/README.txt Sun Nov 18 21:16:00 2012 +0100 @@ -180,6 +180,13 @@ remote Web sites, provided that these sources have been defined in the event sources dictionary. +To use a search pattern, use the search parameter and specify the search +criteria just as you would when using the standard search macros: + + <> + +This will aggregate events found on subpages of the MonthCalendarEvents page. + See pages/HelpOnEventAggregator for more detailed information. Using the Actions @@ -329,6 +336,9 @@ * Added an event parser that can format special page regions in different ways and support links directly to such regions. * Permitted Wiki markup in the description and location metadata. + * Added support for search patterns so that event pages can be obtained + through arbitrary searches and do not have to belong to particular + categories. New in EventAggregator 0.8.5 (Changes since EventAggregator 0.8.4) ------------------------------------------------------------------ diff -r 56b7bd844f1e -r 53fa1f193ebb actions/EventAggregatorSummary.py --- a/actions/EventAggregatorSummary.py Sun Nov 18 19:22:17 2012 +0100 +++ b/actions/EventAggregatorSummary.py Sun Nov 18 21:16:00 2012 +0100 @@ -104,6 +104,8 @@ "category_list" : "\n".join(category_list), "sources_label" : escape(_("Sources")), "sources_list" : "\n".join(sources_list), + "search_label" : escape(_("Search pattern")), + "search_default" : escattr(form.get("search", [""])[0]), "start_month_list" : "\n".join(start_month_list), "start_label" : escape(_("Start day (optional), month and year")), "start_day_default" : escattr(start_day_default), @@ -133,6 +135,12 @@ + + + +
+ +