# HG changeset patch # User Sebastien Decugis # Date 1281423906 -32400 # Node ID 76549bed2e2f57a794c7f61c698305c17cf59c8a # Parent 559393b8973fedd5c9911a608ba5a64bea9f032b Started next feature, to be completed diff -r 559393b8973f -r 76549bed2e2f trac_plugin/MailmanPlugin.py --- a/trac_plugin/MailmanPlugin.py Tue Aug 10 15:07:25 2010 +0900 +++ b/trac_plugin/MailmanPlugin.py Tue Aug 10 16:05:06 2010 +0900 @@ -26,7 +26,7 @@ class MailmanPlugin(Component): """ Search mailing-list archives. """ - implements(ISearchSource) + implements(ISearchSource, ITimelineEventProvider) # ISearchSource methods def get_search_filters(self, req): @@ -58,4 +58,51 @@ result.getproperty('name') + ' <' + result.getproperty('email') + '>', shorten_result(content, query)) + # ITimelineEventProvider methods + def get_timeline_filters(req): + for MLShort, MLIndex, MLLabel in MailmanConfig: + yield ('ML-' + MLShort, MLLabel) + +""" +Development to be continued. +Need some way to dig into the archives without being too much resource-consuming. +For example create an index like: +cat /var/lib/mailman/archives/public/help/*.txt | grep -E '(From|Date): ' | sed -r "s/From: ([^[:space:]]*) at ([^[:space:]]*) \(([^\]*)\)$/\3 <\1@\2>/" +And update in a cron job. +""" + def get_timeline_events(req, start, stop, filters): + """Return a list of events in the time range given by the `start` and + `stop` parameters. + + The `filters` parameters is a list of the enabled filters, each item + being the name of the tuples returned by `get_timeline_filters`. + + Since 0.11, the events are `(kind, date, author, data)` tuples, + where `kind` is a string used for categorizing the event, `date` + is a `datetime` object, `author` is a string and `data` is some + private data that the component will reuse when rendering the event. + + When the event has been created indirectly by another module, + like this happens when calling `AttachmentModule.get_timeline_events()` + the tuple can also specify explicitly the provider by returning tuples + of the following form: `(kind, date, author, data, provider)`. + + Before version 0.11, the events returned by this function used to + be tuples of the form `(kind, href, title, date, author, markup)`. + This is still supported but less flexible, as `href`, `title` and + `markup` are not context dependent. + """ + + def render_timeline_event(context, field, event): + """Display the title of the event in the given context. + + :param context: the rendering `Context` object that can be used for + rendering + :param field: what specific part information from the event should + be rendered: can be the 'title', the 'description' or + the 'url' + :param event: the event tuple, as returned by `get_timeline_events` + """ + + \ No newline at end of file