Make backup before compressing (low memory servers)

Fix error : Call post hook plugins even in display only mode
Don't compute unordered hits (remove pasts if they are found after current)
Remove tags in stats diff
Don't do geolocalisation is visitor is not valid
Don't try to find search engine on robots
Update robot check rules
Add top_pages_diff plugin
This commit is contained in:
Gregory Soutade
2019-08-30 07:50:54 +02:00
parent ed6ed68706
commit bb268114b2
6 changed files with 131 additions and 36 deletions

View File

@@ -22,6 +22,7 @@ from iwla import IWLA
from iplugin import IPlugin
from display import *
import logging
import re
"""
Display hook interface
@@ -54,9 +55,11 @@ class IWLADisplayStatsDiff(IPlugin):
self.month_stats_key = None
# Set >= if month_stats[self.month_stats_key] is a list or a tuple
self.stats_index = -1
self.display_index = 1
self.filename = None
self.block_name = None
self.logger = logging.getLogger(__name__)
self.tag_re = re.compile(r'<[^>]+>')
def load(self):
if not self.month_stats_key or not self.filename or\
@@ -67,6 +70,10 @@ class IWLADisplayStatsDiff(IPlugin):
self.cur_stats = {k:v for (k,v) in month_stats.get(self.month_stats_key, {}).items()}
return True
# from https://tutorialedge.net/python/removing-html-from-string/
def remove_tags(self, text):
return self.tag_re.sub('', text)
def hook(self):
display = self.iwla.getDisplay()
month_stats = self.iwla.getMonthStats()
@@ -88,14 +95,21 @@ class IWLADisplayStatsDiff(IPlugin):
if new_value:
if self.stats_index != -1:
if new_value[self.stats_index] != v[self.stats_index]:
stats_diff[k] = 'iwla_update'
diff_value = v[self.stats_index] - new_value[self.stats_index]
stats_diff[k] = ['iwla_update', diff_value]
else:
if new_value != v:
stats_diff[k] = 'iwla_update'
diff_value = v - new_value
stats_diff[k] = ['iwla_update', diff_value]
else:
stats_diff[k] = 'iwla_new'
stats_diff[k] = ['iwla_new', 0]
for (idx, row) in enumerate(block.rows):
for k in stats_diff.keys():
if k in row[0]:
block.setCellCSSClass(idx, 0, stats_diff[k])
clear_text = self.remove_tags(row[0])
if clear_text in stats_diff.keys():
(cls, diff) = stats_diff[clear_text]
block.setCellCSSClass(idx, 0, cls)
if diff:
value = block.getCellValue(idx, self.display_index)
value += ' (+%d)' % diff
block.setCellValue(idx, self.display_index, value)