Try to manage CSS path
This commit is contained in:
parent
d4170ad3ed
commit
81c3aa8099
|
@ -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'))]
|
||||
|
|
16
display.py
16
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('<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>')
|
||||
|
@ -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)
|
||||
|
||||
|
|
14
iwla.py
14
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'])
|
||||
|
|
|
@ -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', ''])
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
BIN
resources/icon/vh.png
Normal file
BIN
resources/icon/vh.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 239 B |
BIN
resources/icon/vk.png
Normal file
BIN
resources/icon/vk.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 236 B |
BIN
resources/icon/vp.png
Normal file
BIN
resources/icon/vp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 248 B |
BIN
resources/icon/vu.png
Normal file
BIN
resources/icon/vu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 239 B |
BIN
resources/icon/vv.png
Normal file
BIN
resources/icon/vv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 239 B |
Loading…
Reference in New Issue
Block a user