iwla

iwla Commit Details

Date:2014-12-29 19:12:41 (6 years 6 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:ac211e30ea8366c68ecf7c0b9906aa764b652d5d
Parents: 1d894b6bc02eae1f5dd44544ad5e908aa8739c11
Message:Add year statistics in month details

Changes:
Mdisplay.py (3 diffs)
Miwla.py (5 diffs)
Mresources/css/iwla.css (1 diff)

File differences

display.py
5252
5353
5454
55
56
57
5558
5659
5760
......
287290
288291
289292
290
293
291294
292295
293296
......
308311
309312
310313
311
312
314
315
316
313317
314318
315319
self._buildHTML()
self._build(f, self.html)
def getTitle(self):
return ''
class DisplayHTMLBlock(DisplayHTMLRaw):
def __init__(self, iwla, title=''):
def appendBlock(self, block):
self.blocks.append(block)
def build(self, root):
def build(self, root, displayVersion=True):
filename = os.path.join(root, self.filename)
base = os.path.dirname(filename)
f.write(u'</head><body>')
for block in self.blocks:
block.build(f)
f.write(u'<center>Generated by <a href="%s">IWLA %s</a></center>' %
("http://indefero.soutade.fr/p/iwla", self.iwla.getVersion()))
if displayVersion:
f.write(u'<center>Generated by <a href="%s">IWLA %s</a></center>' %
("http://indefero.soutade.fr/p/iwla", self.iwla.getVersion()))
f.write(u'</body></html>')
f.close()
iwla.py
5959
6060
6161
62
6263
6364
6465
......
371372
372373
373374
375
376
374377
375378
376379
......
430433
431434
432435
436
437
433438
434439
435440
......
447452
448453
449454
455
456
457
458
450459
451460
452461
453462
454463
464
455465
456466
457467
......
460470
461471
462472
473
474
475
476
477
478
463479
464480
465481
DB_ROOT/meta.db
DB_ROOT/year/month/iwla.db
OUTPUT_ROOT/index.html
OUTPUT_ROOT/year/_stats.html
OUTPUT_ROOT/year/month/index.html
Statistics creation :
filename = self.getCurDisplayPath('index.html')
self.logger.info('==> Generate display (%s)' % (filename))
page = self.display.createPage(title, filename, conf.css_path)
link = DisplayHTMLRaw(self, '<iframe src="../_stats.html"></iframe>')
page.appendBlock(link)
_, nb_month_days = monthrange(cur_time.tm_year, cur_time.tm_mon)
days = self.display.createBlock(DisplayHTMLBlockTableWithGraph, self._('By day'), [self._('Day'), self._('Visits'), self._('Pages'), self._('Hits'), self._('Bandwidth'), self._('Not viewed Bandwidth')], None, nb_month_days, range(1,6))
graph_cols=range(1,7)
months = self.display.createBlock(DisplayHTMLBlockTableWithGraph, title, cols, None, 12, graph_cols)
months.setColsCSSClass(['', 'iwla_visitor', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth', ''])
months_ = self.display.createBlock(DisplayHTMLBlockTableWithGraph, title, cols[:-1], None, 12, graph_cols[:-1])
months_.setColsCSSClass(['', 'iwla_visitor', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth'])
total = [0] * len(cols)
for i in range(1, 13):
month = '%s<br/>%d' % (months_name[i], year)
months.setCellValue(i-1, 5, bytesToStr(row[5]))
months.setCellValue(i-1, 6, bytesToStr(row[6]))
months.appendShortTitle(month)
months_.appendRow(row[:-1])
months_.setCellValue(i-1, 5, bytesToStr(row[5]))
months_.setCellValue(i-1, 6, bytesToStr(row[6]))
months_.appendShortTitle(month)
if year == cur_time.tm_year and i == cur_time.tm_mon:
css = months.getCellCSSClass(i-1, 0)
if css: css = '%s %s' % (css, 'iwla_curday')
else: css = 'iwla_curday'
months.setCellCSSClass(i-1, 0, css)
months_.setCellCSSClass(i-1, 0, css)
total[0] = self._('Total')
total[5] = bytesToStr(total[5])
months.appendRow(total)
page.appendBlock(months)
months_.appendRow(total[:-1])
filename = '%d/_stats.html' % (year)
page_ = self.display.createPage(u'', filename, conf.css_path)
page_.appendBlock(months_)
page_.build(conf.DISPLAY_ROOT, False)
def _generateDisplayWholeMonthStats(self):
title = '%s %s' % (self._('Statistics for'), conf.domain_name)
filename = 'index.html'
resources/css/iwla.css
8989
9090
9191
92
text-align:center;
}
iframe {outline:none; border:0px; width:100%; height:500px; display:block;}

Archive Download the corresponding diff file

Branches

Tags