stl-statilque-litterateur/var/lib/stl/scripts/manage__stats

130 lines
3.7 KiB
Plaintext
Raw Permalink Normal View History

2022-07-21 16:42:49 +02:00
#!/bin/bash
# Name: Statique Littérateur
# Type: Manage Statistics (statoolinfos, and more)
# file: manage__stats
# Folder: /var/lib/stl/scripts/
# By echolib (XMPP: im@echolib.re)
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
2022-08-23 16:48:33 +02:00
#------------
# funny stats
#------------
# lines: 129
# functions: 4
#-----------------------------------------------------------------------
#**********************************************************************
2022-07-21 16:42:49 +02:00
#======================================================================
# Argument: stats
#======================================================================
stats__OPTIONS() {
domain__get
# Init stats
stats__init
db__get_wip_articles "stats"
stats__statoolinfos
}
#======================================================================
# Stats initialization
#======================================================================
stats__init() {
article_words_www=0
article_titles_www=0
article_paragraphs_www=0
article_links_www=0
article_quotes_www=0
article_lists_www=0
article_bolds_www=0
article_strongs_www=0
article_emphasis_www=0
article_icodes_www=0
article_cross_www=0
article_dels_www=0
files_images_www=0
files_links_www=0
files_codes_www=
files_bruts_www=0
}
#======================================================================
# Create stl.properties for statoolinfos
#======================================================================
stats__statoolinfos() {
case "$stl_install" in
server)
2022-08-14 02:35:27 +02:00
touch "$domain_dir_www/stl-stats.properties"
2022-08-23 16:48:33 +02:00
cat <<EOSTATS > "$domain_dir_wip/stl-stats.properties"
stl.articles = $stat_articles_www
stl.articles.titles = $article_titles_www
stl.articles.words = $article_words_www
stl.articles.paragraphs = $article_paragraphs_www
stl.articles.links = $article_links_www
stl.articles.bolds = $article_bolds_www
stl.articles.strongs = $article_strongs_www
stl.articles.emphasis = $article_emphasis_www
stl.articles.inlinecodes = $article_icodes_www
stl.articles.cross = $article_cross_www
stl.articles.dels = $article_dels_www
stl.articles.quotes = $article_quotes_www
stl.articles.lists = $article_lists_www
# Files
stl.articles.filelinks = $files_links_www
stl.articles.images = $files_images_www
stl.articles.filecodes = $files_codes_www
stl.articles.filebruts = $files_bruts_www
EOSTATS
# log
2022-08-23 16:48:33 +02:00
this_article="$domain_dir_wip/stl-stats.properties"
log__add -i -W -S "Created stats (Statoolinfos)"
;;
esac
}
#======================================================================
# Count words in article
# Called from checkers() ; check_article
# $1: $article_tmp_post
#======================================================================
stats__words() {
article_words=`cat "$1" | wc -w`
content_stats_images=`grep "_image:" "$1" | wc -l`
content_stats_fcodes=`grep "_code:" "$1" | wc -l`
content_stats_fbruts=`grep "_brut:" "$1" | wc -l`
content_stats_slists=`grep "<<" "$1" | wc -w`
content_stats_clists=`grep ">>" "$1" | wc -l`
content_stats_olists=`grep "^+" "$1" | wc -l`
content_stats_ulists=`grep "^=" "$1" | wc -l`
content_stats_commts=`grep "^# " "$1" | wc -w`
content_stats_titles=`grep "^#[1-6] " "$1" | wc -l`
content_stats_mquots=`grep "^---" "$1" | wc -l`
content_stats_oparas=`grep "^(" "$1" | wc -w`
content_stats_cparas=`grep "^)" "$1" | wc -l`
article_words=\
$(( article_words \
- content_stats_images \
- content_stats_fcodes \
- content_stats_fbruts \
- content_stats_slists \
- content_stats_clists \
- content_stats_olists \
- content_stats_ulists \
- content_stats_commts \
- content_stats_titles \
- content_stats_mquots \
- content_stats_oparas \
- content_stats_cparas
))
2022-07-21 16:42:49 +02:00
}