Fully rework display with CSS style inclusion
This commit is contained in:
@@ -12,20 +12,12 @@ class IWLADisplayTopDownloads(IPlugin):
|
||||
|
||||
def hook(self):
|
||||
top_downloads = self.iwla.getMonthStats()['top_downloads']
|
||||
|
||||
top_downloads = sorted(top_downloads.items(), key=lambda t: t[1], reverse=True)
|
||||
|
||||
index = self.iwla.getDisplayIndex()
|
||||
|
||||
table = DisplayHTMLBlockTable('Top Downloads', ['URI', 'Hits'])
|
||||
for (uri, entrance) in top_downloads[:10]:
|
||||
table.appendRow([uri, entrance])
|
||||
index.appendBlock(table)
|
||||
|
||||
title = time.strftime('Top Downloads - %B %Y', self.iwla.getCurTime())
|
||||
|
||||
# All in a file
|
||||
filename = 'top_downloads.html'
|
||||
path = self.iwla.getCurDisplayPath(filename)
|
||||
title = time.strftime('All Downloads - %B %Y', self.iwla.getCurTime())
|
||||
|
||||
page = DisplayHTMLPage(title, path)
|
||||
table = DisplayHTMLBlockTable('All Downloads', ['URI', 'Hit'])
|
||||
@@ -33,9 +25,15 @@ class IWLADisplayTopDownloads(IPlugin):
|
||||
table.appendRow([uri, entrance])
|
||||
page.appendBlock(table)
|
||||
|
||||
display = self.iwla.getDisplay()
|
||||
display.addPage(page)
|
||||
self.iwla.getDisplay().addPage(page)
|
||||
|
||||
block = DisplayHTMLRawBlock()
|
||||
block.setRawHTML('<a href=\'%s\'>All Downloads</a>' % (filename))
|
||||
index.appendBlock(block)
|
||||
link = '<a href=\'%s\'>All Downloads</a>' % (filename)
|
||||
title = '%s - %s' % ('Top Downloads', link)
|
||||
|
||||
# Top in index
|
||||
index = self.iwla.getDisplayIndex()
|
||||
|
||||
table = DisplayHTMLBlockTable(title, ['URI', 'Hits'])
|
||||
for (uri, entrance) in top_downloads[:10]:
|
||||
table.appendRow([uri, entrance])
|
||||
index.appendBlock(table)
|
||||
|
||||
Reference in New Issue
Block a user