diff --git a/conf.py b/conf.py index e26b953..fd015b5 100644 --- a/conf.py +++ b/conf.py @@ -12,7 +12,7 @@ display_visitor_ip = True # Hooks used pre_analysis_hooks = ['page_to_hit', 'robots'] post_analysis_hooks = ['referers', 'top_pages', 'top_downloads', 'top_hits']#, 'reverse_dns'] -display_hooks = ['top_visitors', 'all_visits', 'referers', 'top_pages', 'top_downloads', 'top_hits'] +display_hooks = ['top_visitors', 'all_visits', 'referers', 'top_pages', 'top_downloads', 'top_hits', 'referers_diff'] # Reverse DNS timeout reverse_dns_timeout = 0.2 diff --git a/docs/index.md b/docs/index.md index 1a3b36c..aa927c0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -175,34 +175,6 @@ iwla None -plugins.display.top_downloads ------------------------------ - - Display hook - - Create TOP downloads page - - Plugin requirements : - post_analysis/top_downloads - - Conf values needed : - max_downloads_displayed* - create_all_downloads_page* - - Output files : - OUTPUT_ROOT/year/month/top_downloads.html - OUTPUT_ROOT/year/month/index.html - - Statistics creation : - None - - Statistics update : - None - - Statistics deletion : - None - - plugins.display.all_visits -------------------------- @@ -230,34 +202,6 @@ plugins.display.all_visits None -plugins.display.top_hits ------------------------- - - Display hook - - Create TOP hits page - - Plugin requirements : - post_analysis/top_hits - - Conf values needed : - max_hits_displayed* - create_all_hits_page* - - Output files : - OUTPUT_ROOT/year/month/top_hits.html - OUTPUT_ROOT/year/month/index.html - - Statistics creation : - None - - Statistics update : - None - - Statistics deletion : - None - - plugins.display.referers ------------------------ @@ -289,20 +233,50 @@ plugins.display.referers None -plugins.display.top_visitors ----------------------------- +plugins.display.top_downloads +----------------------------- Display hook - Create TOP visitors block + Create TOP downloads page Plugin requirements : - None + post_analysis/top_downloads Conf values needed : - display_visitor_ip* + max_downloads_displayed* + create_all_downloads_page* Output files : + OUTPUT_ROOT/year/month/top_downloads.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.top_hits +------------------------ + + Display hook + + Create TOP hits page + + Plugin requirements : + post_analysis/top_hits + + Conf values needed : + max_hits_displayed* + create_all_hits_page* + + Output files : + OUTPUT_ROOT/year/month/top_hits.html OUTPUT_ROOT/year/month/index.html Statistics creation : @@ -343,43 +317,41 @@ plugins.display.top_pages None -plugins.post_analysis.top_downloads ------------------------------------ +plugins.display.top_visitors +---------------------------- - Post analysis hook + Display hook - Count TOP downloads + Create TOP visitors block Plugin requirements : None Conf values needed : - None + display_visitor_ip* Output files : - None + OUTPUT_ROOT/year/month/index.html Statistics creation : None Statistics update : - month_stats: - top_downloads => - uri + None Statistics deletion : None -plugins.post_analysis.top_hits ------------------------------- +plugins.display.referers_diff +----------------------------- - Post analysis hook + Display hook - Count TOP hits + Enlight new and updated key phrases in in all_key_phrases.html Plugin requirements : - None + display/referers Conf values needed : None @@ -391,9 +363,7 @@ plugins.post_analysis.top_hits None Statistics update : - month_stats: - top_hits => - uri + None Statistics deletion : None @@ -465,6 +435,62 @@ plugins.post_analysis.reverse_dns None +plugins.post_analysis.top_downloads +----------------------------------- + + Post analysis hook + + Count TOP downloads + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_downloads => + uri + + Statistics deletion : + None + + +plugins.post_analysis.top_hits +------------------------------ + + Post analysis hook + + Count TOP hits + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_hits => + uri + + Statistics deletion : + None + + plugins.post_analysis.top_pages ------------------------------- diff --git a/docs/modules.md b/docs/modules.md index 41167c3..f530620 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -83,34 +83,6 @@ iwla None -plugins.display.top_downloads ------------------------------ - - Display hook - - Create TOP downloads page - - Plugin requirements : - post_analysis/top_downloads - - Conf values needed : - max_downloads_displayed* - create_all_downloads_page* - - Output files : - OUTPUT_ROOT/year/month/top_downloads.html - OUTPUT_ROOT/year/month/index.html - - Statistics creation : - None - - Statistics update : - None - - Statistics deletion : - None - - plugins.display.all_visits -------------------------- @@ -138,34 +110,6 @@ plugins.display.all_visits None -plugins.display.top_hits ------------------------- - - Display hook - - Create TOP hits page - - Plugin requirements : - post_analysis/top_hits - - Conf values needed : - max_hits_displayed* - create_all_hits_page* - - Output files : - OUTPUT_ROOT/year/month/top_hits.html - OUTPUT_ROOT/year/month/index.html - - Statistics creation : - None - - Statistics update : - None - - Statistics deletion : - None - - plugins.display.referers ------------------------ @@ -197,20 +141,50 @@ plugins.display.referers None -plugins.display.top_visitors ----------------------------- +plugins.display.top_downloads +----------------------------- Display hook - Create TOP visitors block + Create TOP downloads page Plugin requirements : - None + post_analysis/top_downloads Conf values needed : - display_visitor_ip* + max_downloads_displayed* + create_all_downloads_page* Output files : + OUTPUT_ROOT/year/month/top_downloads.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.top_hits +------------------------ + + Display hook + + Create TOP hits page + + Plugin requirements : + post_analysis/top_hits + + Conf values needed : + max_hits_displayed* + create_all_hits_page* + + Output files : + OUTPUT_ROOT/year/month/top_hits.html OUTPUT_ROOT/year/month/index.html Statistics creation : @@ -251,43 +225,41 @@ plugins.display.top_pages None -plugins.post_analysis.top_downloads ------------------------------------ +plugins.display.top_visitors +---------------------------- - Post analysis hook + Display hook - Count TOP downloads + Create TOP visitors block Plugin requirements : None Conf values needed : - None + display_visitor_ip* Output files : - None + OUTPUT_ROOT/year/month/index.html Statistics creation : None Statistics update : - month_stats: - top_downloads => - uri + None Statistics deletion : None -plugins.post_analysis.top_hits ------------------------------- +plugins.display.referers_diff +----------------------------- - Post analysis hook + Display hook - Count TOP hits + Enlight new and updated key phrases in in all_key_phrases.html Plugin requirements : - None + display/referers Conf values needed : None @@ -299,9 +271,7 @@ plugins.post_analysis.top_hits None Statistics update : - month_stats: - top_hits => - uri + None Statistics deletion : None @@ -373,6 +343,62 @@ plugins.post_analysis.reverse_dns None +plugins.post_analysis.top_downloads +----------------------------------- + + Post analysis hook + + Count TOP downloads + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_downloads => + uri + + Statistics deletion : + None + + +plugins.post_analysis.top_hits +------------------------------ + + Post analysis hook + + Count TOP hits + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_hits => + uri + + Statistics deletion : + None + + plugins.post_analysis.top_pages ------------------------------- diff --git a/plugins/display/referers.py b/plugins/display/referers.py index bdd04a5..777dc8a 100644 --- a/plugins/display/referers.py +++ b/plugins/display/referers.py @@ -197,7 +197,7 @@ class IWLADisplayReferers(IPlugin): total_search = [0]*2 page = display.createPage(title, path, self.iwla.getConfValue('css_path', [])) - table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Top key phrases'), [self.iwla._(u'Key phrase'), self.iwla._(u'Search')]) + table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'All key phrases'), [self.iwla._(u'Key phrase'), self.iwla._(u'Search')]) table.setColsCSSClass(['', 'iwla_search']) new_list = self.max_key_phrases and top_key_phrases[:self.max_key_phrases] or top_key_phrases for phrase in new_list: diff --git a/plugins/display/referers_diff.py b/plugins/display/referers_diff.py new file mode 100644 index 0000000..ddfd91b --- /dev/null +++ b/plugins/display/referers_diff.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# 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 * + +""" +Display hook + +Enlight new and updated key phrases in in all_key_phrases.html + +Plugin requirements : + display/referers + +Conf values needed : + None + +Output files : + None + +Statistics creation : + None + +Statistics update : + None + +Statistics deletion : + None +""" + +class IWLADisplayReferersDiff(IPlugin): + def __init__(self, iwla): + super(IWLADisplayReferersDiff, self).__init__(iwla) + self.API_VERSION = 1 + self.requires = ['IWLADisplayReferers'] + + def load(self): + if not self.iwla.getConfValue('create_all_key_phrases_page', True): + return False + month_stats = self.iwla.getMonthStats() + self.cur_key_phrases = {k:v for (k,v) in month_stats.get('key_phrases', {})} + return True + + def hook(self): + display = self.iwla.getDisplay() + month_stats = self.iwla.getMonthStats() + + filename = 'key_phrases.html' + path = self.iwla.getCurDisplayPath(filename) + page = display.getPage(path) + if not page: return + title = self.iwla._(u'All key phrases') + referers_block = page.getBlock(title) + + kp_diff = {} + for (k, v) in month_stats['key_phrases'].items(): + new_value = self.cur_key_phrases.get(k, 0) + if new_value: + if new_value != v: + kp_diff[k] = 'iwla_update' + else: + kp_diff[k] = 'iwla_new' + + for (idx, row) in enumerate(referers_block.rows): + if row[0] in kp_diff.keys(): + referers_block.setCellCSSClass(idx, 0, kp_diff[row[0]]) diff --git a/resources/css/iwla.css b/resources/css/iwla.css index 71b652b..fe4d5ab 100644 --- a/resources/css/iwla.css +++ b/resources/css/iwla.css @@ -69,6 +69,9 @@ td:first-child .iwla_weekend { background : #ECECEC; } .iwla_curday { font-weight: bold; } .iwla_others { color: #668; } +.iwla_update { background : orange; } +.iwla_new { background : green } + .iwla_graph_table { margin-left:auto; @@ -85,3 +88,4 @@ table.iwla_graph_table td { text-align:center; } +