From 7b9d4cf89c2650f635770a9580758e3727cbe038 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Tue, 4 Apr 2023 16:03:13 +0200 Subject: [PATCH] Statistics for statoolinfos OK. Other fixes. Can show-wip/show-www stats --- src/usr/bin/tyto | 32 ++- src/var/lib/tyto/program/db.py | 30 ++- src/var/lib/tyto/program/dom.py | 76 +++--- src/var/lib/tyto/program/form.py | 7 +- src/var/lib/tyto/program/infos.py | 30 ++- src/var/lib/tyto/program/langs.py | 4 +- src/var/lib/tyto/program/logs.py | 7 +- src/var/lib/tyto/program/publish.py | 2 +- src/var/lib/tyto/program/show.py | 6 +- src/var/lib/tyto/program/stats.py | 299 ++++++++++++++--------- src/var/lib/tyto/program/status.py | 3 +- src/var/lib/tyto/program/tyto.py | 1 - src/var/lib/tyto/program/wip.py | 2 +- src/var/lib/tyto/translations/logs_en.py | 1 + src/var/lib/tyto/translations/logs_fr.py | 1 + src/var/lib/tyto/translations/site_en.py | 15 +- src/var/lib/tyto/translations/site_fr.py | 14 +- 17 files changed, 332 insertions(+), 198 deletions(-) diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index f4c9f0f..93791f1 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,13 +1,27 @@ #!/usr/bin/env python3 -# Version: 0.9.1 -# Name: Tyto - Littérateur -# Type: Executable -# Description: Multiple Static Websites generator and manager -# file: tyto -# Folder: /usr/local/bin/ -# By echolib (XMPP: im@echolib.re) -# Repo: https://git.a-lec.org/echolib/tyto.git -# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 +# Tyto - Littérateur +# +# Copyright (C) 2023 Cyrille Louarn +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or of the License, or (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +#---------------------------------------------------------------------- +# XMPP: echolib (im@echolib.re) +# +# Description: Main binary to execute +# File: /usr/bin/tyto +#---------------------------------------------------------------------- #------------ # funny stats diff --git a/src/var/lib/tyto/program/db.py b/src/var/lib/tyto/program/db.py index 8ed7559..47632d5 100644 --- a/src/var/lib/tyto/program/db.py +++ b/src/var/lib/tyto/program/db.py @@ -1,11 +1,27 @@ #!/usr/bin/env python3 -# Name: Tyto - Littérateur -# Type: DB for article -# Description: Search article database and exec -# file: db.py -# Folder: /var/lib/tyto/program/ -# By echolib (XMPP: im@echolib.re) -# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 +# Tyto - Littérateur +# +# Copyright (C) 2023 Cyrille Louarn +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or of the License, or (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +#---------------------------------------------------------------------- +# XMPP: echolib (im@echolib.re) +# +# Description: Load article's database and check validity +# File: /var/lib/tyto/program/db.py +#---------------------------------------------------------------------- #------------ # funny stats diff --git a/src/var/lib/tyto/program/dom.py b/src/var/lib/tyto/program/dom.py index b5d0b8f..97fffa1 100644 --- a/src/var/lib/tyto/program/dom.py +++ b/src/var/lib/tyto/program/dom.py @@ -19,7 +19,7 @@ #---------------------------------------------------------------------- # XMPP: echolib (im@echolib.re) # -# Description: Manage domain configuration +# Description: Load domain database and check validity # File: /var/lib/tyto/program/dom.py #---------------------------------------------------------------------- @@ -36,7 +36,7 @@ import os, sys, importlib, langs lib = 'tyto_domain' -exists = incomplete = active = ready = shortname = False +exists = incomplete = active = ready = shortname = corrupt = False local_user = articles_db_d = False hole = False @@ -81,11 +81,13 @@ dom_values = \ 'wip_sidebar_f', 'wip_metas_f', 'wip_footer_f', +'wip_stats_f', 'www_css_f', 'www_navbar_f', 'www_sidebar_f', 'www_metas_f', 'www_footer_f', +'www_stats_f', 'www_logo_f', 'www_rss_f', 'logo', @@ -136,53 +138,58 @@ if not hole: # Set configuration domain file config = '%s/tyto_domain.py'%folder + shortname = config # Set exists if configuration file if os.path.exists(config): exists = True - exec(open(config).read()) - + try: + exec(open(config).read()) + except: + corrupt = True + # For logs: show uri if not shortname known try: shortname - except: shortname = config + except: pass try: active = activated except: pass - for value in dom_values: - try: - eval(str(value)) - value_set = True - except: - err_val = err_val + ((value),) - value_set = False - incomplete = True - active = False - - - if value.endswith('_d'): - if value_set: - if not os.path.exists(eval(str(value))): - try: - os.makedirs(eval(str(value)), exist_ok=True) - dir_new = dir_new + ((eval(str(value))),) - except: - dir_unu = dir_unu + ((eval(str(value))),) - - elif value.endswith('_f'): - if value_set: - if not os.path.exists(eval(str(value))): - if value in create_files: - file_mod = file_mod + ((value),) - else: - file_unu = file_unu + ((eval(str(value))),) - + if not corrupt: + for value in dom_values: + try: + eval(str(value)) + value_set = True + except: + err_val = err_val + ((value),) + value_set = False + incomplete = True + active = False + + + if value.endswith('_d'): + if value_set: + if not os.path.exists(eval(str(value))): + try: + os.makedirs(eval(str(value)), exist_ok=True) + dir_new = dir_new + ((eval(str(value))),) + except: + dir_unu = dir_unu + ((eval(str(value))),) + + elif value.endswith('_f'): + if value_set: + if not os.path.exists(eval(str(value))): + if value in create_files: + file_mod = file_mod + ((value),) + else: + file_unu = file_unu + ((eval(str(value))),) #==============================================# # When an active and complete domain is needed # #----------------------------------------------# - if not incomplete: + wip_html_mods = () + if exists and not incomplete and not corrupt: wip_html_mods = \ ( eval(str('wip_navbar_f')), @@ -199,4 +206,5 @@ if not hole: #------------------------------------# def valid(): if incomplete: sys.exit(41) + #elif corrupt: sys.exit(41) elif not active: sys.exit(42) diff --git a/src/var/lib/tyto/program/form.py b/src/var/lib/tyto/program/form.py index b597485..0d7d1ae 100644 --- a/src/var/lib/tyto/program/form.py +++ b/src/var/lib/tyto/program/form.py @@ -250,6 +250,9 @@ def create_domain(target): #------------------------------------- root_srv_dom = '%s/%s'%(srv, shortname) srv_wip_tpl = "%s/wip/template/"%root_srv_dom + stats_wip_f = "%s/wip/tyto_wip_statoolinfos.conf"%root_srv_dom + stats_www_f = "%s/www/tyto_www_statoolinfos.conf"%root_srv_dom + srv_www_tpl = "%s/www/template/"%root_srv_dom set_f = \ '# Servers directories\n' + \ @@ -271,6 +274,7 @@ def create_domain(target): 'wip_sidebar_f = "%ssidebar.html"\n'%srv_wip_tpl + \ 'wip_metas_f = "%smetas.html"\n'%srv_wip_tpl + \ 'wip_footer_f = "%sfooter.html"\n'%srv_wip_tpl + \ + 'wip_stats_f = "%s"\n'%stats_wip_f + \ '\n' + \ '# Servers files (www)\n' + \ 'www_logo_f = "%s%s"\n'%(srv_www_tpl, logo) + \ @@ -278,7 +282,8 @@ def create_domain(target): 'www_navbar_f = "%snavbar.html"\n'%srv_www_tpl + \ 'www_sidebar_f = "%ssidebar.html"\n'%srv_www_tpl + \ 'www_metas_f = "%smetas.html"\n'%srv_www_tpl + \ - 'www_footer_f = "%sfooter.html"'%srv_www_tpl + 'www_footer_f = "%sfooter.html"\n'%srv_www_tpl + \ + 'www_stats_f = "%s"'%stats_www_f tyto.set_file(dom.config, False, set_f) diff --git a/src/var/lib/tyto/program/infos.py b/src/var/lib/tyto/program/infos.py index 9cfd7dc..5b97aa0 100644 --- a/src/var/lib/tyto/program/infos.py +++ b/src/var/lib/tyto/program/infos.py @@ -1,11 +1,27 @@ #!/usr/bin/env python3 -# Name: Tyto - Littérateur -# Type: Show infos about Tyto -# Description: Show informations about Tyto - Littérateur -# file: infos.py -# Folder: /var/lib/tyto/program/ -# By echolib (XMPP: im@echolib.re) -# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 +# Tyto - Littérateur +# +# Copyright (C) 2023 Cyrille Louarn +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or of the License, or (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +#---------------------------------------------------------------------- +# XMPP: echolib (im@echolib.re) +# +# Description: Show helps and informations +# File: /var/lib/tyto/program/infos.py +#---------------------------------------------------------------------- #------------ # funny stats diff --git a/src/var/lib/tyto/program/langs.py b/src/var/lib/tyto/program/langs.py index 667359d..200cbde 100644 --- a/src/var/lib/tyto/program/langs.py +++ b/src/var/lib/tyto/program/langs.py @@ -19,8 +19,8 @@ #---------------------------------------------------------------------- # XMPP: echolib (im@echolib.re) # -# Description: Load translations file for log -# File: /var/lib/tyto/program/log.py +# Description: Load translations file for logs and forms/sites +# File: /var/lib/tyto/program/langs.py #---------------------------------------------------------------------- #------------ diff --git a/src/var/lib/tyto/program/logs.py b/src/var/lib/tyto/program/logs.py index 3d254f8..c90aec9 100644 --- a/src/var/lib/tyto/program/logs.py +++ b/src/var/lib/tyto/program/logs.py @@ -85,9 +85,10 @@ def out(nbr, value, out): '36' : ' ╡ %s %s'%(langs.log.file_e, value), '37' : ' ╡ %s %s'%(langs.log.dir_e, value), '38' : ' ╞ %s%s%s "%s ?"'%(CR, langs.log.unused_t, CS, value), - '40' : ' ╒ %s%s%s > "%s"'%(CY, langs.log.dom_ina, CS, value), - '41' : ' ╒ %s%s%s > "%s"'%(CR, langs.log.dom_inc, CS, value), - '42' : ' ╒ %s%s%s > "%s"'%(CG, langs.log.dom_act, CS, value), + '39' : ' ╒ %s%s%s > %s'%(CR, langs.log.dom_cor, CS, value), + '40' : ' ╒ %s%s%s > %s'%(CY, langs.log.dom_ina, CS, value), + '41' : ' ╒ %s%s%s > %s'%(CR, langs.log.dom_inc, CS, value), + '42' : ' ╒ %s%s%s > %s'%(CG, langs.log.dom_act, CS, value), '43' : ' ╒ %s%s%s'%(CY, langs.log.dom_no, CS), '44' : ' ╞ %s%s%s "tyto check %s"'%(CY, langs.log.check_m, CS, value), '45' : ' ╞ %s%s %s%s > %s'%(CY, langs.log.meta_t, langs.log.no_up, CS, value), diff --git a/src/var/lib/tyto/program/publish.py b/src/var/lib/tyto/program/publish.py index f896a04..c172bda 100644 --- a/src/var/lib/tyto/program/publish.py +++ b/src/var/lib/tyto/program/publish.py @@ -58,7 +58,7 @@ def manage_publish(target): 'metas' : html.create_user_metas, 'footer' : html.create_user_footer, 'template' : publish_template, - 'stats' : stats.manage_stats + 'stats' : stats.manage } do[target]('www') diff --git a/src/var/lib/tyto/program/show.py b/src/var/lib/tyto/program/show.py index 6917467..468d210 100644 --- a/src/var/lib/tyto/program/show.py +++ b/src/var/lib/tyto/program/show.py @@ -150,7 +150,8 @@ def manage(target): 'metas' : dom.wip_metas_f, 'navbar' : dom.wip_navbar_f, 'sidebar' : dom.wip_sidebar_f, - 'post' : post_wip + 'post' : post_wip, + 'stats' : dom.wip_stats_f, }, 'www' : { 'domain' : dom.config, @@ -158,7 +159,8 @@ def manage(target): 'metas' : dom.www_metas_f, 'navbar' : dom.www_navbar_f, 'sidebar' : dom.www_sidebar_f, - 'post' : post_www + 'post' : post_www, + 'stats' : dom.www_stats_f, }, } diff --git a/src/var/lib/tyto/program/stats.py b/src/var/lib/tyto/program/stats.py index c28b860..ebf9392 100644 --- a/src/var/lib/tyto/program/stats.py +++ b/src/var/lib/tyto/program/stats.py @@ -1,11 +1,27 @@ #!/usr/bin/env python3 -# Name: Tyto - Littérateur -# Type: Statistics generator -# Description: Create/Show statistics (wip, publish...) -# file: stats.py -# Folder: /var/lib/tyto/program/ -# By echolib (XMPP: im@echolib.re) -# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 +# Tyto - Littérateur +# +# Copyright (C) 2023 Cyrille Louarn +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of the +# License, or of the License, or (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +#---------------------------------------------------------------------- +# XMPP: echolib (im@echolib.re) +# +# Description: Create total statistics file for www or wip +# File: /var/lib/tyto/program/stats.py +#---------------------------------------------------------------------- #------------ # funny stats @@ -18,40 +34,26 @@ #********************************************************************** import os, importlib -import args, dom, logs, form, tyto, show - -sti_anchors = sti_abbrs = sti_links = 0 -sti_images = sti_files = sti_raws = 0 -sti_tags = sti_words = sti_titles = sti_paragraphs = sti_anclinks = 0 -sti_strongs = sti_bolds = sti_emphasis = sti_italics = sti_dels = 0 -sti_underlines = sti_cites = sti_customs = sti_icodes = 0 -sti_bcodes = sti_quotes = sti_lists = 0 +import args, dom, logs, form, tyto, show, langs +sti_articles = 0 #=======================# # Manage "stats" option # #-----------------------# -def manage_stats(process): - domain.domain_needed() +def manage(process): + dom.valid() global file_uri, domain_srv - global sti_articles if process == 'wip': - file_uri = '%s%s'%(db.srv_wip, tyto.stats_f) - domain_srv = db.domain_wip_url + file_uri = dom.wip_stats_f + domain_srv = dom.wip_url elif process == 'www': - file_uri = '%s%s'%(db.srv_www, tyto.stats_f) - domain_srv = db.domain_www_url + file_uri = dom.www_stats_f + domain_srv = dom.www_url - do = { - 'wip' : loop_articles, - 'publish' : loop_articles, - 'show-wip' : show_stats, - 'show-www' : show_stats - } - - do[args.action](process) + loop_articles(process) #==========================# @@ -59,78 +61,133 @@ def manage_stats(process): #--------------------------# def loop_articles(process): global sti_articles - sti_articles = 0 - + # Get databases of articles - for post_db in os.listdir(db.articles_db): - if not post_db.endswith('.conf'): continue + for post_db in os.listdir(dom.articles_db_d): + if not post_db.endswith('.config'): + continue # Load DB - post_db = '%s%s'%(db.articles_db, post_db) + post_db = '%s%s'%(dom.articles_db_d, post_db) exec(open(post_db).read(),globals()) - args.target = post_src.rsplit('%s/'%db.in_dir)[1] - importlib.reload(db) # Check hash status (wip/www) hash_srv = '' - if process == 'wip': hash_srv = db.hash_wip - elif process == 'www': hash_srv = db.hash_www - - # Now generic for wip/www - if not hash_srv: continue - - print(':> [%s] | %s'%(db.title, db.post_src)) - - # Article has changed and could have different stats - if hash_srv != db.hash_chk: - logs.out("9", db.post_src, False) + if process == 'wip': hash_srv = hash_wip + elif process == 'www': hash_srv = hash_www + + + # - Now generic for wip and www + # - Article has changed and could have different stats + if not hash_srv or \ + hash_srv != hash_chk: continue - + + sti_articles += 1 - count_stats() + if sti_articles == 1: count_stats(False) + else: count_stats(True) # Create file if article if sti_articles > 0: create_stats_file(file_uri) - else: logs.out("28", '(%s stats)'%process, True) + else: logs.out("28", '%s stats'%process, True) +#===============================# +# False: Set First statistics # +# True: Count total statistics # +#-------------------------------# +def count_stats(add): + global sti_uniq_anchors + global sti_uniq_abbrs + global sti_uniq_links + global sti_uniq_images + global sti_uniq_files + global sti_uniq_codes + global sti_uniq_raws + + global sti_posts_coms + global sti_posts_tags + global sti_posts_lines + global sti_posts_words + global sti_posts_titles + global sti_posts_paragraphs + global sti_posts_anchors + global sti_posts_abbrs + global sti_posts_strongs + global sti_posts_bolds + global sti_posts_emphasis + global sti_posts_italics + global sti_posts_dels + global sti_posts_underlines + global sti_posts_cites + global sti_posts_customs + global sti_posts_icodes + global sti_posts_bcodes + global sti_posts_quotes + global sti_posts_lists + + + # Set + if not add: + sti_uniq_anchors = uniq_anchors + sti_uniq_abbrs = uniq_abbrs + sti_uniq_links = uniq_links + sti_uniq_images = uniq_images + sti_uniq_files = uniq_files + sti_uniq_codes = uniq_codes + sti_uniq_raws = uniq_raws + + sti_posts_coms = post_coms + sti_posts_tags = post_tags + sti_posts_lines = post_lines + sti_posts_words = post_words + sti_posts_titles = post_titles + sti_posts_paragraphs = post_paragraphs + sti_posts_anchors = post_anchors + sti_posts_abbrs = post_abbrs + sti_posts_strongs = post_strongs + sti_posts_bolds = post_bolds + sti_posts_emphasis = post_emphasis + sti_posts_italics = post_italics + sti_posts_dels = post_dels + sti_posts_underlines = post_underlines + sti_posts_cites = post_cites + sti_posts_customs = post_customs + sti_posts_icodes = post_icodes + sti_posts_bcodes = post_bcodes + sti_posts_quotes = post_quotes + sti_posts_lists = post_lists -#================================# -# Set Statistics and count # -# in a loop, from loop_article() # -#--------------------------------# -def count_stats(): - # Set Statistics - global sti_anchors, sti_abbrs, sti_links - global sti_images, sti_files, sti_raws - global sti_tags, sti_words, sti_titles, sti_paragraphs, sti_anclinks - global sti_strongs, sti_bolds, sti_emphasis, sti_italics, sti_dels - global sti_underlines, sti_cites, sti_customs, sti_icodes - global sti_bcodes, sti_quotes, sti_lists - - # Set statistics - sti_anchors = sti_anchors + db.uniq_anchors - sti_abbrs = sti_abbrs + db.uniq_abbrs - sti_links = sti_links + db.uniq_links - sti_images = sti_images + db.uniq_images - sti_files = sti_files + db.uniq_files - sti_raws = sti_raws + db.uniq_raws - sti_tags = sti_tags + db.stat_tags - sti_words = sti_words + db.stat_words - sti_titles = sti_titles + db.stat_titles - sti_paragraphs = sti_paragraphs + db.stat_paragraphs - sti_anclinks = sti_anclinks + db.stat_anchors - sti_strongs = sti_strongs + db.stat_strongs - sti_bolds = sti_bolds + db.stat_bolds - sti_emphasis = sti_emphasis + db.stat_emphasis - sti_italics = sti_italics + db.stat_italics - sti_dels = sti_dels + db.stat_dels - sti_underlines = sti_underlines + db.stat_underlines - sti_cites = sti_cites + db.stat_cites - sti_customs = sti_customs + db.stat_customs - sti_icodes = sti_icodes + db.stat_icodes - sti_bcodes = sti_bcodes + db.stat_bcodes - sti_quotes = sti_quotes + db.stat_quotes - sti_lists = sti_lists + db.stat_lists + # Count + else: + sti_uniq_anchors = sti_uniq_anchors + uniq_anchors + sti_uniq_abbrs = sti_uniq_abbrs + uniq_abbrs + sti_uniq_links = sti_uniq_links + uniq_links + sti_uniq_images = sti_uniq_images + uniq_images + sti_uniq_files = sti_uniq_files + uniq_files + sti_uniq_codes = sti_uniq_codes + uniq_codes + sti_uniq_raws = sti_uniq_raws + uniq_raws + + sti_posts_coms = sti_posts_coms + post_coms + sti_posts_tags = sti_posts_tags + post_tags + sti_posts_lines = sti_posts_lines + post_lines + sti_posts_words = sti_posts_words + post_words + sti_posts_titles = sti_posts_titles + post_titles + sti_posts_paragraphs = sti_posts_paragraphs + post_paragraphs + sti_posts_anchors = sti_posts_anchors + post_anchors + sti_posts_abbrs = sti_posts_abbrs + post_abbrs + sti_posts_strongs = sti_posts_strongs + post_strongs + sti_posts_bolds = sti_posts_bolds + post_bolds + sti_posts_emphasis = sti_posts_emphasis + post_emphasis + sti_posts_italics = sti_posts_italics + post_italics + sti_posts_dels = sti_posts_dels + post_dels + sti_posts_underlines = sti_posts_underlines + post_underlines + sti_posts_cites = sti_posts_cites + post_cites + sti_posts_customs = sti_posts_customs + post_customs + sti_posts_icodes = sti_posts_icodes + post_icodes + sti_posts_bcodes = sti_posts_bcodes + post_bcodes + sti_posts_quotes = sti_posts_quotes + post_quotes + sti_posts_lists = sti_posts_lists + post_lists #============================# @@ -144,36 +201,48 @@ def create_stats_file(file_uri): '# Generated: %s\n'%tyto.nowdate() + \ '\n' + \ '# Uniq statistics from articles\' headers\n' + \ - 'stats_articles = %d\n'%int(sti_articles) + \ - 'stats_uniq_anchors = %d\n'%int(sti_anchors) + \ - 'stats_uniq_abbrs = %d\n'%int(sti_abbrs) + \ - 'stats_uniq_links = %d\n'%int(sti_links) + \ - 'stats_uniq_images = %d\n'%int(sti_images) + \ - 'stats_uniq_files = %d\n'%int(sti_files) + \ - 'stats_uniq_raws = %d\n'%int(sti_raws) + \ + 'stats_articles = %d\n'%int(sti_articles) + \ + 'stats_uniq_anchors = %d\n'%int(sti_uniq_anchors) + \ + 'stats_uniq_abbrs = %d\n'%int(sti_uniq_abbrs) + \ + 'stats_uniq_links = %d\n'%int(sti_uniq_links) + \ + 'stats_uniq_images = %d\n'%int(sti_uniq_images) + \ + 'stats_uniq_files = %d\n'%int(sti_uniq_files) + \ + 'stats_uniq_codes = %d\n'%int(sti_uniq_codes) + \ + 'stats_uniq_raws = %d\n'%int(sti_uniq_raws) + \ '\n' + \ - '# Statistics from articles\' content\n' + \ - 'stats_tags = %d\n'%int(sti_tags) + \ - 'stats_words = %d\n'%int(sti_words) + \ - 'stats_titles = %d\n'%int(sti_titles) + \ - 'stats_paragraphs = %d\n'%int(sti_paragraphs) + \ - 'stats_link_anchors = %d\n'%int(sti_anclinks) + \ - 'stats_strongs = %d\n'%int(sti_strongs) + \ - 'stats_bolds = %d\n'%int(sti_bolds) + \ - 'stats_emphasis = %d\n'%int(sti_emphasis) + \ - 'stats_italics = %d\n'%int(sti_italics) + \ - 'stats_dels = %d\n'%int(sti_dels) + \ - 'stats_underlines = %d\n'%int(sti_underlines) + \ - 'stats_cites = %d\n'%int(sti_cites) + \ - 'stats_customs = %d\n'%int(sti_customs) + \ - 'stats_icodes = %d\n'%int(sti_icodes) + \ - 'stats_bcodes = %d\n'%int(sti_bcodes) + \ - 'stats_quotes = %d\n'%int(sti_quotes) + \ - 'stats_lists = %d\n'%int(sti_lists) + '# Statistics from articles\' contents\n' + \ + 'stats_posts_coms = %d\n'%int(sti_posts_coms) + \ + 'stats_posts_tags = %d\n'%int(sti_posts_tags) + \ + 'stats_posts_lines = %d\n'%int(sti_posts_lines) + \ + 'stats_posts_words = %d\n'%int(sti_posts_words) + \ + 'stats_posts_titles = %d\n'%int(sti_posts_titles) + \ + 'stats_posts_paragraphs = %d\n'%int(sti_posts_paragraphs) + \ + 'stats_posts_anchors = %d\n'%int(sti_posts_anchors) + \ + 'stats_posts_abbrs = %d\n'%int(sti_posts_abbrs) + \ + 'stats_posts_strongs = %d\n'%int(sti_posts_strongs) + \ + 'stats_posts_bolds = %d\n'%int(sti_posts_bolds) + \ + 'stats_posts_emphasis = %d\n'%int(sti_posts_emphasis) + \ + 'stats_posts_italics = %d\n'%int(sti_posts_italics) + \ + 'stats_posts_dels = %d\n'%int(sti_posts_dels) + \ + 'stats_posts_underlines = %d\n'%int(sti_posts_underlines) + \ + 'stats_posts_cites = %d\n'%int(sti_posts_cites) + \ + 'stats_posts_customs = %d\n'%int(sti_posts_customs) + \ + 'stats_posts_icodes = %d\n'%int(sti_posts_icodes) + \ + 'stats_posts_bcodes = %d\n'%int(sti_posts_bcodes) + \ + 'stats_posts_quotes = %d\n'%int(sti_posts_quotes) + \ + 'stats_posts_lists = %d\n'%int(sti_posts_lists) tyto.set_file(file_uri, 'New', sti) - logs.out("33", file_uri, False) - + try: + print(' └', langs.site.stats_f%( + sti_articles, sti_posts_words + ) + ) + except: + print(' └ Articles = %s ; Words = %s'%( + sti_articles, sti_posts_words + ) + ) #======================================# # Show statistics from pages on server # diff --git a/src/var/lib/tyto/program/status.py b/src/var/lib/tyto/program/status.py index 2b9f2ea..a58cfdf 100644 --- a/src/var/lib/tyto/program/status.py +++ b/src/var/lib/tyto/program/status.py @@ -37,7 +37,8 @@ import dom, logs, tyto, form def domain(): if dom.hole: logs.out("13", '', True) - elif not dom.shortname: return + elif dom.corrupt: logs.out("39", dom.shortname, True) + #elif not dom.shortname: return elif dom.incomplete: logs.out("41", dom.shortname, False) elif dom.active: logs.out("42", dom.shortname, False) elif not dom.active: logs.out("40", dom.shortname, False) diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index 2ce06b4..309eb0e 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -41,7 +41,6 @@ import args, dom, logs Tyto = 'Tyto - Littérateur' Tytogit = 'https://git.a-lec.org/echolib/tyto-litterateur' Tytoweb = 'https://tyto.echolib.re' -stats_f = 'tyto_statoolinfos.conf' # Needed header tags diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 5f3fa5d..234cd18 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -62,7 +62,7 @@ def manage(target): 'navbar' : html.create_navbar, 'metas' : html.create_user_metas, 'footer' : html.create_user_footer, - 'stats' : stats.manage_stats + 'stats' : stats.manage } do[target]('wip') diff --git a/src/var/lib/tyto/translations/logs_en.py b/src/var/lib/tyto/translations/logs_en.py index e315034..d922ef6 100644 --- a/src/var/lib/tyto/translations/logs_en.py +++ b/src/var/lib/tyto/translations/logs_en.py @@ -30,6 +30,7 @@ no_fidi = "Black Hole: no file or directory here" dom_ina = "Inactive domain" dom_inc = "Incomplete domain" dom_act = "Active domain" +dom_cor = "Corrupted domain" data_inc = "Incomplete data" data_inv = "Invalid data" dom_no = "No domain found" diff --git a/src/var/lib/tyto/translations/logs_fr.py b/src/var/lib/tyto/translations/logs_fr.py index 1a7dcf3..5a89e07 100644 --- a/src/var/lib/tyto/translations/logs_fr.py +++ b/src/var/lib/tyto/translations/logs_fr.py @@ -30,6 +30,7 @@ no_fidi = "Trou Noir: aucun fichier ou dossier ici" dom_ina = "Domaine inactif" dom_inc = "Domaine incomplet" dom_act = "Domaine actif" +dom_cor = "Domaine corrompu" data_inc = "Donnée incomplète" data_inv = "Donnée invalide" dom_no = "Aucun domaine trouvé" diff --git a/src/var/lib/tyto/translations/site_en.py b/src/var/lib/tyto/translations/site_en.py index f65bfc9..0d23dac 100644 --- a/src/var/lib/tyto/translations/site_en.py +++ b/src/var/lib/tyto/translations/site_en.py @@ -12,13 +12,12 @@ # IMPORTANT Instructions #----------------------- -''' -This is a python file, so... DO NOT REMOVE: -- "#" -- "%s", "%d" -- "\n" -- "+ \" -''' +# This is a python file, so... DO NOT REMOVE: +# - "#" +# - "%s", "%d" +# - "\n" +# - "+ \" + # Generic article = "Article" @@ -133,6 +132,8 @@ check_a = "Check again this article" uptpl = "Update directory" +stats_f = "Articles: %s (%s words)" + # Documentation of configuration files #------------------------------------- metas_doc = \ diff --git a/src/var/lib/tyto/translations/site_fr.py b/src/var/lib/tyto/translations/site_fr.py index ca72c6c..ed933c5 100644 --- a/src/var/lib/tyto/translations/site_fr.py +++ b/src/var/lib/tyto/translations/site_fr.py @@ -12,13 +12,11 @@ # Instructions IMPORTANTES #------------------------- -''' -Ceci est un fichier python, donc... NE PAS ENLEVER : -- "#" -- "%s", "%d" -- "\n" -- "+ \" -''' +# Ceci est un fichier python, donc... NE PAS ENLEVER : +# - "#" +# - "%s", "%d" +# - "\n" +# - "+ \" # Generic article = "Article" @@ -134,6 +132,8 @@ check_a = "Vérifier encore l'article" uptpl = "Mettre à jour le dossier" +stats_f = "Articles : %s (%s mots)" + # Documentation des fichiers de configuration #-------------------------------------------- metas_doc = \