Version 0.0.37

This commit is contained in:
Cyrille L 2022-04-25 13:17:09 +02:00
parent 2a61aafbfa
commit e41fc4e8fe
9 changed files with 154 additions and 97 deletions

View File

@ -1,5 +1,5 @@
Package: egsl
Version: 0.0.36
Version: 0.0.37
Section: custom
Priority: optional
Architecture: all

View File

@ -52,15 +52,11 @@ gsl_log_e='Err'
gsl_log_w='War'
gsl_log_i='Inf'
# Date format
gsl_test_date='^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]+$'
#-----------------------------------------------------------------------
# Set LOG help Activity for NEEDED HEADERS
#-----------------------------------------------------------------------
gsl_log_act_title='POST TITLE'
gsl_log_act_author='REGISTRED NAME'
gsl_log_act_date='YYYY-MM-DD'
gsl_log_act_info='POST is ABOUT...'
gsl_log_act_slug='POST-TITLE'
gsl_log_act_code='NBR : FILENAME : Alt Text'

View File

@ -1,11 +1,12 @@
# Version: 0.0.35 > 0.0.36
# [0.0.37]
- New list converter (! Use + for ol, not ø)
- New block titles converter with div
- New option: create
- New option with edit: conf (to edit domain configuration)
- New option: --version (to show changes)
- New generic function if invalid option
- New min size for post: 150
- Fix: No <div</div> if block title empty
- Added changelog
- Make stats at each www call
- Fix variable name propertie for stats (statoolinfos)
- Set yourself a class ID for paragraphs: i.e. "( 1a"
- Better Logs harmony
- date: Set to DD-MM-YYYY if site lang=fr || YYYY-MM-DD
- date: Check for month value > 12
- if 'error' log : do not exit 1 anymore
- link: check only online url from http...
- some changed syntax in make process

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Version: 0.0.36
# Version: 0.0.37
# file: gsl
# Folder: /usr/local/bin
# By echolib
@ -254,7 +254,13 @@ case "$1" in
"$PWD/$3.gsl"
gsl_checker_war=true
else
gsl__create_article "$2" "$(date +%F)" "$gsl_postname" && \
[[ `grep -i "fr" <<<"$gsl_site_lang"` ]] \
&& gsl_today=`printf '%(%d-%m-%Y)T'` \
|| gsl_today=`date +%F`
gsl__debug "$gsl_site_lang" "$gsl_today"
gsl__create_article "$2" "$gsl_today" "$gsl_postname" && \
gsl__logs_print \
"$gsl_log_i" \
"Create" \
@ -492,6 +498,17 @@ case "$1" in
gsl_srv_www="$gsl_site_server/$gsl_site_ndd/www"
gsl__loop_posts www "$2"
# Stats
gsl__if_file "$gsl_dir_scripts/gsl__stats" source
gsl_file_sti="$gsl_site_server/$gsl_find_domain/gsl-sti.properties"
gsl__get_stats &>/dev/null && \
gsl__logs_print \
"$gsl_log_i" \
"Stats" \
"File" \
"Generated" \
"$gsl_file_sti"
gsl__logs_print \
"$gsl_log_i" \
"Stopping" \
@ -536,5 +553,5 @@ if [[ "$gsl_checker_err" ]];then
echo
gsl_logs_err=true
gsl__logs_show
exit 1
exit
fi

View File

