iwla

iwla Commit Details

Date:2014-12-05 16:03:09 (6 years 7 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:fd858034fb1e2badc2b5e7d482c9f7d0f1bce67e
Parents: 4cb2736e22dcd856e8c49162ea2e52396b54f036
Message:Add Others field in index

Changes:
Mdisplay.py (1 diff)
Mplugins/display/referers.py (4 diffs)
Mplugins/display/top_downloads.py (2 diffs)
Mplugins/display/top_hits.py (2 diffs)
Mplugins/display/top_pages.py (2 diffs)
Mplugins/display/top_visitors.py (2 diffs)
Mresources/css/iwla.css (1 diff)

File differences

display.py
6666
6767
6868
69
70
71
72
73
74
6975
7076
7177
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):
plugins/display/referers.py
4242
4343
4444
45
4546
4647
4748
49
50
4851
4952
53
5054
5155
5256
57
58
5359
5460
61
5562
5663
5764
65
66
5867
5968
6069
......
7382
7483
7584
85
86
7687
88
89
90
91
7792
7893
7994
8095
96
97
8198
99
100
101
102
82103
83104
84105
85106
107
108
86109
110
111
112
113
87114
88115
89116
......
93120
94121
95122
123
96124
97125
98126
99127
100128
129
101130
102131
103132
......
110139
111140
112141
142
143
144
145
146
113147
table = DisplayHTMLBlockTable('Connexion from', ['Origin', 'Pages', 'Hits'])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit'])
total_search = [0]*3
table.appendRow(['<b>Search Engine</b>', '', ''])
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(['<b>External URL</b>', '', ''])
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(['<b>External URL (robot)</b>', '', ''])
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)
table.appendRow(['<b>Search Engine</b>', '', ''])
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(['<b>External URL</b>', '', ''])
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(['<b>External URL (robot)</b>', '', ''])
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)
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)
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)
plugins/display/top_downloads.py
2222
2323
2424
25
26
2527
2628
29
2730
2831
2932
......
3841
3942
4043
44
45
46
47
48
4149
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)
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)
plugins/display/top_hits.py
2222
2323
2424
25
2526
2627
28
2729
2830
2931
......
3840
3941
4042
43
44
45
46
47
4148
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)
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)
plugins/display/top_pages.py
2222
2323
2424
25
2526
2627
28
2729
2830
2931
......
3840
3941
4042
43
44
45
46
47
4148
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)
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)
plugins/display/top_visitors.py
1111
1212
1313
14
1514
1615
17
18
16
17
18
19
20
21
22
1923
2024
2125
......
3539
3640
3741
42
43
44
3845
46
47
48
49
50
51
3952
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]]
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)
resources/css/iwla.css
6868
6969
7070
71
71
7272
7373
7474
.iwla_search { background : #F4F090; }
.iwla_weekend { background : #ECECEC; }
.iwla_curday { font-weight: bold; }
.iwla_others { color: #668; }
.iwla_graph_table
{
margin-left:auto;

Archive Download the corresponding diff file

Branches

Tags