- 932DB323BE19AE3D24ECEC90B63D8E0E551EDDFE2278233CFB73E66E89CF36108768D3FB8A0E5BB330D25BA31B0634F7805ADF2BE3E0ABE2D18E6A546179C6F9
+ E67F9263580FCE464D48E985CC229C279A89C2F79296DEF56631EB295DA2B4604EBDC681914C1217D139B68873F721CD5DF0AF1A82F6F199E16A87F1DBBBEDB9
logotron/reader.py
(15 . 6)(15 . 7)
220 import os
221 import threading
222 import re
223 import shlex
224 from datetime import datetime
225 from urlparse import urljoin
226 from flask import Flask, request, session, url_for, redirect, Response, \
(276 . 16)(277 . 26)
228 if ss <= l['idx'] <= se:
229 dclass = "highlight"
230
231 speaker = l['speaker']
232 separator = ":"
233
234 # If 'action', annotate:
235 if l['self']:
236 separator = ""
237 payload = "<i>" + payload + "</i>"
238 speaker = "<i>" + speaker + "</i>"
239
240 # HTMLize the given line :
241 s = ("<div id='{0}' class='{6}{5}'>"
242 "<a class='nick' title='{2}'"
243 " href=\"{3}\">{1}</a>: {4}</div>").format(l['idx'],
244 l['speaker'],
245 l['t'],
246 line_url(l),
247 payload,
248 bot,
249 dclass)
250 " href=\"{3}\">{1}</a>{5} {4}</div>").format(l['idx'],
251 speaker,
252 l['t'],
253 line_url(l),
254 payload,
255 bot,
256 dclass,
257 separator)
258 return s
259
260 # Make above callable from inside htm templater:
(436 . 6)(447 . 49)
262 return Response(res, mimetype='text/plain')
263
264
265 # "Tape" is a raw log containing entried from ALL logged chans:
266 @app.route('/tape')
267 def tape():
268 res = ""
269
270 # Get start and end indices:
271 idx_start = request.args.get('istart', default = 0, type = int)
272 idx_end = request.args.get('iend', default = 0, type = int)
273
274 # Malformed bounds?
275 if idx_start > idx_end:
276 return Response("EGGOG: Start must precede End!",
277 mimetype='text/plain')
278
279 # Demanded too many in one burst ?
280 if (idx_end - idx_start) > Max_Raw_Ln :
281 return Response("EGGOG: May request Max. of %s Lines !" % Max_Raw_Ln,
282 mimetype='text/plain')
283
284 # Get the loglines from DB
285 lines = query_db(
286 '''select * from loglines where
287 idx between %s and %s order by idx asc;''',
288 [idx_start, idx_end], one=False)
289
290 # Retrieve raw lines in Tape format:
291 for l in lines:
292 action = ""
293 speaker = "%s;" % l['speaker']
294 if l['self']:
295 action = "*;"
296 speaker = "%s " % l['speaker']
297 res += "%s;%s;%s;%s%s%s\n" % (l['chan'],
298 l['idx'],
299 l['t'].strftime('%s'),
300 action,
301 speaker,
302 l['payload'])
303
304 # Return plain text:
305 return Response(res, mimetype='text/plain')
306
307
308 Name_Chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"
309
310 def sanitize_speaker(s):
(464 . 7)(518 . 7)
312 # Forbid query that is too short:
313 if len(query) >= Min_Query_Length:
314 # Get the search tokens to use:
315 tokens = query.split()
316 tokens = shlex.split(query)
317 tokens_standard = []
318 from_users = []
319