# HG changeset patch # User Paul Boddie # Date 1366923893 -7200 # Node ID e1f2a2864fd88516e0fbe07ab55259bf7eed955f # Parent 2cb6eb1df3cc4e75b7a2c324ec6e658906932a4a Changed iCalendar serialisation to use the vContent library, making vContent a requirement of this software. diff -r 2cb6eb1df3cc -r e1f2a2864fd8 EventAggregatorSupport.py --- a/EventAggregatorSupport.py Tue Feb 05 00:16:04 2013 +0100 +++ b/EventAggregatorSupport.py Thu Apr 25 23:04:53 2013 +0200 @@ -3456,10 +3456,11 @@ # Start the collection. - if mimetype == "text/calendar": - write("BEGIN:VCALENDAR\r\n") - write("PRODID:-//MoinMoin//EventAggregatorSummary\r\n") - write("VERSION:2.0\r\n") + if mimetype == "text/calendar" and vCalendar is not None: + write = vCalendar.iterwrite(write=write).write + write("BEGIN", {}, "VCALENDAR") + write("PRODID", {}, "-//MoinMoin//EventAggregatorSummary") + write("VERSION", {}, "2.0") elif mimetype == "application/rss+xml": @@ -3494,8 +3495,8 @@ # End the collection. - if mimetype == "text/calendar": - write("END:VCALENDAR\r\n") + if mimetype == "text/calendar" and vCalendar is not None: + write("END", {}, "VCALENDAR") elif mimetype == "application/rss+xml": write('\r\n') @@ -3524,11 +3525,13 @@ event_details = event.getDetails() event_metadata = event.getMetadata() - if mimetype == "text/calendar": + if mimetype == "text/calendar" and vCalendar is not None: # NOTE: A custom formatter making attributes for links and plain # NOTE: text for values could be employed here. + write = vCalendar.iterwrite(write=write).write + # Get the summary details. event_summary = event.getSummary(parent) @@ -3536,43 +3539,40 @@ # Output the event details. - write("BEGIN:VEVENT\r\n") - write("UID:%s\r\n" % link) - write("URL:%s\r\n" % link) - write("DTSTAMP:%04d%02d%02dT%02d%02d%02dZ\r\n" % event_metadata["created"].as_tuple()[:6]) - write("LAST-MODIFIED:%04d%02d%02dT%02d%02d%02dZ\r\n" % event_metadata["last-modified"].as_tuple()[:6]) - write("SEQUENCE:%d\r\n" % event_metadata["sequence"]) + write("BEGIN", {}, "VEVENT") + write("UID", {}, link) + write("URL", {}, link) + write("DTSTAMP", {}, "%04d%02d%02dT%02d%02d%02dZ" % event_metadata["created"].as_tuple()[:6]) + write("LAST-MODIFIED", {}, "%04d%02d%02dT%02d%02d%02dZ" % event_metadata["last-modified"].as_tuple()[:6]) + write("SEQUENCE", {}, "%d" % event_metadata["sequence"]) start = event_details["start"] end = event_details["end"] if isinstance(start, DateTime): - write("DTSTART") - write_calendar_datetime(request, start) + params, value = get_calendar_datetime(start) else: - write("DTSTART;VALUE=DATE:%04d%02d%02d\r\n" % start.as_date().as_tuple()) + params, value = {"VALUE" : "DATE"}, "%04d%02d%02d" % start.as_date().as_tuple() + write("DTSTART", params, value) if isinstance(end, DateTime): - write("DTEND") - write_calendar_datetime(request, end) + params, value = get_calendar_datetime(end) else: - write("DTEND;VALUE=DATE:%04d%02d%02d\r\n" % end.next_day().as_date().as_tuple()) - - write("SUMMARY:%s\r\n" % getQuotedText(event_summary)) + params, value = {"VALUE" : "DATE"}, "%04d%02d%02d" % end.next_day().as_date().as_tuple() + write("DTEND", params, value) + + write("SUMMARY", {}, event_summary) # Optional details. if event_details.get("topics") or event_details.get("categories"): - write("CATEGORIES:%s\r\n" % ",".join( - [getQuotedText(topic) - for topic in event_details.get("topics") or event_details.get("categories")] - )) + write("CATEGORIES", {}, event_details.get("topics") or event_details.get("categories")) if event_details.has_key("location"): - write("LOCATION:%s\r\n" % getQuotedText(event_details["location"])) + write("LOCATION", {}, event_details["location"]) if event_details.has_key("geo"): - write("GEO:%s\r\n" % getQuotedText(";".join([str(ref.to_degrees()) for ref in event_details["geo"]]))) - - write("END:VEVENT\r\n") + write("GEO", {}, tuple([str(ref.to_degrees()) for ref in event_details["geo"]])) + + write("END", {}, "VEVENT") elif mimetype == "application/rss+xml": @@ -3618,7 +3618,7 @@ # iCalendar format helper functions. -def write_calendar_datetime(request, datetime): +def get_calendar_datetime(datetime): """ Write to the given 'request' the 'datetime' using appropriate time zone @@ -3627,17 +3627,12 @@ utc_datetime = datetime.to_utc() if utc_datetime: - request.write(";VALUE=DATE-TIME:%04d%02d%02dT%02d%02d%02dZ\r\n" % utc_datetime.padded().as_tuple()[:-1]) + return {"VALUE" : "DATE-TIME"}, "%04d%02d%02dT%02d%02d%02dZ" % utc_datetime.padded().as_tuple()[:-1] else: zone = datetime.time_zone() + params = {"VALUE" : "DATE-TIME"} if zone: - request.write(";TZID=/%s" % zone) - request.write(";VALUE=DATE-TIME:%04d%02d%02dT%02d%02d%02d\r\n" % datetime.padded().as_tuple()[:-1]) - -def getQuotedText(text): - - "Return the 'text' quoted for iCalendar purposes." - - return text.replace(";", r"\;").replace(",", r"\,").replace("\n", "\\n") + params["TZID"] = zone + return params, "%04d%02d%02dT%02d%02d%02d" % datetime.padded().as_tuple()[:-1] # vim: tabstop=4 expandtab shiftwidth=4 diff -r 2cb6eb1df3cc -r e1f2a2864fd8 README.txt --- a/README.txt Tue Feb 05 00:16:04 2013 +0100 +++ b/README.txt Thu Apr 25 23:04:53 2013 +0200 @@ -104,20 +104,33 @@ @import "event-aggregator.css"; -Optional Installation Tasks ---------------------------- +Additional Installation Tasks +----------------------------- + +See the "Dependencies" section below for details of the software featured in +this section. -To add the capability of aggregating iCalendar format event sources, the -vContent software needs to be obtained and installed. See the "Recommended -Software" section below for details. +EventAggregator depends on MoinSupport having been installed. This is because +a lot of useful functionality common to a number of MoinMoin extensions now +resides in the MoinSupport distribution. + +The following command can be run with $MSDIR referring to the MoinSupport +distribution directory: + + python moinsetup.py -f moinsetup.cfg -m install_extension_package $MSDIR + +To support iCalendar summary production for calendars as well as the +capability of aggregating iCalendar format event sources, the vContent +software needs to be obtained and installed. The following command can be run with $VCDIR referring to the vContent distribution directory: python moinsetup.py -f moinsetup.cfg -m install_extension_package $VCDIR -This merely runs the setup.py script provided by that software, installing -the software under the configured installation "prefix". +In each case, the install_extension_package method merely runs the setup.py +script provided by the software concerned, installing the software under the +configured installation "prefix". Useful Pages ------------ @@ -256,13 +269,6 @@ http://moinmo.in/HelpOnXapian -The vContent software is required for the parsing of iCalendar information -from remote event sources. - -See the following page for information on vContent: - -https://hg.boddie.org.uk/vContent - Troubleshooting: Categories --------------------------- @@ -331,6 +337,9 @@ MoinSupport Tested with 0.2 Source: http://hgweb.boddie.org.uk/MoinSupport +vContent Tested with 0.2 + Source: http://hgweb.boddie.org.uk/vContent + pytz Tested with 2007k (specifically 2007k-0ubuntu2) Source: http://pytz.sourceforge.net/ @@ -339,6 +348,12 @@ time zone information for the correct interpretation of time information in those summaries. Thus, it is highly recommended that pytz be installed. +New in EventAggregator 0.9.1 (Changes since EventAggregator 0.9) +---------------------------------------------------------------- + + * Changed iCalendar serialisation to use the vContent library, making + vContent a requirement of this software. + New in EventAggregator 0.9 (Changes since EventAggregator 0.8.5) ---------------------------------------------------------------- diff -r 2cb6eb1df3cc -r e1f2a2864fd8 TO_DO.txt --- a/TO_DO.txt Tue Feb 05 00:16:04 2013 +0100 +++ b/TO_DO.txt Thu Apr 25 23:04:53 2013 +0200 @@ -1,9 +1,3 @@ -iCalendar Serialisation ------------------------ - -The vContent serialisation should probably be used instead of the existing -code. - Navigation Controls -------------------