diff --git a/display.py b/display.py
index 0bb6b26..0ffd61d 100644
--- a/display.py
+++ b/display.py
@@ -66,6 +66,12 @@ class DisplayHTMLBlockTable(DisplayHTMLBlock):
self.rows.append(listToStr(row))
self.rows_cssclasses.append([u''] * len(row))
+ def getNbRows(self):
+ return len(self.rows)
+
+ def getNbCols(self):
+ return len(self.cols)
+
def getCellValue(self, row, col):
if row < 0 or col < 0 or\
row >= len(self.rows) or col >= len(self.cols):
diff --git a/plugins/display/referers.py b/plugins/display/referers.py
index 4e28bf1..be08acd 100644
--- a/plugins/display/referers.py
+++ b/plugins/display/referers.py
@@ -42,19 +42,28 @@ class IWLADisplayReferers(IPlugin):
table = DisplayHTMLBlockTable('Connexion from', ['Origin', 'Pages', 'Hits'])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit'])
+ total_search = [0]*3
table.appendRow(['Search Engine', '', ''])
for r,_ in top_search_engine_referers:
row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']]
+ total_search[1] += search_engine_referers[r]['pages']
+ total_search[2] += search_engine_referers[r]['hits']
table.appendRow(row)
+ total_external = [0]*3
table.appendRow(['External URL', '', ''])
for r,_ in top_referers:
row = [generateHTMLLink(r), referers[r]['pages'], referers[r]['hits']]
+ total_external[1] += referers[r]['pages']
+ total_external[2] += referers[r]['hits']
table.appendRow(row)
+ total_robot = [0]*3
table.appendRow(['External URL (robot)', '', ''])
for r,_ in top_robots_referers:
row = [generateHTMLLink(r), robots_referers[r]['pages'], robots_referers[r]['hits']]
+ total_robot[1] += robots_referers[r]['pages']
+ total_robot[2] += robots_referers[r]['hits']
table.appendRow(row)
page.appendBlock(table)
@@ -73,17 +82,35 @@ class IWLADisplayReferers(IPlugin):
table.appendRow(['Search Engine', '', ''])
for r,_ in top_search_engine_referers[:10]:
row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']]
+ total_search[1] -= search_engine_referers[r]['pages']
+ total_search[2] -= search_engine_referers[r]['hits']
table.appendRow(row)
+ if total_search[1] or total_search[2]:
+ total_search[0] = 'Others'
+ table.appendRow(total_search)
+ table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
table.appendRow(['External URL', '', ''])
for r,_ in top_referers[:10]:
row = [generateHTMLLink(r), referers[r]['pages'], referers[r]['hits']]
+ total_external[1] -= referers[r]['pages']
+ total_external[2] -= referers[r]['hits']
table.appendRow(row)
+ if total_external[1] or total_external[2]:
+ total_external[0] = 'Others'
+ table.appendRow(total_external)
+ table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
table.appendRow(['External URL (robot)', '', ''])
for r,_ in top_robots_referers[:10]:
row = [generateHTMLLink(r), robots_referers[r]['pages'], robots_referers[r]['hits']]
+ total_robot[1] -= robots_referers[r]['pages']
+ total_robot[2] -= robots_referers[r]['hits']
table.appendRow(row)
+ if total_robot[1] or total_robot[2]:
+ total_robot[0] = 'Others'
+ table.appendRow(total_robot)
+ table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table)
@@ -93,11 +120,13 @@ class IWLADisplayReferers(IPlugin):
filename = 'key_phrases.html'
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'])
table.setColsCSSClass(['', 'iwla_search'])
for phrase in top_key_phrases:
table.appendRow([phrase[0], phrase[1]])
+ total_search[1] += phrase[1]
page.appendBlock(table)
display.addPage(page)
@@ -110,4 +139,9 @@ class IWLADisplayReferers(IPlugin):
table.setColsCSSClass(['', 'iwla_search'])
for phrase in top_key_phrases[:10]:
table.appendRow([phrase[0], phrase[1]])
+ total_search[1] -= phrase[1]
+ if total_search[1]:
+ total_search[0] = 'Others'
+ table.appendRow(total_search)
+ table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table)
diff --git a/plugins/display/top_downloads.py b/plugins/display/top_downloads.py
index 9629db2..0e42b8d 100644
--- a/plugins/display/top_downloads.py
+++ b/plugins/display/top_downloads.py
@@ -22,8 +22,11 @@ class IWLADisplayTopDownloads(IPlugin):
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('All Downloads', ['URI', 'Hit'])
table.setColsCSSClass(['', 'iwla_hit'])
+
+ total_entrance = [0]*2
for (uri, entrance) in top_downloads:
table.appendRow([generateHTMLLink(uri), entrance])
+ total_entrance[1] += entrance
page.appendBlock(table)
self.iwla.getDisplay().addPage(page)
@@ -38,4 +41,9 @@ class IWLADisplayTopDownloads(IPlugin):
table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_downloads[:10]:
table.appendRow([generateHTMLLink(uri), entrance])
+ total_entrance[1] -= entrance
+ if total_entrance[1]:
+ total_entrance[0] = 'Others'
+ table.appendRow(total_entrance)
+ table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table)
diff --git a/plugins/display/top_hits.py b/plugins/display/top_hits.py
index 107204d..8128fc9 100644
--- a/plugins/display/top_hits.py
+++ b/plugins/display/top_hits.py
@@ -22,8 +22,10 @@ class IWLADisplayTopHits(IPlugin):
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('All Hits', ['URI', 'Entrance'])
table.setColsCSSClass(['', 'iwla_hit'])
+ total_hits = [0]*2
for (uri, entrance) in top_hits:
table.appendRow([generateHTMLLink(uri), entrance])
+ total_hits[1] += entrance
page.appendBlock(table)
self.iwla.getDisplay().addPage(page)
@@ -38,4 +40,9 @@ class IWLADisplayTopHits(IPlugin):
table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_hits[:10]:
table.appendRow([generateHTMLLink(uri), entrance])
+ total_hits[1] -= entrance
+ if total_hits[1]:
+ total_hits[0] = 'Others'
+ table.appendRow(total_hits)
+ table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table)
diff --git a/plugins/display/top_pages.py b/plugins/display/top_pages.py
index 23f9dfe..0c7211e 100644
--- a/plugins/display/top_pages.py
+++ b/plugins/display/top_pages.py
@@ -22,8 +22,10 @@ class IWLADisplayTopPages(IPlugin):
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('All Pages', ['URI', 'Entrance'])
table.setColsCSSClass(['', 'iwla_hit'])
+ total_hits = [0]*2
for (uri, entrance) in top_pages:
table.appendRow([generateHTMLLink(uri), entrance])
+ total_hits[1] += entrance
page.appendBlock(table)
self.iwla.getDisplay().addPage(page)
@@ -38,4 +40,9 @@ class IWLADisplayTopPages(IPlugin):
table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_pages[:10]:
table.appendRow([generateHTMLLink(uri), entrance])
+ total_hits[1] -= entrance
+ if total_hits[1]:
+ total_hits[0] = 'Others'
+ table.appendRow(total_hits)
+ table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table)
diff --git a/plugins/display/top_visitors.py b/plugins/display/top_visitors.py
index fa4eecf..1711005 100644
--- a/plugins/display/top_visitors.py
+++ b/plugins/display/top_visitors.py
@@ -11,11 +11,15 @@ class IWLADisplayTopVisitors(IPlugin):
def hook(self):
hits = self.iwla.getValidVisitors()
- count_hit_only = self.iwla.getConfValue('count_hit_only_visitors', False)
display_visitor_ip = self.iwla.getConfValue('display_visitor_ip', False)
- top_bandwidth = [(k,v['bandwidth']) for (k,v) in hits.items() \
- if count_hit_only or v['viewed_pages']]
+ total = [0]*5
+ for super_hit in hits.values():
+ total[1] += super_hit['viewed_pages']
+ total[2] += super_hit['viewed_hits']
+ total[3] += super_hit['bandwidth']
+
+ top_bandwidth = [(k,v['bandwidth']) for (k,v) in hits.items()]
top_bandwidth = sorted(top_bandwidth, key=lambda t: t[1], reverse=True)
top_visitors = [hits[h[0]] for h in top_bandwidth[:10]]
@@ -35,5 +39,14 @@ class IWLADisplayTopVisitors(IPlugin):
bytesToStr(super_hit['bandwidth']),
time.asctime(super_hit['last_access'])
]
+ total[1] -= super_hit['viewed_pages']
+ total[2] -= super_hit['viewed_hits']
+ total[3] -= super_hit['bandwidth']
table.appendRow(row)
+ if total[1] or total[2] or total[3]:
+ total[0] = 'Others'
+ total[3] = bytesToStr(total[3])
+ total[4] = ''
+ table.appendRow(total)
+ table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table)
diff --git a/resources/css/iwla.css b/resources/css/iwla.css
index 5371769..71b652b 100644
--- a/resources/css/iwla.css
+++ b/resources/css/iwla.css
@@ -68,7 +68,7 @@ td:first-child
.iwla_search { background : #F4F090; }
.iwla_weekend { background : #ECECEC; }
.iwla_curday { font-weight: bold; }
-
+.iwla_others { color: #668; }
.iwla_graph_table
{
margin-left:auto;