1.1 --- a/EventAggregatorSupport.py Sun Nov 18 19:22:17 2012 +0100
1.2 +++ b/EventAggregatorSupport.py Sun Nov 18 21:16:00 2012 +0100
1.3 @@ -1280,8 +1280,8 @@
1.4
1.5 def __init__(self, page, calendar_name, raw_calendar_start, raw_calendar_end,
1.6 original_calendar_start, original_calendar_end, calendar_start, calendar_end,
1.7 - first, last, category_names, remote_sources, template_name, parent_name, mode,
1.8 - resolution, name_usage, map_name):
1.9 + first, last, category_names, remote_sources, search_pattern, template_name,
1.10 + parent_name, mode, resolution, name_usage, map_name):
1.11
1.12 """
1.13 Initialise the view with the current 'page', a 'calendar_name' (which
1.14 @@ -1294,9 +1294,9 @@
1.15 navigation in the user interface), along with the 'first' and 'last'
1.16 months of event coverage.
1.17
1.18 - The additional 'category_names', 'remote_sources', 'template_name',
1.19 - 'parent_name' and 'mode' parameters are used to configure the links
1.20 - employed by the view.
1.21 + The additional 'category_names', 'remote_sources', 'search_pattern',
1.22 + 'template_name', 'parent_name' and 'mode' parameters are used to
1.23 + configure the links employed by the view.
1.24
1.25 The 'resolution' affects the view for certain modes and is also used to
1.26 parameterise links.
1.27 @@ -1323,8 +1323,11 @@
1.28 self.name_usage = name_usage
1.29 self.map_name = map_name
1.30
1.31 + # Search-related parameters for links.
1.32 +
1.33 self.category_name_parameters = "&".join([("category=%s" % name) for name in category_names])
1.34 self.remote_source_parameters = "&".join([("source=%s" % source) for source in remote_sources])
1.35 + self.search_pattern = search_pattern
1.36
1.37 # Calculate the duration in terms of the highest common unit of time.
1.38
1.39 @@ -1449,6 +1452,7 @@
1.40 ("template", self.template_name or ""),
1.41 ("names", self.name_usage),
1.42 ("map", self.map_name or ""),
1.43 + ("search", self.search_pattern or ""),
1.44 ]
1.45
1.46 url = self.page.url(self.page.request,
1.47 @@ -1557,9 +1561,10 @@
1.48
1.49 # Generate the links.
1.50
1.51 - download_dialogue_link = "action=EventAggregatorSummary&parent=%s&resolution=%s%s%s" % (
1.52 + download_dialogue_link = "action=EventAggregatorSummary&parent=%s&resolution=%s&search=%s%s%s" % (
1.53 self.parent_name or "",
1.54 self.resolution,
1.55 + self.search_pattern,
1.56 self.category_name_parameters and "&%s" % self.category_name_parameters,
1.57 self.remote_source_parameters and "&%s" % self.remote_source_parameters
1.58 )
1.59 @@ -3220,6 +3225,31 @@
1.60 </script>
1.61 """
1.62
1.63 +# Event selection from request parameters.
1.64 +
1.65 +def getEventsUsingParameters(category_names, search_pattern, remote_sources,
1.66 + calendar_start, calendar_end, resolution, request):
1.67 +
1.68 + "Get the events according to the resolution of the calendar."
1.69 +
1.70 + if search_pattern:
1.71 + results = getPagesForSearch(search_pattern, request)
1.72 + else:
1.73 + results = []
1.74 +
1.75 + results += getAllCategoryPages(category_names, request)
1.76 + pages = getPagesFromResults(results, request)
1.77 + events = getEventsFromResources(getEventPages(pages))
1.78 + events += getEventsFromResources(getEventResources(remote_sources, calendar_start, calendar_end, request))
1.79 + all_shown_events = getEventsInPeriod(events, getCalendarPeriod(calendar_start, calendar_end))
1.80 + earliest, latest = getEventLimits(all_shown_events)
1.81 +
1.82 + # Get a concrete period of time.
1.83 +
1.84 + first, last = getConcretePeriod(calendar_start, calendar_end, earliest, latest, resolution)
1.85 +
1.86 + return all_shown_events, first, last
1.87 +
1.88 # Event-only formatting.
1.89
1.90 def formatEvent(event, request, fmt, write=None):
2.1 --- a/README.txt Sun Nov 18 19:22:17 2012 +0100
2.2 +++ b/README.txt Sun Nov 18 21:16:00 2012 +0100
2.3 @@ -180,6 +180,13 @@
2.4 remote Web sites, provided that these sources have been defined in the event
2.5 sources dictionary.
2.6
2.7 +To use a search pattern, use the search parameter and specify the search
2.8 +criteria just as you would when using the standard search macros:
2.9 +
2.10 + <<EventAggregator(search="title:MonthCalendarEvents/")>>
2.11 +
2.12 +This will aggregate events found on subpages of the MonthCalendarEvents page.
2.13 +
2.14 See pages/HelpOnEventAggregator for more detailed information.
2.15
2.16 Using the Actions
2.17 @@ -329,6 +336,9 @@
2.18 * Added an event parser that can format special page regions in different
2.19 ways and support links directly to such regions.
2.20 * Permitted Wiki markup in the description and location metadata.
2.21 + * Added support for search patterns so that event pages can be obtained
2.22 + through arbitrary searches and do not have to belong to particular
2.23 + categories.
2.24
2.25 New in EventAggregator 0.8.5 (Changes since EventAggregator 0.8.4)
2.26 ------------------------------------------------------------------
3.1 --- a/actions/EventAggregatorSummary.py Sun Nov 18 19:22:17 2012 +0100
3.2 +++ b/actions/EventAggregatorSummary.py Sun Nov 18 21:16:00 2012 +0100
3.3 @@ -104,6 +104,8 @@
3.4 "category_list" : "\n".join(category_list),
3.5 "sources_label" : escape(_("Sources")),
3.6 "sources_list" : "\n".join(sources_list),
3.7 + "search_label" : escape(_("Search pattern")),
3.8 + "search_default" : escattr(form.get("search", [""])[0]),
3.9 "start_month_list" : "\n".join(start_month_list),
3.10 "start_label" : escape(_("Start day (optional), month and year")),
3.11 "start_day_default" : escattr(start_day_default),
3.12 @@ -133,6 +135,12 @@
3.13 <input name="resolution" type="hidden" value="%(resolution)s" />
3.14 <table>
3.15 <tr>
3.16 + <td class="label"><label>%(search_label)s</label></td>
3.17 + <td class="content">
3.18 + <input name="search" type="text" value="%(search_default)s" size="40" />
3.19 + </td>
3.20 + </tr>
3.21 + <tr>
3.22 <td class="label"><label>%(category_label)s</label></td>
3.23 <td class="content">
3.24 <select multiple="multiple" name="category">
3.25 @@ -225,11 +233,12 @@
3.26 # If no category names or sources exist in the request, an error message
3.27 # is returned.
3.28
3.29 - category_names = form.get("category", [])
3.30 - sources = form.get("source", [])
3.31 + category_names = form.get("category")
3.32 + sources = form.get("source")
3.33 + search_pattern = form.get("search")
3.34
3.35 - if not (category_names or sources):
3.36 - return 0, _("No categories or sources specified.")
3.37 + if not (category_names or sources or search_pattern):
3.38 + return 0, _("No categories, sources or search patterns specified.")
3.39
3.40 write_resource(self.request)
3.41 return 1, None
3.42 @@ -257,6 +266,7 @@
3.43
3.44 category_names = form.get("category", [])
3.45 remote_sources = form.get("source", [])
3.46 + search_pattern = form.get("search", [None])[0]
3.47 format = form.get("format", ["iCalendar"])[0]
3.48 descriptions = form.get("descriptions", ["page"])[0]
3.49 parent = form.get("parent", [""])[0]
3.50 @@ -286,11 +296,11 @@
3.51
3.52 # Determine the period and get the events involved.
3.53
3.54 - pages = getPagesFromResults(getAllCategoryPages(category_names, request), request)
3.55 - events = getEventsFromResources(getEventPages(pages))
3.56 - events += getEventsFromResources(getEventResources(remote_sources, calendar_start, calendar_end, request))
3.57 - all_shown_events = getEventsInPeriod(events, getCalendarPeriod(calendar_start, calendar_end))
3.58 - latest_timestamp = getLatestEventTimestamp(all_shown_events)
3.59 + all_shown_events, first, last = getEventsUsingParameters(
3.60 + category_names, search_pattern, remote_sources, calendar_start, calendar_end,
3.61 + resolution, request)
3.62 +
3.63 + latest_timestamp = getLatestEventTimestamp(all_shown_events)
3.64
3.65 # Output summary data...
3.66
4.1 --- a/actions/EventAggregatorUpdate.py Sun Nov 18 19:22:17 2012 +0100
4.2 +++ b/actions/EventAggregatorUpdate.py Sun Nov 18 21:16:00 2012 +0100
4.3 @@ -30,6 +30,7 @@
4.4
4.5 calendar_name = form.get("calendar", [None])[0]
4.6 category_names = form.get("category", [])
4.7 + search_pattern = form.get("search", [None])[0]
4.8 remote_sources = form.get("source", [])
4.9 name_usage = getParameter(request, "names", "weekly")
4.10 template_name = getParameter(request, "template")
4.11 @@ -63,22 +64,16 @@
4.12
4.13 # Get the events according to the resolution of the calendar.
4.14
4.15 - pages = getPagesFromResults(getAllCategoryPages(category_names, request), request)
4.16 - events = getEventsFromResources(getEventPages(pages))
4.17 - events += getEventsFromResources(getEventResources(remote_sources, calendar_start, calendar_end, request))
4.18 - all_shown_events = getEventsInPeriod(events, getCalendarPeriod(calendar_start, calendar_end))
4.19 - earliest, latest = getEventLimits(all_shown_events)
4.20 -
4.21 - # Get a concrete period of time.
4.22 -
4.23 - first, last = getConcretePeriod(calendar_start, calendar_end, earliest, latest, resolution)
4.24 + all_shown_events, first, last = getEventsUsingParameters(
4.25 + category_names, search_pattern, remote_sources, calendar_start, calendar_end,
4.26 + resolution, request)
4.27
4.28 # Define a view of the calendar, retaining useful navigational information.
4.29
4.30 view = View(page, calendar_name, raw_calendar_start, raw_calendar_end,
4.31 original_calendar_start, original_calendar_end, calendar_start, calendar_end,
4.32 - first, last, category_names, remote_sources, template_name, parent_name,
4.33 - mode, resolution, name_usage, map_name)
4.34 + first, last, category_names, remote_sources, search_pattern, template_name,
4.35 + parent_name, mode, resolution, name_usage, map_name)
4.36
4.37 send_headers = get_send_headers(request)
4.38 send_headers(["Content-Type: text/html; charset=%s" % config.charset])
5.1 --- a/macros/EventAggregator.py Sun Nov 18 19:22:17 2012 +0100
5.2 +++ b/macros/EventAggregator.py Sun Nov 18 21:16:00 2012 +0100
5.3 @@ -77,6 +77,7 @@
5.4
5.5 category_names = []
5.6 remote_sources = []
5.7 + search_pattern = None
5.8 raw_calendar_start = None
5.9 raw_calendar_end = None
5.10 calendar_start = None
5.11 @@ -116,6 +117,9 @@
5.12 elif arg.startswith("source="):
5.13 remote_sources.append(arg[7:])
5.14
5.15 + elif arg.startswith("search="):
5.16 + search_pattern = arg[7:]
5.17 +
5.18 else:
5.19 category_names.append(arg)
5.20
5.21 @@ -145,22 +149,16 @@
5.22
5.23 # Get the events according to the resolution of the calendar.
5.24
5.25 - pages = getPagesFromResults(getAllCategoryPages(category_names, request), request)
5.26 - events = getEventsFromResources(getEventPages(pages))
5.27 - events += getEventsFromResources(getEventResources(remote_sources, calendar_start, calendar_end, request))
5.28 - all_shown_events = getEventsInPeriod(events, getCalendarPeriod(calendar_start, calendar_end))
5.29 - earliest, latest = getEventLimits(all_shown_events)
5.30 -
5.31 - # Get a concrete period of time.
5.32 -
5.33 - first, last = getConcretePeriod(calendar_start, calendar_end, earliest, latest, resolution)
5.34 + all_shown_events, first, last = getEventsUsingParameters(
5.35 + category_names, search_pattern, remote_sources, calendar_start, calendar_end,
5.36 + resolution, request)
5.37
5.38 # Define a view of the calendar, retaining useful navigational information.
5.39
5.40 view = View(page, calendar_name, raw_calendar_start, raw_calendar_end,
5.41 original_calendar_start, original_calendar_end, calendar_start, calendar_end,
5.42 - first, last, category_names, remote_sources, template_name, parent_name,
5.43 - mode, resolution, name_usage, map_name)
5.44 + first, last, category_names, remote_sources, search_pattern, template_name,
5.45 + parent_name, mode, resolution, name_usage, map_name)
5.46
5.47 return view.render(all_shown_events)
5.48
6.1 --- a/pages/HelpOnEventAggregator Sun Nov 18 19:22:17 2012 +0100
6.2 +++ b/pages/HelpOnEventAggregator Sun Nov 18 21:16:00 2012 +0100
6.3 @@ -17,7 +17,7 @@
6.4
6.5 The easiest way to create an event is to hover over a day number in a calendar and to follow the "New event" link, or if the calendar is being shown as a list, map or table, to select the "New event" link below the calendar content. If you do not have a calendar set up, take a look at the instructions for [[#PreparingACalendar|preparing]] and [[#ShowingEventCalendars|showing]] calendars first.
6.6
6.7 -Each event must be created on a new page belonging to the appropriate event category. The following action can be used to create a new event page (using [[HelpOnEventAggregatorNewEvent|EventAggregatorNewEvent]]) without looking at a calendar:
6.8 +Each event must be created on a new page belonging to the appropriate event category, if the calendar has been configured to only look for events in particular categories. The following action can be used to create a new event page (using [[HelpOnEventAggregatorNewEvent|EventAggregatorNewEvent]]) without looking at a calendar:
6.9
6.10 (!) <<Action(EventAggregatorNewEvent,Add an event)>>
6.11
6.12 @@ -142,9 +142,15 @@
6.13 <<Anchor(PreparingACalendar)>>
6.14 == Preparing a Calendar ==
6.15
6.16 -Before trying to show a calendar or trying to create any events, you must either decide on a category for your events or on an event source which will provide events to the Wiki. Or you can choose to show a calendar based on both categories and event sources.
6.17 +Before trying to show a calendar or trying to create any events, you must decide on where those events will come from. This can be one or more of the following:
6.18
6.19 -You can create a new category for the purpose of managing events by filling out and submitting this form:
6.20 + * A category in the Wiki containing pages for your events
6.21 + * An event source which will provide events to the Wiki
6.22 + * Pages that can be found using a particular search pattern
6.23 +
6.24 +You can choose to show a calendar based on categories, event sources and a search pattern, obtaining events from each of these things and combining them into a single view.
6.25 +
6.26 +If you decide to organise your events using categories, you can create a new category for the purpose of managing events by filling out and submitting this form:
6.27
6.28 <<NewPage(CategoryTemplate,Add a new category,,Category%s)>>
6.29
6.30 @@ -175,6 +181,15 @@
6.31 <<EventAggregator(source=GriCal,source=FSFE)>>
6.32 }}}
6.33
6.34 +To use a search pattern instead of categories or sources, specify it using the `search` parameter. For example:
6.35 +
6.36 +{{{
6.37 +## Show events in pages below the MonthCalendarEvents page.
6.38 +<<EventAggregator(search="title:MonthCalendarEvents/")>>
6.39 +}}}
6.40 +
6.41 +This example lets !EventAggregator behave somewhat like the [[HelpOnMacros/MonthCalendar|MonthCalendar]] macro, although new events created using the "New event" link do not currently create appropriately named pages.
6.42 +
6.43 Categories can be combined with sources, thus aggregating "internal" and "external" events:
6.44
6.45 {{{