stats: added show-wip/show-www argument to read srv pages statistics

This commit is contained in:
Cyrille L 2023-03-12 16:19:34 +01:00
parent 35794a8ae8
commit 532c63dbdd
2 changed files with 50 additions and 31 deletions

View File

@ -18,7 +18,7 @@
#********************************************************************** #**********************************************************************
import os, importlib import os, importlib
import args, db, logs, domain, tyto, check import args, db, logs, domain, tyto, check, stats
#======================# #======================#
@ -56,22 +56,29 @@ def manage_show(target):
} }
elif args.action in actions_wip: elif args.action in actions_wip:
do = { if target == 'stats':
"domain" : db.domain_conf, stats.manage_stats('wip')
"footer" : db.wip_footer, return
"metas" : db.wip_metas,
"navbar" : db.wip_navbar, do = {
"sidebar" : db.wip_sidebar "domain" : db.domain_conf,
} "footer" : db.wip_footer,
"metas" : db.wip_metas,
"navbar" : db.wip_navbar,
"sidebar" : db.wip_sidebar
}
elif args.action in actions_www: elif args.action in actions_www:
do = { if target == 'stats':
"domain" : db.domain_conf, stats.manage_stats('www')
"footer" : db.www_footer, return
"metas" : db.www_metas, do = {
"navbar" : db.www_navbar, "domain" : db.domain_conf,
"sidebar" : db.www_sidebar "footer" : db.www_footer,
} "metas" : db.www_metas,
"navbar" : db.www_navbar,
"sidebar" : db.www_sidebar
}
# Target is a post uri # Target is a post uri
#--------------------- #---------------------

View File

@ -18,14 +18,14 @@
#********************************************************************** #**********************************************************************
import os, importlib import os, importlib
import args, logs, db, domain, tyto import args, logs, db, domain, tyto, show
sti_anchors = sti_abbrs = sti_links = 0 sti_anchors = sti_abbrs = sti_links = 0
sti_images = sti_files = sti_raws = 0 sti_images = sti_files = sti_raws = 0
sti_tags = sti_words = sti_titles = sti_paragraphs = sti_anclinks = 0 sti_tags = sti_words = sti_titles = sti_paragraphs = sti_anclinks = 0
sti_strongs = sti_bolds = sti_emphasis = sti_italics = sti_dels = 0 sti_strongs = sti_bolds = sti_emphasis = sti_italics = sti_dels = 0
sti_underlines = sti_cites = sti_customs = sti_icodes = 0 sti_underlines = sti_cites = sti_customs = sti_icodes = 0
sti_bcodes = sti_quotes = sti_lists = sti_articles = 0 sti_bcodes = sti_quotes = sti_lists = 0
#=======================# #=======================#
@ -34,20 +34,6 @@ sti_bcodes = sti_quotes = sti_lists = sti_articles = 0
def manage_stats(process): def manage_stats(process):
domain.domain_needed() domain.domain_needed()
do = {
'wip' : loop_articles,
'publish' : loop_articles,
'show-wip' : count_stats, # NO
'show_www' : count_stats, # NO
}
do[args.action](process)
#==========================#
# Check databases' article #
#--------------------------#
def loop_articles(process):
global file_uri, domain_srv global file_uri, domain_srv
global sti_articles global sti_articles
@ -57,6 +43,23 @@ def loop_articles(process):
elif process == 'www': elif process == 'www':
file_uri = '%s%s'%(db.srv_www, tyto.stats_f) file_uri = '%s%s'%(db.srv_www, tyto.stats_f)
domain_srv = db.domain_www_url domain_srv = db.domain_www_url
do = {
'wip' : loop_articles,
'publish' : loop_articles,
'show-wip' : show_stats,
'show-www' : show_stats
}
do[args.action](process)
#==========================#
# Check databases' article #
#--------------------------#
def loop_articles(process):
global sti_articles
sti_articles = 0
# Get databases of wip's articles # Get databases of wip's articles
for post_db in os.listdir(db.articles_db): for post_db in os.listdir(db.articles_db):
@ -72,6 +75,7 @@ def loop_articles(process):
if process == 'wip': hash_srv = db.hash_wip if process == 'wip': hash_srv = db.hash_wip
elif process == 'www': hash_srv = db.hash_www elif process == 'www': hash_srv = db.hash_www
# Now generic for wip/www
if not hash_srv: continue if not hash_srv: continue
print(':> [%s] | %s'%(db.title, db.post_src)) print(':> [%s] | %s'%(db.title, db.post_src))
@ -135,6 +139,7 @@ def create_stats_file(file_uri):
sti = \ sti = \
'# Statistics file created by %s\n'%tyto.Tyto + \ '# Statistics file created by %s\n'%tyto.Tyto + \
'# Website: %s\n'%domain_srv + \ '# Website: %s\n'%domain_srv + \
'# File: %s\n'%file_uri + \
'# Generated: %s\n'%tyto.nowdate() + \ '# Generated: %s\n'%tyto.nowdate() + \
'\n' + \ '\n' + \
'# Uniq statistics from articles\' headers\n' + \ '# Uniq statistics from articles\' headers\n' + \
@ -167,3 +172,10 @@ def create_stats_file(file_uri):
tyto.set_file(file_uri, 'New', sti) tyto.set_file(file_uri, 'New', sti)
logs.out("33", file_uri, False) logs.out("33", file_uri, False)
#======================================#
# Show statistics from pages on server #
#--------------------------------------#
def show_stats(process):
show.read_lines(file_uri)