diff --git a/plugins/display/all_visits_enlight.py b/plugins/display/all_visits_enlight.py new file mode 100644 index 0000000..35172f2 --- /dev/null +++ b/plugins/display/all_visits_enlight.py @@ -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 . +# + +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') diff --git a/resources/css/iwla.css b/resources/css/iwla.css index add0e57..89b2abf 100644 --- a/resources/css/iwla.css +++ b/resources/css/iwla.css @@ -89,4 +89,8 @@ table.iwla_graph_table td text-align:center; } -iframe {outline:none; border:0px; width:100%; height:500px; display:block;} \ No newline at end of file +iframe {outline:none; border:0px; width:100%; height:500px; display:block;} + +.iwla_enlight { + color:orange; +}