Give iwla to each display class

Add generic functions createPage() and createBlock() in DisplayHTMLBuild
Add and display IWLA version
This commit is contained in:
Grégory Soutadé
2014-12-08 14:13:26 +01:00
parent fd858034fb
commit 010c16caca
9 changed files with 58 additions and 42 deletions

View File

@@ -11,6 +11,7 @@ class IWLADisplayTopDownloads(IPlugin):
self.requires = ['IWLAPostAnalysisTopDownloads']
def hook(self):
display = self.iwla.getDisplay()
top_downloads = self.iwla.getMonthStats()['top_downloads']
top_downloads = sorted(top_downloads.items(), key=lambda t: t[1], reverse=True)
@@ -19,8 +20,8 @@ class IWLADisplayTopDownloads(IPlugin):
path = self.iwla.getCurDisplayPath(filename)
title = time.strftime('All Downloads - %B %Y', self.iwla.getCurTime())
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('All Downloads', ['URI', 'Hit'])
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
table = display.createBlock(DisplayHTMLBlockTable, 'All Downloads', ['URI', 'Hit'])
table.setColsCSSClass(['', 'iwla_hit'])
total_entrance = [0]*2
@@ -29,7 +30,7 @@ class IWLADisplayTopDownloads(IPlugin):
total_entrance[1] += entrance
page.appendBlock(table)
self.iwla.getDisplay().addPage(page)
display.addPage(page)
link = '<a href=\'%s\'>All Downloads</a>' % (filename)
title = '%s - %s' % ('Top Downloads', link)
@@ -37,7 +38,7 @@ class IWLADisplayTopDownloads(IPlugin):
# Top in index
index = self.iwla.getDisplayIndex()
table = DisplayHTMLBlockTable(title, ['URI', 'Hits'])
table = display.createBlock(DisplayHTMLBlockTable, title, ['URI', 'Hits'])
table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_downloads[:10]:
table.appendRow([generateHTMLLink(uri), entrance])