Fully rework display with CSS style inclusion

This commit is contained in:
2014-11-27 19:38:41 +01:00
parent 02233f2f37
commit d2b0d0dae6
6 changed files with 176 additions and 104 deletions

View File

@@ -12,30 +12,28 @@ class IWLADisplayTopHits(IPlugin):
def hook(self):
top_hits = self.iwla.getMonthStats()['top_hits']
top_hits = sorted(top_hits.items(), key=lambda t: t[1], reverse=True)
index = self.iwla.getDisplayIndex()
table = DisplayHTMLBlockTable('Top Hits', ['URI', 'Entrance'])
for (uri, entrance) in top_hits[:10]:
table.appendRow([uri, entrance])
index.appendBlock(table)
# All in a file
title = time.strftime('All Hits - %B %Y', self.iwla.getCurTime())
filename = 'top_hits.html'
path = self.iwla.getCurDisplayPath(filename)
page = DisplayHTMLPage(title, path)
table = DisplayHTMLBlockTable('Top Hits', ['URI', 'Entrance'])
table = DisplayHTMLBlockTable('All Hits', ['URI', 'Entrance'])
for (uri, entrance) in top_hits:
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 hits</a>' % (filename))
index.appendBlock(block)
link = '<a href=\'%s\'>All hits</a>' % (filename)
title = '%s - %s' % ('Top Hits', link)
# Top in index
index = self.iwla.getDisplayIndex()
table = DisplayHTMLBlockTable(title, ['URI', 'Entrance'])
for (uri, entrance) in top_hits[:10]:
table.appendRow([uri, entrance])
index.appendBlock(table)