iwla

iwla Commit Details

Date:2016-02-04 20:46:12 (5 years 6 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:bb189425f153a4b5178075e83947c6c0fd36d17d
Parents: 79da471398ff8265c7b82eaf54425fba2a0402f8
Message:Add filter mechanism for plugins

Changes:
Mdisplay.py (8 diffs)
Miwla.py (1 diff)
Mplugins/display/track_users.py (1 diff)

File differences

display.py
4848
4949
5050
51
51
52
5253
5354
5455
56
57
58
59
60
61
62
5563
5664
5765
......
189197
190198
191199
200
201
202
203
204
205
206
207
208
209
210
211
192212
193213
194214
......
315335
316336
317337
318
338
339
340
341
319342
320343
321344
322
345
323346
324347
325348
......
339362
340363
341364
342
365
343366
344367
345368
......
349372
350373
351374
352
353375
376
377
378
379
380
354381
355382
356383
......
364391
365392
366393
394
395
396
367397
368398
369399
......
378408
379409
380410
381
411
412
413
414
415
382416
383417
384418
......
417451
418452
419453
420
def _build(self, f, html):
if html: f.write(html)
def build(self, f):
def build(self, f, filters=None):
if filters: self.filter(filters)
self._buildHTML()
self._build(f, self.html)
def _filter(self, function, **kwargs):
pass
def filter(self, filters):
for (args, function) in filters:
self._filter(function, **args)
def getTitle(self):
return ''
val = r[column] and int(r[column]) or 0
self.setCellValue(index, column_insertion, '%.1f%%' % (float(val*100)/float(total)))
def _filter(self, function, column, args):
target_col = None
for col in range(0, len(self.cols)):
if self.cols[col] == column:
target_col = col
break
if target_col is None: return
for row in self.rows:
res = function(row[target_col], **args)
if res:
row[target_col] = res
def _buildHTML(self):
style = u''
if self.table_css: style = u' class="%s"' % (self.table_css)
if title == b.getTitle():
return b
return None
def getAllBlocks(self):
return self.blocks
def appendBlock(self, block):
self.blocks.append(block)
def build(self, root, displayVersion=True):
def build(self, root, displayVersion=True, filters=None):
filename = os.path.join(root, self.filename)
base = os.path.dirname(filename)
f.write(u'<title>%s</title>' % (self.title))
f.write(u'</head><body>')
for block in self.blocks:
block.build(f)
block.build(f, filters=filters)
if displayVersion:
f.write(u'<center>Generated by <a href="%s">IWLA %s</a></center>' %
("http://indefero.soutade.fr/p/iwla", self.iwla.getVersion()))
class DisplayHTMLBuild(object):
def __init__(self, iwla):
self.pages = []
self.iwla = iwla
self.filters = []
self.clear()
def clear(self):
self.pages = []
def createPage(self, *args):
return DisplayHTMLPage(self.iwla, *args)
return page
return None
def getAllPages(self):
return self.pages
def addPage(self, page):
self.pages.append(page)
os.symlink(target, link_name)
for page in self.pages:
page.build(root)
page.build(root, filters=self.filters)
def addColumnFilter(self, column, function, args):
self.filters.append(({'column':column, 'args':args}, function))
#
# Global functions
if domain_name:
title += u' - %s' % (domain_name)
return title
iwla.py
230230
231231
232232
233
233
234234
235235
236236
return self.meta_infos
def _clearDisplay(self):
self.display = DisplayHTMLBuild(self)
self.display.clear()
return self.display
def getDBFilename(self, time):
plugins/display/track_users.py
110110
111111
112112
113
113
114114
115115
116116
index = self.iwla.getDisplayIndex()
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'IP'), self.iwla._(u'Last Access'), self.iwla._(u'Pages'), self.iwla._(u'Hits')])
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'Host'), self.iwla._(u'Last Access'), self.iwla._(u'Pages'), self.iwla._(u'Hits')])
table.setColsCSSClass(['', '', 'iwla_page', 'iwla_hit'])
for ip in self.tracked_ip:
if not ip in hits.keys(): continue

Archive Download the corresponding diff file

Branches

Tags