diff --git a/default_conf.py b/default_conf.py
index 48ce1df..1d5e1b4 100644
--- a/default_conf.py
+++ b/default_conf.py
@@ -1,7 +1,9 @@
+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'
@@ -27,3 +29,8 @@ count_hit_only_visitors = True
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'))]
diff --git a/display.py b/display.py
index bcecc3c..6750309 100644
--- a/display.py
+++ b/display.py
@@ -140,10 +140,11 @@ class DisplayHTMLBlockTable(DisplayHTMLBlock):
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;
@@ -169,7 +170,8 @@ class DisplayHTMLPage(object):
f.write('')
f.write('
')
f.write('')
- f.write('')
+ for css in self.css_path:
+ f.write('' % (css))
if self.title:
f.write('%s' % (self.title))
f.write('')
@@ -180,8 +182,9 @@ class DisplayHTMLPage(object):
class DisplayHTMLBuild(object):
- def __init__(self):
+ def __init__(self, iwla):
self.pages = []
+ self.iwla = iwla
def getPage(self, filename):
for page in self.pages:
@@ -193,6 +196,13 @@ class DisplayHTMLBuild(object):
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)
diff --git a/iwla.py b/iwla.py
index d4fff1e..5896422 100755
--- a/iwla.py
+++ b/iwla.py
@@ -28,7 +28,7 @@ class IWLA(object):
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)
@@ -89,6 +89,12 @@ class IWLA(object):
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
@@ -96,7 +102,7 @@ class IWLA(object):
return self.meta_infos
def _clearDisplay(self):
- self.display = DisplayHTMLBuild()
+ self.display = DisplayHTMLBuild(self)
return self.display
def getDBFilename(self, time):
@@ -108,7 +114,7 @@ class IWLA(object):
os.makedirs(base)
# TODO : remove return
- #return
+ return
with open(filename + '.tmp', 'wb+') as f:
pickle.dump(obj, f)
@@ -232,7 +238,7 @@ class IWLA(object):
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'])
diff --git a/plugins/display/all_visits.py b/plugins/display/all_visits.py
index ef5e71c..42a5b3c 100644
--- a/plugins/display/all_visits.py
+++ b/plugins/display/all_visits.py
@@ -20,7 +20,7 @@ class IWLADisplayAllVisits(IPlugin):
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', ''])
diff --git a/plugins/display/referers.py b/plugins/display/referers.py
index 60bc154..36381bc 100644
--- a/plugins/display/referers.py
+++ b/plugins/display/referers.py
@@ -38,7 +38,7 @@ class IWLADisplayReferers(IPlugin):
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'])
@@ -93,7 +93,7 @@ class IWLADisplayReferers(IPlugin):
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:
diff --git a/plugins/display/top_downloads.py b/plugins/display/top_downloads.py
index 727c138..baf6a1b 100644
--- a/plugins/display/top_downloads.py
+++ b/plugins/display/top_downloads.py
@@ -19,7 +19,7 @@ class IWLADisplayTopDownloads(IPlugin):
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:
diff --git a/plugins/display/top_hits.py b/plugins/display/top_hits.py
index 9beecd1..05b74eb 100644
--- a/plugins/display/top_hits.py
+++ b/plugins/display/top_hits.py
@@ -19,7 +19,7 @@ class IWLADisplayTopHits(IPlugin):
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:
diff --git a/plugins/display/top_pages.py b/plugins/display/top_pages.py
index bf7c907..5533166 100644
--- a/plugins/display/top_pages.py
+++ b/plugins/display/top_pages.py
@@ -19,7 +19,7 @@ class IWLADisplayTopPages(IPlugin):
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:
diff --git a/resources/icon/vh.png b/resources/icon/vh.png
new file mode 100644
index 0000000..13e52f9
Binary files /dev/null and b/resources/icon/vh.png differ
diff --git a/resources/icon/vk.png b/resources/icon/vk.png
new file mode 100644
index 0000000..ac1bc63
Binary files /dev/null and b/resources/icon/vk.png differ
diff --git a/resources/icon/vp.png b/resources/icon/vp.png
new file mode 100644
index 0000000..8ebf702
Binary files /dev/null and b/resources/icon/vp.png differ
diff --git a/resources/icon/vu.png b/resources/icon/vu.png
new file mode 100644
index 0000000..7d39356
Binary files /dev/null and b/resources/icon/vu.png differ
diff --git a/resources/icon/vv.png b/resources/icon/vv.png
new file mode 100644
index 0000000..d5b7cdd
Binary files /dev/null and b/resources/icon/vv.png differ