#!/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 #------------ # funny stats #------------ # lines: 129 # functions: 4 #----------------------------------------------------------------------- #********************************************************************** #====================================================================== # 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) touch "$domain_dir_www/stl-stats.properties" cat < "$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 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 )) }