Give iwla to each display class
Add generic functions createPage() and createBlock() in DisplayHTMLBuild Add and display IWLA version
This commit is contained in:
@@ -10,6 +10,7 @@ class IWLADisplayAllVisits(IPlugin):
|
||||
self.API_VERSION = 1
|
||||
|
||||
def hook(self):
|
||||
display = self.iwla.getDisplay()
|
||||
hits = self.iwla.getValidVisitors()
|
||||
display_visitor_ip = self.iwla.getConfValue('display_visitor_ip', False)
|
||||
|
||||
@@ -20,8 +21,8 @@ class IWLADisplayAllVisits(IPlugin):
|
||||
filename = 'all_visits.html'
|
||||
path = self.iwla.getCurDisplayPath(filename)
|
||||
|
||||
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
|
||||
table = DisplayHTMLBlockTable('Last seen', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
|
||||
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
|
||||
table = display.createBlock(DisplayHTMLBlockTable, 'Last seen', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
|
||||
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', ''])
|
||||
|
||||
for super_hit in last_access:
|
||||
@@ -40,7 +41,6 @@ class IWLADisplayAllVisits(IPlugin):
|
||||
table.appendRow(row)
|
||||
page.appendBlock(table)
|
||||
|
||||
display = self.iwla.getDisplay()
|
||||
display.addPage(page)
|
||||
|
||||
index = self.iwla.getDisplayIndex()
|
||||
@@ -49,6 +49,6 @@ class IWLADisplayAllVisits(IPlugin):
|
||||
if block:
|
||||
block.setTitle('%s - %s' % (block.getTitle(), link))
|
||||
else:
|
||||
block = DisplayHTMLRawBlock()
|
||||
block = display.createBlock(DisplayHTMLRawBlock)
|
||||
block.setRawHTML(link)
|
||||
index.appendBlock(block)
|
||||
|
@@ -11,6 +11,7 @@ class IWLADisplayReferers(IPlugin):
|
||||
self.requires = ['IWLAPostAnalysisReferers']
|
||||
|
||||
def hook(self):
|
||||
display = self.iwla.getDisplay()
|
||||
month_stats = self.iwla.getMonthStats()
|
||||
referers = month_stats.get('referers', {})
|
||||
robots_referers = month_stats.get('robots_referers', {})
|
||||
@@ -38,8 +39,8 @@ class IWLADisplayReferers(IPlugin):
|
||||
filename = 'referers.html'
|
||||
path = self.iwla.getCurDisplayPath(filename)
|
||||
|
||||
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
|
||||
table = DisplayHTMLBlockTable('Connexion from', ['Origin', 'Pages', 'Hits'])
|
||||
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
|
||||
table = display.createBlock(DisplayHTMLBlockTable, 'Connexion from', ['Origin', 'Pages', 'Hits'])
|
||||
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit'])
|
||||
|
||||
total_search = [0]*3
|
||||
@@ -68,7 +69,6 @@ class IWLADisplayReferers(IPlugin):
|
||||
|
||||
page.appendBlock(table)
|
||||
|
||||
display = self.iwla.getDisplay()
|
||||
display.addPage(page)
|
||||
|
||||
link = '<a href=\'%s\'>All referers</a>' % (filename)
|
||||
@@ -76,7 +76,7 @@ class IWLADisplayReferers(IPlugin):
|
||||
# Top referers in index
|
||||
title = '%s - %s' % ('Connexion from', link)
|
||||
|
||||
table = DisplayHTMLBlockTable(title, ['Origin', 'Pages', 'Hits'])
|
||||
table = display.createBlock(DisplayHTMLBlockTable, title, ['Origin', 'Pages', 'Hits'])
|
||||
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit'])
|
||||
|
||||
table.appendRow(['<b>Search Engine</b>', '', ''])
|
||||
@@ -121,8 +121,8 @@ class IWLADisplayReferers(IPlugin):
|
||||
path = self.iwla.getCurDisplayPath(filename)
|
||||
|
||||
total_search = [0]*2
|
||||
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
|
||||
table = DisplayHTMLBlockTable('Top key phrases', ['Key phrase', 'Search'])
|
||||
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
|
||||
table = display.createBlock(DisplayHTMLBlockTable, 'Top key phrases', ['Key phrase', 'Search'])
|
||||
table.setColsCSSClass(['', 'iwla_search'])
|
||||
for phrase in top_key_phrases:
|
||||
table.appendRow([phrase[0], phrase[1]])
|
||||
@@ -135,7 +135,7 @@ class IWLADisplayReferers(IPlugin):
|
||||
|
||||
# Top key phrases in index
|
||||
title = '%s - %s' % ('Top key phrases', link)
|
||||
table = DisplayHTMLBlockTable(title, ['Key phrase', 'Search'])
|
||||
table = display.createBlock(DisplayHTMLBlockTable, title, ['Key phrase', 'Search'])
|
||||
table.setColsCSSClass(['', 'iwla_search'])
|
||||
for phrase in top_key_phrases[:10]:
|
||||
table.appendRow([phrase[0], phrase[1]])
|
||||
|
@@ -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])
|
||||
|
@@ -11,6 +11,7 @@ class IWLADisplayTopHits(IPlugin):
|
||||
self.requires = ['IWLAPostAnalysisTopHits']
|
||||
|
||||
def hook(self):
|
||||
display = self.iwla.getDisplay()
|
||||
top_hits = self.iwla.getMonthStats()['top_hits']
|
||||
top_hits = sorted(top_hits.items(), key=lambda t: t[1], reverse=True)
|
||||
|
||||
@@ -19,8 +20,8 @@ class IWLADisplayTopHits(IPlugin):
|
||||
filename = 'top_hits.html'
|
||||
path = self.iwla.getCurDisplayPath(filename)
|
||||
|
||||
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
|
||||
table = DisplayHTMLBlockTable('All Hits', ['URI', 'Entrance'])
|
||||
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
|
||||
table = display.createBlock(DisplayHTMLBlockTable, 'All Hits', ['URI', 'Entrance'])
|
||||
table.setColsCSSClass(['', 'iwla_hit'])
|
||||
total_hits = [0]*2
|
||||
for (uri, entrance) in top_hits:
|
||||
@@ -28,7 +29,7 @@ class IWLADisplayTopHits(IPlugin):
|
||||
total_hits[1] += entrance
|
||||
page.appendBlock(table)
|
||||
|
||||
self.iwla.getDisplay().addPage(page)
|
||||
display.addPage(page)
|
||||
|
||||
link = '<a href=\'%s\'>All hits</a>' % (filename)
|
||||
title = '%s - %s' % ('Top Hits', link)
|
||||
@@ -36,7 +37,7 @@ class IWLADisplayTopHits(IPlugin):
|
||||
# Top in index
|
||||
index = self.iwla.getDisplayIndex()
|
||||
|
||||
table = DisplayHTMLBlockTable(title, ['URI', 'Entrance'])
|
||||
table = display.createBlock(DisplayHTMLBlockTable, title, ['URI', 'Entrance'])
|
||||
table.setColsCSSClass(['', 'iwla_hit'])
|
||||
for (uri, entrance) in top_hits[:10]:
|
||||
table.appendRow([generateHTMLLink(uri), entrance])
|
||||
|
@@ -11,6 +11,7 @@ class IWLADisplayTopPages(IPlugin):
|
||||
self.requires = ['IWLAPostAnalysisTopPages']
|
||||
|
||||
def hook(self):
|
||||
display = self.iwla.getDisplay()
|
||||
top_pages = self.iwla.getMonthStats()['top_pages']
|
||||
top_pages = sorted(top_pages.items(), key=lambda t: t[1], reverse=True)
|
||||
|
||||
@@ -19,8 +20,8 @@ class IWLADisplayTopPages(IPlugin):
|
||||
filename = 'top_pages.html'
|
||||
path = self.iwla.getCurDisplayPath(filename)
|
||||
|
||||
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
|
||||
table = DisplayHTMLBlockTable('All Pages', ['URI', 'Entrance'])
|
||||
page = display.createPage(title, path, self.iwla.getConfValue('css_path', []))
|
||||
table = display.createBlock(DisplayHTMLBlockTable, 'All Pages', ['URI', 'Entrance'])
|
||||
table.setColsCSSClass(['', 'iwla_hit'])
|
||||
total_hits = [0]*2
|
||||
for (uri, entrance) in top_pages:
|
||||
@@ -28,7 +29,7 @@ class IWLADisplayTopPages(IPlugin):
|
||||
total_hits[1] += entrance
|
||||
page.appendBlock(table)
|
||||
|
||||
self.iwla.getDisplay().addPage(page)
|
||||
display.addPage(page)
|
||||
|
||||
link = '<a href=\'%s\'>All pages</a>' % (filename)
|
||||
title = '%s - %s' % ('Top Pages', link)
|
||||
@@ -36,7 +37,7 @@ class IWLADisplayTopPages(IPlugin):
|
||||
# Top in index
|
||||
index = self.iwla.getDisplayIndex()
|
||||
|
||||
table = DisplayHTMLBlockTable(title, ['URI', 'Entrance'])
|
||||
table = display.createBlock(DisplayHTMLBlockTable, title, ['URI', 'Entrance'])
|
||||
table.setColsCSSClass(['', 'iwla_hit'])
|
||||
for (uri, entrance) in top_pages[:10]:
|
||||
table.appendRow([generateHTMLLink(uri), entrance])
|
||||
|
@@ -11,6 +11,7 @@ class IWLADisplayTopVisitors(IPlugin):
|
||||
|
||||
def hook(self):
|
||||
hits = self.iwla.getValidVisitors()
|
||||
display = self.iwla.getDisplay()
|
||||
display_visitor_ip = self.iwla.getConfValue('display_visitor_ip', False)
|
||||
|
||||
total = [0]*5
|
||||
@@ -24,7 +25,7 @@ class IWLADisplayTopVisitors(IPlugin):
|
||||
top_visitors = [hits[h[0]] for h in top_bandwidth[:10]]
|
||||
|
||||
index = self.iwla.getDisplayIndex()
|
||||
table = DisplayHTMLBlockTable('Top visitors', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
|
||||
table = display.createBlock(DisplayHTMLBlockTable, 'Top visitors', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
|
||||
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', ''])
|
||||
for super_hit in top_visitors:
|
||||
address = super_hit['remote_addr']
|
||||
|
Reference in New Issue
Block a user