1.1 --- a/EventAggregatorSupport.py Tue Feb 05 00:16:04 2013 +0100
1.2 +++ b/EventAggregatorSupport.py Thu Apr 25 23:04:53 2013 +0200
1.3 @@ -3456,10 +3456,11 @@
1.4
1.5 # Start the collection.
1.6
1.7 - if mimetype == "text/calendar":
1.8 - write("BEGIN:VCALENDAR\r\n")
1.9 - write("PRODID:-//MoinMoin//EventAggregatorSummary\r\n")
1.10 - write("VERSION:2.0\r\n")
1.11 + if mimetype == "text/calendar" and vCalendar is not None:
1.12 + write = vCalendar.iterwrite(write=write).write
1.13 + write("BEGIN", {}, "VCALENDAR")
1.14 + write("PRODID", {}, "-//MoinMoin//EventAggregatorSummary")
1.15 + write("VERSION", {}, "2.0")
1.16
1.17 elif mimetype == "application/rss+xml":
1.18
1.19 @@ -3494,8 +3495,8 @@
1.20
1.21 # End the collection.
1.22
1.23 - if mimetype == "text/calendar":
1.24 - write("END:VCALENDAR\r\n")
1.25 + if mimetype == "text/calendar" and vCalendar is not None:
1.26 + write("END", {}, "VCALENDAR")
1.27
1.28 elif mimetype == "application/rss+xml":
1.29 write('</channel>\r\n')
1.30 @@ -3524,11 +3525,13 @@
1.31 event_details = event.getDetails()
1.32 event_metadata = event.getMetadata()
1.33
1.34 - if mimetype == "text/calendar":
1.35 + if mimetype == "text/calendar" and vCalendar is not None:
1.36
1.37 # NOTE: A custom formatter making attributes for links and plain
1.38 # NOTE: text for values could be employed here.
1.39
1.40 + write = vCalendar.iterwrite(write=write).write
1.41 +
1.42 # Get the summary details.
1.43
1.44 event_summary = event.getSummary(parent)
1.45 @@ -3536,43 +3539,40 @@
1.46
1.47 # Output the event details.
1.48
1.49 - write("BEGIN:VEVENT\r\n")
1.50 - write("UID:%s\r\n" % link)
1.51 - write("URL:%s\r\n" % link)
1.52 - write("DTSTAMP:%04d%02d%02dT%02d%02d%02dZ\r\n" % event_metadata["created"].as_tuple()[:6])
1.53 - write("LAST-MODIFIED:%04d%02d%02dT%02d%02d%02dZ\r\n" % event_metadata["last-modified"].as_tuple()[:6])
1.54 - write("SEQUENCE:%d\r\n" % event_metadata["sequence"])
1.55 + write("BEGIN", {}, "VEVENT")
1.56 + write("UID", {}, link)
1.57 + write("URL", {}, link)
1.58 + write("DTSTAMP", {}, "%04d%02d%02dT%02d%02d%02dZ" % event_metadata["created"].as_tuple()[:6])
1.59 + write("LAST-MODIFIED", {}, "%04d%02d%02dT%02d%02d%02dZ" % event_metadata["last-modified"].as_tuple()[:6])
1.60 + write("SEQUENCE", {}, "%d" % event_metadata["sequence"])
1.61
1.62 start = event_details["start"]
1.63 end = event_details["end"]
1.64
1.65 if isinstance(start, DateTime):
1.66 - write("DTSTART")
1.67 - write_calendar_datetime(request, start)
1.68 + params, value = get_calendar_datetime(start)
1.69 else:
1.70 - write("DTSTART;VALUE=DATE:%04d%02d%02d\r\n" % start.as_date().as_tuple())
1.71 + params, value = {"VALUE" : "DATE"}, "%04d%02d%02d" % start.as_date().as_tuple()
1.72 + write("DTSTART", params, value)
1.73
1.74 if isinstance(end, DateTime):
1.75 - write("DTEND")
1.76 - write_calendar_datetime(request, end)
1.77 + params, value = get_calendar_datetime(end)
1.78 else:
1.79 - write("DTEND;VALUE=DATE:%04d%02d%02d\r\n" % end.next_day().as_date().as_tuple())
1.80 -
1.81 - write("SUMMARY:%s\r\n" % getQuotedText(event_summary))
1.82 + params, value = {"VALUE" : "DATE"}, "%04d%02d%02d" % end.next_day().as_date().as_tuple()
1.83 + write("DTEND", params, value)
1.84 +
1.85 + write("SUMMARY", {}, event_summary)
1.86
1.87 # Optional details.
1.88
1.89 if event_details.get("topics") or event_details.get("categories"):
1.90 - write("CATEGORIES:%s\r\n" % ",".join(
1.91 - [getQuotedText(topic)
1.92 - for topic in event_details.get("topics") or event_details.get("categories")]
1.93 - ))
1.94 + write("CATEGORIES", {}, event_details.get("topics") or event_details.get("categories"))
1.95 if event_details.has_key("location"):
1.96 - write("LOCATION:%s\r\n" % getQuotedText(event_details["location"]))
1.97 + write("LOCATION", {}, event_details["location"])
1.98 if event_details.has_key("geo"):
1.99 - write("GEO:%s\r\n" % getQuotedText(";".join([str(ref.to_degrees()) for ref in event_details["geo"]])))
1.100 -
1.101 - write("END:VEVENT\r\n")
1.102 + write("GEO", {}, tuple([str(ref.to_degrees()) for ref in event_details["geo"]]))
1.103 +
1.104 + write("END", {}, "VEVENT")
1.105
1.106 elif mimetype == "application/rss+xml":
1.107
1.108 @@ -3618,7 +3618,7 @@
1.109
1.110 # iCalendar format helper functions.
1.111
1.112 -def write_calendar_datetime(request, datetime):
1.113 +def get_calendar_datetime(datetime):
1.114
1.115 """
1.116 Write to the given 'request' the 'datetime' using appropriate time zone
1.117 @@ -3627,17 +3627,12 @@
1.118
1.119 utc_datetime = datetime.to_utc()
1.120 if utc_datetime:
1.121 - request.write(";VALUE=DATE-TIME:%04d%02d%02dT%02d%02d%02dZ\r\n" % utc_datetime.padded().as_tuple()[:-1])
1.122 + return {"VALUE" : "DATE-TIME"}, "%04d%02d%02dT%02d%02d%02dZ" % utc_datetime.padded().as_tuple()[:-1]
1.123 else:
1.124 zone = datetime.time_zone()
1.125 + params = {"VALUE" : "DATE-TIME"}
1.126 if zone:
1.127 - request.write(";TZID=/%s" % zone)
1.128 - request.write(";VALUE=DATE-TIME:%04d%02d%02dT%02d%02d%02d\r\n" % datetime.padded().as_tuple()[:-1])
1.129 -
1.130 -def getQuotedText(text):
1.131 -
1.132 - "Return the 'text' quoted for iCalendar purposes."
1.133 -
1.134 - return text.replace(";", r"\;").replace(",", r"\,").replace("\n", "\\n")
1.135 + params["TZID"] = zone
1.136 + return params, "%04d%02d%02dT%02d%02d%02d" % datetime.padded().as_tuple()[:-1]
1.137
1.138 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/README.txt Tue Feb 05 00:16:04 2013 +0100
2.2 +++ b/README.txt Thu Apr 25 23:04:53 2013 +0200
2.3 @@ -104,20 +104,33 @@
2.4
2.5 @import "event-aggregator.css";
2.6
2.7 -Optional Installation Tasks
2.8 ----------------------------
2.9 +Additional Installation Tasks
2.10 +-----------------------------
2.11 +
2.12 +See the "Dependencies" section below for details of the software featured in
2.13 +this section.
2.14
2.15 -To add the capability of aggregating iCalendar format event sources, the
2.16 -vContent software needs to be obtained and installed. See the "Recommended
2.17 -Software" section below for details.
2.18 +EventAggregator depends on MoinSupport having been installed. This is because
2.19 +a lot of useful functionality common to a number of MoinMoin extensions now
2.20 +resides in the MoinSupport distribution.
2.21 +
2.22 +The following command can be run with $MSDIR referring to the MoinSupport
2.23 +distribution directory:
2.24 +
2.25 + python moinsetup.py -f moinsetup.cfg -m install_extension_package $MSDIR
2.26 +
2.27 +To support iCalendar summary production for calendars as well as the
2.28 +capability of aggregating iCalendar format event sources, the vContent
2.29 +software needs to be obtained and installed.
2.30
2.31 The following command can be run with $VCDIR referring to the vContent
2.32 distribution directory:
2.33
2.34 python moinsetup.py -f moinsetup.cfg -m install_extension_package $VCDIR
2.35
2.36 -This merely runs the setup.py script provided by that software, installing
2.37 -the software under the configured installation "prefix".
2.38 +In each case, the install_extension_package method merely runs the setup.py
2.39 +script provided by the software concerned, installing the software under the
2.40 +configured installation "prefix".
2.41
2.42 Useful Pages
2.43 ------------
2.44 @@ -256,13 +269,6 @@
2.45
2.46 http://moinmo.in/HelpOnXapian
2.47
2.48 -The vContent software is required for the parsing of iCalendar information
2.49 -from remote event sources.
2.50 -
2.51 -See the following page for information on vContent:
2.52 -
2.53 -https://hg.boddie.org.uk/vContent
2.54 -
2.55 Troubleshooting: Categories
2.56 ---------------------------
2.57
2.58 @@ -331,6 +337,9 @@
2.59 MoinSupport Tested with 0.2
2.60 Source: http://hgweb.boddie.org.uk/MoinSupport
2.61
2.62 +vContent Tested with 0.2
2.63 + Source: http://hgweb.boddie.org.uk/vContent
2.64 +
2.65 pytz Tested with 2007k (specifically 2007k-0ubuntu2)
2.66 Source: http://pytz.sourceforge.net/
2.67
2.68 @@ -339,6 +348,12 @@
2.69 time zone information for the correct interpretation of time information in
2.70 those summaries. Thus, it is highly recommended that pytz be installed.
2.71
2.72 +New in EventAggregator 0.9.1 (Changes since EventAggregator 0.9)
2.73 +----------------------------------------------------------------
2.74 +
2.75 + * Changed iCalendar serialisation to use the vContent library, making
2.76 + vContent a requirement of this software.
2.77 +
2.78 New in EventAggregator 0.9 (Changes since EventAggregator 0.8.5)
2.79 ----------------------------------------------------------------
2.80