--- a/handlers.py Thu Feb 12 00:57:39 2009 +0200
+++ b/handlers.py Thu Feb 12 01:53:52 2009 +0200
@@ -20,7 +20,7 @@
)
# return a http.Response for the given text in the given format
-def _render_type (request, channel, lines, type) :
+def _render_type (request, channel, lines, type, full_timestamps=False) :
"""
Render the given LogLines as a http.Response in the given format, which is one of:
html - XXX: not supported
@@ -38,7 +38,7 @@
elif type == 'txt' :
# plaintext
- lines = formatter.format_txt(lines)
+ lines = formatter.format_txt(lines, full_timestamps)
# build data
data = '\n'.join(data for line, data in lines)
@@ -47,13 +47,13 @@
elif type == 'png' :
# PNG image
- png_data = formatter.format_png(lines)
+ png_data = formatter.format_png(lines, full_timestamps)
return http.Response(png_data, 'image/png', charset=None)
elif type == 'rss' :
# RSS feed
- rss_data = formatter.format_rss(lines)
+ rss_data = formatter.format_rss(lines, full_timestamps)
# XXX: fix to render as unicode?
return http.Response(rss_data, 'application/rss+xml', charset=None)
@@ -224,7 +224,7 @@
return _render_date (request, channel, date, lines, type, count, page, max)
@preferences.handler(prefs.formatter, prefs.count)
-def channel_search (request, channel, formatter, count, q=None, page=1, max=1, type=None) :
+def channel_search (request, channel, formatter, count, q=None, page=1, max=1, type=None, t=None) :
"""
Display the search form for the channel for GET, or do the search for POST.
"""
@@ -234,9 +234,12 @@
# got a search query?
if q :
+ # attribute targets
+ targets = dict(('search_%s' % target, True) for target in t if target in ('msg', 'nick')) if t else {}
+
try :
# do search
- lines = log_search.get_index().search_simple(channel, q, count, skip)
+ lines = log_search.get_index().search_simple(channel, q, count, skip, **targets)
# update max?
if max and page > max :
@@ -253,7 +256,7 @@
# type?
if type and lines :
# special type
- return _render_type(request, channel, lines, type)
+ return _render_type(request, channel, lines, type, full_timestamps=True)
else :
# format lines to HTML if any
@@ -267,6 +270,7 @@
prefs = request.prefs,
channel = channel,
search_query = q,
+ search_targets = t,
count = count,
page = page,
skip = skip,