# HG changeset patch # User Paul Boddie # Date 1303163002 -7200 # Node ID afddbe14481f44c74415a148bc879eff2c2359c1 # Parent 0131c3d7fe9c1f572aa700250dcb5a7d5003c615 Added the "normalisation" of locations, retrieving town/country names from the end of location strings in order to more easily match locations in the dictionary. Removed margins around print view descriptions, making slightly better use of space and aligning the numbers better with the descriptions. diff -r 0131c3d7fe9c -r afddbe14481f EventAggregatorSupport.py --- a/EventAggregatorSupport.py Mon Apr 18 01:06:30 2011 +0200 +++ b/EventAggregatorSupport.py Mon Apr 18 23:43:22 2011 +0200 @@ -50,6 +50,7 @@ # Value parsing. country_code_regexp = re.compile(ur'(?:^|\W)(?P[A-Z]{2})(?:$|\W+$)', re.UNICODE) +location_normalised_regexp = re.compile(ur"([\w-]+(?:,(?:\s*[\w-]+)+)?)$", re.UNICODE) month_regexp_str = ur'(?P[0-9]{4})-(?P[0-9]{2})' date_regexp_str = ur'(?P[0-9]{4})-(?P[0-9]{2})-(?P[0-9]{2})' @@ -308,6 +309,19 @@ return weekday_labels[weekday] +def getNormalisedLocation(location): + + """ + Attempt to return a normalised 'location' of the form ", " or + "". + """ + + match = location_normalised_regexp.search(location) + if match: + return match.group() + else: + return None + # Action support functions. def getPageRevision(page): diff -r 0131c3d7fe9c -r afddbe14481f css/event-aggregator-print.css --- a/css/event-aggregator-print.css Mon Apr 18 01:06:30 2011 +0200 +++ b/css/event-aggregator-print.css Mon Apr 18 23:43:22 2011 +0200 @@ -104,7 +104,6 @@ position: static !important; display: block; visibility: visible; - margin: 0.5em; padding: 0.5em; border: 1px solid #ddd; } diff -r 0131c3d7fe9c -r afddbe14481f macros/EventAggregator.py --- a/macros/EventAggregator.py Mon Apr 18 01:06:30 2011 +0200 +++ b/macros/EventAggregator.py Mon Apr 18 23:43:22 2011 +0200 @@ -1496,6 +1496,11 @@ event_details = event.getDetails() location = event_details.get("location") + + # Use a normalised location if possible. + + location = location and getNormalisedLocation(location) or location + if not events_by_location.has_key(location): events_by_location[location] = [] events_by_location[location].append(event)