149 @preferences.handler(prefs.formatter) |
149 @preferences.handler(prefs.formatter) |
150 def channel_last (request, channel, count, formatter, type=None) : |
150 def channel_last (request, channel, count, formatter, type=None) : |
151 """ |
151 """ |
152 The main channel view page, displaying the most recent lines |
152 The main channel view page, displaying the most recent lines |
153 """ |
153 """ |
154 |
154 |
155 # get latest events |
155 # get latest events |
156 lines = channel.source.get_latest(count) |
156 lines = channel.source.get_latest(count) |
157 |
157 |
158 # type? |
158 # type? |
159 if type : |
159 if type : |
229 page, max, lines = channel.source.get_date_paged(date, count, page) |
229 page, max, lines = channel.source.get_date_paged(date, count, page) |
230 |
230 |
231 else : |
231 else : |
232 lines = channel.source.get_date(date) |
232 lines = channel.source.get_date(date) |
233 max = None |
233 max = None |
234 |
234 |
235 # render channel_date |
235 # render channel_date |
236 return _render_date (request, channel, date, lines, type, count, page, max) |
236 return _render_date (request, channel, date, lines, type, count, page, max) |
237 |
237 |
238 @preferences.handler(prefs.formatter, prefs.count) |
238 @preferences.handler(prefs.formatter, prefs.count) |
239 def channel_search (request, channel, formatter, count, q=None, page=1, max=1, type=None, t=None) : |
239 def channel_search (request, channel, formatter, count, q=None, nick=None, page=1, max=1, type=None) : |
240 """ |
240 """ |
241 Display the search form for the channel for GET, or do the search for POST. |
241 Display the search form for the channel for GET, or do the search for POST. |
242 """ |
242 """ |
243 |
243 |
244 # calculate skip offset from page/count |
244 # calculate skip offset from page/count |
245 skip = (page - 1) * count |
245 skip = (page - 1) * count |
246 |
246 |
247 # got a search query? |
247 |
248 if q : |
248 if q or nick : |
249 # attribute targets |
249 # search |
250 targets = dict(('search_%s' % target, True) for target in t if target in ('msg', 'nick')) if t else {} |
|
251 |
|
252 try : |
250 try : |
253 # do search |
251 lines = log_search.get_index().search_advanced(channel, q, nick, count, skip) |
254 lines = log_search.get_index().search_simple(channel, q, count, skip, **targets) |
252 |
255 |
|
256 # update max? |
|
257 if max and page > max : |
|
258 max = page |
|
259 |
|
260 except log_search.NoResultsFound : |
253 except log_search.NoResultsFound : |
261 # no results |
254 # no results |
262 lines = None |
255 lines = None |
263 |
256 |
264 else : |
257 else : |
265 # just display the search form |
258 # just display the search form |
266 lines = None |
259 lines = None |
267 |
260 |
|
261 |
|
262 # max? |
|
263 if max and page > max : |
|
264 max = page |
|
265 |
|
266 |
268 # type? |
267 # type? |
269 if type and lines : |
268 if type and lines : |
270 # special type |
269 # special type |
271 return _render_type(request, channel, lines, type, full_timestamps=True) |
270 return _render_type(request, channel, lines, type, full_timestamps=True) |
272 |
271 |