# HG changeset patch # User Paul Boddie # Date 1302472355 -7200 # Node ID 299fbb742884ef9dc6af149f71990ea73dfe6ed5 # Parent 1e30e9b62ffc01342e36d0d2faadafff8d6fef66 Added initial support for a map view. diff -r 1e30e9b62ffc -r 299fbb742884 css/event-aggregator.css --- a/css/event-aggregator.css Sun Apr 10 23:52:09 2011 +0200 +++ b/css/event-aggregator.css Sun Apr 10 23:52:35 2011 +0200 @@ -375,5 +375,56 @@ color: #000000; } +/* Map view. */ + +.event-map { + text-align: center; +} + +.event-map-container { + display: inline-block; + position: relative; + /* image and dimensions specified in the HTML */ +} + +/* Label element and pop-up effects. */ + +.event-map-label { + position: absolute; + /* position and dimensions specified in the HTML */ + border: 2px solid #d00; +} + +.event-map-label:hover { + border: 0; +} + +.event-map-label .event-map-details { + display: none; + position: absolute; + top: 0; + left: 0; + z-index: 2; + min-width: 10em; +} + +.event-map-label:hover .event-map-details { + display: block; +} + +/* Details elements. */ + +.event-map-shadow { + background-color: #555; +} + +.event-map-description { + position: relative; + top: -8px; + left: -8px; + padding: 0.25em; + background-color: #fff; +} + /* vim: tabstop=4 expandtab shiftwidth=4 */ diff -r 1e30e9b62ffc -r 299fbb742884 macros/EventAggregator.py --- a/macros/EventAggregator.py Sun Apr 10 23:52:09 2011 +0200 +++ b/macros/EventAggregator.py Sun Apr 10 23:52:35 2011 +0200 @@ -4,11 +4,12 @@ @copyright: 2008, 2009, 2010, 2011 by Paul Boddie @copyright: 2000-2004 Juergen Hermann , - 2005-2008 MoinMoin:ThomasWaldmann. + 2005-2008 MoinMoin:ThomasWaldmann @license: GNU GPL (v2 or later), see COPYING.txt for details. """ from MoinMoin import wikiutil +from MoinMoin.action import AttachFile from EventAggregatorSupport import * import calendar @@ -1047,6 +1048,23 @@ output.append(fmt.table_cell(on=0)) return "".join(output) + def showDictError(self, text, pagename): + page = self.page + fmt = page.formatter + request = page.request + + output = [] + + output.append(fmt.div(on=1, attrs={"class" : "event-aggregator-error"})) + output.append(fmt.paragraph(on=1)) + output.append(fmt.text(text)) + output.append(fmt.paragraph(on=0)) + output.append(fmt.paragraph(on=1)) + output.append(linkToPage(request, Page(request, pagename), pagename)) + output.append(fmt.paragraph(on=0)) + + return "".join(output) + # HTML-related functions. def getColour(s): @@ -1087,9 +1105,7 @@ mode=day shows a calendar day view of events mode=list shows a list of events by month mode=table shows a table of events - - names=daily shows the name of an event on every day of that event - names=weekly shows the name of an event once per week + mode=map shows a map of events calendar=NAME uses the given NAME to provide request parameters which can be used to control the calendar view @@ -1099,6 +1115,19 @@ if not specified) parent=PAGE uses the given PAGE as the parent of any new event page + + Calendar view options: + + names=daily shows the name of an event on every day of that event + names=weekly shows the name of an event once per week + + Map view options: + + map=NAME uses the given NAME as the map image, where an entry for + the map must be found in the EventMaps page (or another + page specified in the configuration by the + 'event_aggregator_maps_page' setting) along with an + attached map image """ request = macro.request @@ -1129,6 +1158,7 @@ calendar_name = None template_name = getattr(request.cfg, "event_aggregator_new_event_template", "EventTemplate") parent_name = None + map_name = None for arg in parsed_args: if arg.startswith("start="): @@ -1152,6 +1182,9 @@ elif arg.startswith("parent="): parent_name = arg[7:] + elif arg.startswith("map="): + map_name = arg[4:] + else: category_names.append(arg) @@ -1282,7 +1315,82 @@ output.append(fmt.table(on=0)) - # Output a list or month calendar. + # Output a map view. + + elif mode == "map": + + # Special dictionary pages. + + maps_page = getattr(request.cfg, "event_aggregator_maps_page", "EventMapsDict") + locations_page = getattr(request.cfg, "event_aggregator_locations_page", "EventLocationsDict") + + map_image = None + + # Get the maps and locations. + + if request.user.may.read(maps_page): + maps = request.dicts.dict(maps_page) + else: + maps = None + + if request.user.may.read(locations_page): + locations = request.dicts.dict(locations_page) + else: + locations = None + + # Get the map image definition. + + if maps is not None and map_name is not None: + try: + map_bottom_left, map_top_right, map_width, map_height, map_image = maps[map_name].split() + except (KeyError, ValueError): + pass + + # Report errors. + + if maps is None: + output.append(view.showDictError( + _("You do not have read access to the maps page:"), + maps_page)) + + elif map_name is None: + output.append(view.showDictError( + _("Please specify a valid map name corresponding to an entry on the following page:"), + maps_page)) + + elif map_image is None: + output.append(view.showDictError( + _("Please specify a valid entry for %s on the following page:") % map_name, + maps_page)) + + elif locations is None: + output.append(view.showDictError( + _("You do not have read access to the locations page:"), + locations_page)) + + # Attempt to show the image. + + else: + + # Get the map image URL. + + map_image_url = AttachFile.getAttachUrl(maps_page, map_image, request) + + # Start of map view output. + + output.append(fmt.div(on=1, css_class="event-map")) + + output.append(fmt.div(on=1, css_class="event-map-container", + style="width: %spx; height: %spx; background-image: url('%s')" % ( + escattr(map_width), escattr(map_height), map_image_url) + )) + + # End of map view output. + + output.append(fmt.div(on=0)) + output.append(fmt.div(on=0)) + + # Output a list or month calendar. These views show month-by-month data. elif mode in ("list", "calendar"):