@ -68,8 +68,8 @@ if ! [[ "$gsl_post_begin" ]];then
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"$gsl_log_c_h1" \
"Missing: #1 TITLE" \
"Begins" \
"Unused: #1 TITLE" \
"${PWD}/$gsl_post"
gsl_checker_err=true
fi
@ -85,9 +85,9 @@ case "$gsl_post_type" in
page|post)
gsl__logs_print \
"$gsl_log_i" \
"Content" \
"Set as" \
"$gsl_post_type: $gsl_post" \
"Header" \
"$gsl_marker_type" \
"$gsl_post Set as $gsl_post_type" \
"${PWD}/$gsl_post"
;;
*)
@ -96,9 +96,9 @@ case "$gsl_post_type" in
"$gsl_post" && \
gsl__logs_print \
"$gsl_log_w" \
"Content" \
"Set as" \
"Default: $gsl_post_type for $gsl_post" \
"Header" \
"$gsl_marker_type" \
"$gsl_post Set as Default $gsl_post_type" \
"${PWD}/$gsl_post"
gsl__get_sum "$gsl_post"
;;
@ -128,8 +128,8 @@ if (( "$gsl_post_p_open" == 0 ));then
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"$gsl_loc_c_p" \
"Missing: ( and ) at begining lines" \
"Paragraphs" \
"Unused: ( and ) at begining lines" \
"${PWD}/$gsl_post"
gsl_checker_err=true
return
@ -145,7 +145,7 @@ else
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"$gsl_log_c_p" \
"Paragraphs" \
"Mismatch: (=$gsl_post_p_open ; )=$gsl_post_p_close" \
"${PWD}/$gsl_post"
gsl_checker_err=true
@ -177,7 +177,7 @@ else
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"$gsl_log_c_cite" \
"Citations" \
"Mismatch: --- not paired" \
"${PWD}/$gsl_post"
gsl_checker_err=true
@ -190,13 +190,13 @@ fi
gsl__check_link() {
# Get & Check Header CONTENT
gsl__check_header_fields \
"Content" "$gsl_log_h_link" "$gsl_log_act_link" \
"Header" "$gsl_marker_link" "$gsl_log_act_link" \
|| return
echo -ne "\r\033[2K: Searching for Links... $gsl_post_hf_1"
# No ALT TEXT ?
gsl__check_header_field3 "Content" "$gsl_log_h_link" "$gsl_marker_link"
gsl__check_header_field3 "Header" "$gsl_marker_link"
gsl_count_links=`
gsl__get_content_line "_$gsl_post_hf_1" "$gsl_post" | wc -l`
@ -204,25 +204,41 @@ gsl__get_content_line "_$gsl_post_hf_1" "$gsl_post" | wc -l`
if (( "$gsl_count_links" > 0 ));then
# Check URL
gsl_url_status=`
timeout 2 curl -o /dev/null --silent --head --write-out \
'%{http_code}' \
"$gsl_post_hf_2" 2>/dev/null || gsl_url_status=408`
case "$gsl_post_hf_2" in
http*)
gsl_url_status=`
timeout 2 curl -o /dev/null --silent --head --write-out \
'%{http_code}' \
"$gsl_post_hf_2" 2>/dev/null`
;;
*)
gsl_url_status=408
;;
esac
case "$gsl_url_status" in
1*|2*|3*)
gsl__logs_print \
"$gsl_log_i" \
"Content" \
"$gsl_log_h_link" \
"Header" \
"$gsl_marker_link" \
"Online:$gsl_url_status ${gsl_post_hf_2:0:40}..." \
"${PWD}/$gsl_post"
;;
4*)
gsl__logs_print \
"$gsl_log_w" \
"Header" \
"$gsl_marker_link" \
"Not checked: ${gsl_post_hf_2:0:40}..." \
"${PWD}/$gsl_post"
gsl_checker_war=true
;;
""|*)
gsl__logs_print \
"$gsl_log_w" \
"Content" \
"$gsl_log_h_link" \
"Header" \
"$gsl_marker_link" \
"Offline:$gsl_url_status ${gsl_post_hf_2:0:40}..." \
"${PWD}/$gsl_post"
@ -242,7 +258,7 @@ else
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"$gsl_log_c_link" \
"Link" \
"Unused: _$gsl_post_hf_1" \
"${PWD}/$gsl_post"
gsl_checker_err=true
@ -274,8 +290,8 @@ else
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"$gsl_log_c_abbr" \
"Missing: $gsl_post_header_field_1" \
"$gsl_marker_abbr" \
"Unused: $gsl_post_header_field_1" \
"${PWD}/$gsl_post"
gsl_checker_err=true
@ -299,8 +315,8 @@ if ! [[ -f "$gsl_dir_domain_files/$gsl_post_hf_2" ]];then
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"Header $gsl_marker_file" \
"Header" \
"$gsl_marker_file" \
"Not found: $gsl_post_hf_2" \
"$gsl_dir_domain_files/$gsl_post_hf_2"
gsl_checker_err=true
@ -332,7 +348,7 @@ else
"$gsl_log_e" \
"Content" \
"$gsl_log_c_file" \
"Missing: __$gsl_post_hf_1" \
"Unused: __$gsl_post_hf_1" \
"${PWD}/$gsl_post"
gsl_checker_err=true
@ -344,21 +360,22 @@ fi
#======================================================================
gsl__check_image() {
gsl__check_header_fields \
"Content" "$gsl_log_h_image" "$gsl_log_act_image" \
"Header" "$gsl_marker_image" "$gsl_log_act_image" \
|| return
gsl__check_header_field3 \
"Header" "$gsl_marker_image" "$gsl_marker_image" \
|| return
echo -ne "\r\033[2K: Searching for Images... $gsl_post_hf_1"
gsl__check_header_field3 "Content" "$gsl_log_h_image" "$gsl_marker_image" \
|| return
# File exists in folder
if ! [[ -f "$gsl_dir_domain_images/$gsl_post_hf_2" ]];then
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"$gsl_log_h_image" \
"Header" \
"$gsl_marker_image" \
"Not found: $gsl_post_hf_2" \
"$gsl_dir_domain_images/$gsl_post_hf_2"
gsl_checker_err=true
@ -389,8 +406,8 @@ else
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"$gsl_log_c_image" \
"Missing: _image:$gsl_post_hf_1" \
"Image" \
"Unused: _image:$gsl_post_hf_1" \
"${PWD}/$gsl_post"
gsl_checker_err=true
@ -403,7 +420,7 @@ fi
gsl__check_fcode() {
gsl__check_header_fields \
"Content" "$gsl_log_h_code" "$gsl_log_act_code" \
"Header" "$gsl_log_h_code" "$gsl_log_act_code" \
|| return
echo -ne "\r\033[2K: Searching for File Codes... $gsl_post_hf_1"
@ -415,8 +432,8 @@ if ! [[ -f "$gsl_dir_domain_files/$gsl_post_hf_2" ]];then
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"$gsl_log_h_code" \
"Header" \
"$gsl_marker_code" \
"Not found: $gsl_post_hf_2" \
"$gsl_dir_domain_files/$gsl_post_hf_2"
gsl_checker_err=true
@ -447,8 +464,8 @@ else
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"$gsl_log_c_code" \
"Missing: _code:$gsl_post_hf_1" \
"Code" \
"Unused: _code:$gsl_post_hf_1" \
"${PWD}/$gsl_post"
gsl_checker_err=true
@ -498,10 +515,18 @@ gsl__check_needed_headers \
# Date
echo -ne "\r\033[2K: Searching HEADERS... $gsl_header_date"
# Date format check in fr or INternational ?
if [[ `grep -i "fr" <<<"$gsl_site_lang"` ]];then
gsl_log_content="DD-MM-YYYY"
gsl_test_date='^[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]+$'
else
gsl_log_content="YYYY-MM-DD"
gsl_test_date='^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]+$'
fi
gsl__check_needed_headers \
"$gsl_header_date" \
"$gsl_marker_date" \
"YYYY-MM-DD" \
"$gsl_log_content" \
&& gsl_date_err=true
# Description
@ -527,8 +552,8 @@ if ! [[ "$gsl_author_err" ]] && \
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"Header $gsl_marker_author" \
"Header" \
"$gsl_marker_author" \
"$gsl_header_author not registred for domain $gsl_find_domain" \
"${PWD}/$gsl_post"
gsl_checker_err=true
@ -541,13 +566,25 @@ if ! [[ "$gsl_date_err" ]] && \
gsl__logs_print \
"$gsl_log_e" \
"Content" \
"Header $gsl_marker_date" \
"$gsl_header_date not YYYY-MM-DD" \
"Header" \
"$gsl_marker_date" \
"$gsl_header_date not $gsl_log_content" \
"${PWD}/$gsl_post"
gsl_checker_err=true
gsl_date_mismatch=true
fi
if ! [[ $gsl_date_mismatch ]];then
gsl_date_m=`awk -F- '{print $2}' <<<"$gsl_header_date"`
[[ "$gsl_date_m" -gt 12 ]] \
&& gsl__logs_print \
"$gsl_log_e" \
"Header" \
"$gsl_marker_date" \
"$gsl_header_date : Month > 12..." \
"${PWD}/$gsl_post" \
&& gsl_checker_err=true
fi
# Slug format title-post
if ! [[ "$gsl_slug_err" ]];then
@ -561,8 +598,8 @@ if ! [[ "$gsl_slug_err" ]];then
"$gsl_post" && \
gsl__logs_print \
"$gsl_log_w" \
"Content" \
"Header $gsl_marker_slug" \
"Header" \
"$gsl_marker_slug" \
"Changed: $gsl_header_slug_test" \
"${PWD}/$gsl_post"

View File

@ -99,11 +99,11 @@ awk -v s="$1" \
#======================================================================
# Loop till no more list marker
gsl__make_list() {
if [[ `awk -v mls="$gsl_mark_listo" \
'$1 ~ mls {print NR,$0;exit}' \
if [[ `awk -v mls="\$gsl_mark_listo" \
'match($1,mls) {print NR,$0;exit}' \
"$gsl_tmp_post"` ]] || \
[[ `awk -v mls="$gsl_mark_list" \
'$1 ~ mls {print NR,$0;exit}' \
[[ `awk -v mls="\$gsl_mark_list" \
'match($1,mls) {print NR,$0;exit}' \
"$gsl_tmp_post"` ]];then
gsl__make_list_read_by_block
fi
@ -170,12 +170,12 @@ gsl__make_list
# =====================================================================
# Create TMP HTML block list file
# =====================================================================
gsl_file_html_list=`mktemp`
gsl__make_list_convert() {
gsl_file_html_list=`mktemp`
# mln: marker list number | pmln: previous list mark number
gsl__make_list_count_prev_mark() {
pml=`awk -v pln=$(( ln -1 )) 'NR == pln {print $1}' "$gsl_file_block_list"`
pml=`gawk -v pln=$(( ln -1 )) 'NR == pln {print $1}' "$gsl_file_block_list"`
pmln=${#pml}
}
@ -219,6 +219,7 @@ do
"" \
"<li class=\"${gsl_site_css}_list-li ${gsl_site_css}_list-$mln\">$content</li>" \
>> "$gsl_file_html_list"
else
printf "%${mln_indent_close}s%s\n" \
@ -383,32 +384,32 @@ rm -f "$gsl_file_block_titles"
# Find and convert paragraphs (3 different css styles)
#=======================================================================
gsl__make_paragraphs() {
gsl_html_par_o1="<p class=\"${gsl_site_css}_paragraph\">"
gsl_html_par_o2="<p class=\"${gsl_site_css}_paragraph-2\">"
gsl_html_par_o3="<p class=\"${gsl_site_css}_paragraph-3\">"
gsl_html_par_c="</p>"
echo -ne "\r\033[2K: Converting Paragraphs..."
while read -r "gsl_content_line_nbr" "gsl_content_line"
while read -r "ln" "content"
do
case "$gsl_content_line" in
case "$content" in
")")
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_c," \
sed -i "${ln}s,.*,</p>," \
"$gsl_tmp_post"
;;
"("|"( 1")
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o1," \
"$gsl_tmp_post"
;;
"( 2")
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o2," \
"$gsl_tmp_post"
;;
"( 3")
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o3," \
"("*)
gsl_css_id=`
awk -v l="$ln" \
'NR == l {print $2}' \
"$gsl_tmp_post"`
if [[ "$gsl_css_id" ]] && \
[[ `grep '^[-0-9a-zA-Z]*$' <<<"$gsl_css_id"` ]];then
gsl_css_id="-$gsl_css_id"
fi
gsl_html_par_id="<p class=\"${gsl_site_css}_paragraph$gsl_css_id\">"
sed -i "${ln}s,.*,$gsl_html_par_id," \
"$gsl_tmp_post"
;;
*)
continue
;;

View File

@ -226,6 +226,6 @@ awk -v l="$gsl_post_begin" \
gsl__post_begin() {
gsl_post_begin=`
awk -v m="#1" \
'$1 == m {print NR;exit}' \
'match($1,m) {print NR;exit}' \
"$gsl_post"`
}

View File

@ -82,10 +82,15 @@ done < <(ls -1 "$gsl_dir_db" | grep ".gsl.db")
#gsl.articles.posts=nombre d'articles type page
#gsl.authors=nombre d'auteurs
#gsl.articles.words=
#gsl.articles.quotes=
#gsl.articles.paragraphs=
printf '%s\n%s\n%s\n%s\n' \
"gsl.articles=$gsl_stats_articles_www" \
"gsl_articles_pages=$gsl_stats_articles_pages_www" \
"gsl_articles_posts=$gsl_stats_articles_posts_www" \
"gsl.articles.pages=$gsl_stats_articles_pages_www" \
"gsl.articles.posts=$gsl_stats_articles_posts_www" \
"gsl.authors=$gsl_auth_max" \
> "$gsl_file_sti" && \
echo "> Génération des stats (Statoolinfos): $gsl_file_sti"

View File

@ -177,8 +177,8 @@ gsl__check_needed_headers() {
! [[ "$1" ]] \
&& gsl__logs_print \
"$gsl_log_e" \
"Post" \
"Header $2" \
"Content" \
"$2" \
"Missing: $3" \
"${PWD}/$gsl_post" \
&& gsl_checker_err=true
@ -241,7 +241,7 @@ if ! [[ "$gsl_post_hf_3" ]];then
"$gsl_log_w" \
"$1" \
"$2" \
"Line:$gsl_post_hf_l > No Alt Text ?" \
"Line:$gsl_post_hf_l > No Alt Text" \
"${PWD}/$gsl_post"
gsl_checker_war=true
;;