iwla

iwla Commit Details

Date:2014-11-30 19:05:17 (6 years 8 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:81c3aa8099d37a0c6d73e77f2366f36e7272f9f8
Parents: d4170ad3ed47751d75904b4aee0bfa38adfa5b2d
Message:Try to manage CSS path

Changes:
Aresources/icon/vh.png
Aresources/icon/vk.png
Aresources/icon/vp.png
Aresources/icon/vu.png
Aresources/icon/vv.png
Mdefault_conf.py (2 diffs)
Mdisplay.py (4 diffs)
Miwla.py (5 diffs)
Mplugins/display/all_visits.py (1 diff)
Mplugins/display/referers.py (2 diffs)
Mplugins/display/top_downloads.py (1 diff)
Mplugins/display/top_hits.py (1 diff)
Mplugins/display/top_pages.py (1 diff)

File differences

default_conf.py
1
2
13
24
3
4
5
6
57
68
79
......
2729
2830
2931
32
33
34
35
36
import os
# Default configuration
DB_ROOT = './output/'
DISPLAY_ROOT = './output/'
DB_ROOT = './output'
DISPLAY_ROOT = './output'
HOOKS_ROOT = 'plugins'
PRE_HOOK_DIRECTORY = HOOKS_ROOT + '.pre_analysis'
multimedia_files = ['png', 'jpg', 'jpeg', 'gif', 'ico',
'css', 'js']
resources_path = ['resources']
css_path = [os.path.join( '/',
os.path.basename(resources_path[0]),
os.path.join('css', 'iwla.css'))]
display.py
140140
141141
142142
143
143
144144
145145
146146
147
147148
148149
149150
......
169170
170171
171172
172
173
174
173175
174176
175177
......
180182
181183
182184
183
185
184186
187
185188
186189
187190
......
193196
194197
195198
199
200
201
202
203
204
205
196206
197207
198208
class DisplayHTMLPage(object):
def __init__(self, title, filename):
def __init__(self, title, filename, css_path):
self.title = title
self.filename = filename
self.blocks = []
self.css_path = css_path
def getFilename(self):
return self.filename;
f.write('<html>')
f.write('<head>')
f.write('<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />')
f.write('<link rel="stylesheet" href="iwla.css"/>')
for css in self.css_path:
f.write('<link rel="stylesheet" href="%s"/>' % (css))
if self.title:
f.write('<title>%s</title>' % (self.title))
f.write('</head>')
class DisplayHTMLBuild(object):
def __init__(self):
def __init__(self, iwla):
self.pages = []
self.iwla = iwla
def getPage(self, filename):
for page in self.pages:
self.pages.append(page)
def build(self, root):
display_root = self.iwla.getConfValue('DISPLAY_ROOT', '')
for res_path in self.iwla.getResourcesPath():
target = os.path.abspath(res_path)
link_name = os.path.join(display_root, res_path)
if not os.path.exists(link_name):
os.symlink(target, link_name)
for page in self.pages:
page.build(root)
iwla.py
2828
2929
3030
31
31
3232
3333
3434
......
8989
9090
9191
92
93
94
95
96
97
9298
9399
94100
......
96102
97103
98104
99
105
100106
101107
102108
......
108114
109115
110116
111
117
112118
113119
114120
......
232238
233239
234240
235
241
236242
237243
238244
self.analyse_started = False
self.current_analysis = {}
self.cache_plugins = {}
self.display = DisplayHTMLBuild()
self.display = DisplayHTMLBuild(self)
self.valid_visitors = None
self.log_format_extracted = re.sub(r'([^\$\w])', r'\\\g<1>', conf.log_format)
cur_time = self.meta_infos['last_time']
return os.path.join(str(cur_time.tm_year), str(cur_time.tm_mon), filename)
def getResourcesPath(self):
return conf.resources_path
def getCSSPath(self):
return conf.css_path
def _clearMeta(self):
self.meta_infos = {
'last_time' : None
return self.meta_infos
def _clearDisplay(self):
self.display = DisplayHTMLBuild()
self.display = DisplayHTMLBuild(self)
return self.display
def getDBFilename(self, time):
os.makedirs(base)
# TODO : remove return
#return
return
with open(filename + '.tmp', 'wb+') as f:
pickle.dump(obj, f)
title = 'Stats %d/%d' % (cur_time.tm_mon, cur_time.tm_year)
filename = self.getCurDisplayPath('index.html')
print '==> Generate display (%s)' % (filename)
page = DisplayHTMLPage(title, filename)
page = DisplayHTMLPage(title, filename, conf.css_path)
days = DisplayHTMLBlockTable('By day', ['Day', 'Visits', 'Pages', 'Hits', 'Bandwidth', 'Not viewed Bandwidth'])
days.setColsCSSClass(['', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth'])
plugins/display/all_visits.py
2020
2121
2222
23
23
2424
2525
2626
filename = 'all_visits.html'
path = self.iwla.getCurDisplayPath(filename)
page = DisplayHTMLPage(title, path)
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('Last seen', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen'])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', ''])
plugins/display/referers.py
3838
3939
4040
41
41
4242
4343
4444
......
9393
9494
9595
96
96
9797
9898
9999
filename = 'referers.html'
path = self.iwla.getCurDisplayPath(filename)
page = DisplayHTMLPage(title, path)
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('Connexion from', ['Origin', 'Pages', 'Hits'])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit'])
filename = 'key_phrases.html'
path = self.iwla.getCurDisplayPath(filename)
page = DisplayHTMLPage(title, path)
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:
plugins/display/top_downloads.py
1919
2020
2121
22
22
2323
2424
2525
path = self.iwla.getCurDisplayPath(filename)
title = time.strftime('All Downloads - %B %Y', self.iwla.getCurTime())
page = DisplayHTMLPage(title, path)
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('All Downloads', ['URI', 'Hit'])
table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_downloads:
plugins/display/top_hits.py
1919
2020
2121
22
22
2323
2424
2525
filename = 'top_hits.html'
path = self.iwla.getCurDisplayPath(filename)
page = DisplayHTMLPage(title, path)
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('All Hits', ['URI', 'Entrance'])
table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_hits:
plugins/display/top_pages.py
1919
2020
2121
22
22
2323
2424
2525
filename = 'top_pages.html'
path = self.iwla.getCurDisplayPath(filename)
page = DisplayHTMLPage(title, path)
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('All Pages', ['URI', 'Entrance'])
table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_pages:

Archive Download the corresponding diff file

Branches

Tags