Add all_visits_enlight display plugin

This commit is contained in:
Gregory Soutade 2022-11-20 10:15:13 +01:00
parent 82993afbce
commit 3117aebac0
2 changed files with 90 additions and 1 deletions

View File

@ -0,0 +1,85 @@
# -*- coding: utf-8 -*-
#
# Copyright Grégory Soutadé 2022
# This file is part of iwla
# iwla is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iwla is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iwla. If not, see <http://www.gnu.org/licenses/>.
#
from iwla import IWLA
from iplugin import IPlugin
from display import *
import logging
import re
"""
Display hook
Enlight users in all visits page if visitor['enlight'] property is True
or user is filtered
Can be set in filter users callback
Plugin requirements :
IWLADisplayAllVisits
Conf values needed :
None
Output files :
None
Statistics creation :
None
Statistics update :
None
Statistics deletion :
None
"""
class IWLADisplayAllVisitsEnlight(IPlugin):
def load(self):
self.ip_re = re.compile(r'.*\[(.*)\].*')
return True
def hook(self):
display = self.iwla.getDisplay()
visitors = self.iwla.getValidVisitors()
path = self.iwla.getCurDisplayPath('all_visits.html')
page = display.getPage(path)
if not page:
self.logger.error('No page for %s' % (path))
return
title = self.iwla._('All visits')
block = page.getBlock(title)
if not block:
self.logger.error('Block %s not found' % (title))
return
for (idx, row) in enumerate(block.rows):
# Direct IP
ip = row[0]
if not ip in visitors.keys():
# name [IP]
ip = self.ip_re.match(row[0])
if not ip: continue
ip = ip[1]
if not ip in visitors.keys():
continue
if visitors[ip].get('enlight', False) or\
visitors[ip].get('filtered', False):
block.setCellCSSClass(idx, 0, 'iwla_enlight')

View File

@ -90,3 +90,7 @@ table.iwla_graph_table td
} }
iframe {outline:none; border:0px; width:100%; height:500px; display:block;} iframe {outline:none; border:0px; width:100%; height:500px; display:block;}
.iwla_enlight {
color:orange;
}