gsl-statique-litterateur/var/lib/gsl/scripts/gsl__post_checkers

827 lines
21 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# file: gsl__post_checkers
# Folder: /var/lib/gsl/scripts
2022-06-14 18:51:19 +02:00
# By echolib (XMPP: im@echolib.re)
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#======================================================================
2022-06-14 18:51:19 +02:00
# Get arguments from COMMAND (check)
# $2 -F (to force) or File
# $3 File
#======================================================================
2022-06-14 18:51:19 +02:00
check__OPTIONS() {
gsl_proc="check"
while test "$2"
do
case "$2" in
-F)
gsl_force_check=true
log_info_force="Force "
;;
-N)
unset gsl_force_check
gsl_check_newer=true
;;
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
*".gsl")
if__file "$2" post
gsl_post="$2"
post_only="$2"
;;
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
*)
gsl__invalid_option "$2" "-F|-N|(FILE)"
;;
esac
shift
done
if ! [[ "$gsl_post" ]];then
log_info_all=" ALL"
[[ $gsl_check_newer ]] \
&& log_info_all+=" NEWER"
2022-02-27 19:16:16 +01:00
fi
2022-06-14 18:51:19 +02:00
log__process_begin "${log_info_force}Check${log_info_all}"
posts__loop check
# For logs ; set post or unset if all
[[ $log_info_all ]] && unset gsl_post
[[ $post_only ]] && gsl_post="$post_only"
log__process_end "${log_info_force}Check${log_info_all}"
2022-02-27 19:16:16 +01:00
}
2022-06-14 18:51:19 +02:00
#======================================================================
2022-06-14 18:51:19 +02:00
# From post__loop() ; get and CHECK headers values
# Called from read__line_with() in gsl__do_commons
# $1: marker
# $2: type (meta/metas)
#======================================================================
2022-06-14 18:51:19 +02:00
check__headers_from_filter() {
case "$4" in
meta)
check__meta_header "$3"
2022-02-27 19:16:16 +01:00
;;
2022-06-14 18:51:19 +02:00
metas|content)
case "$3" in
"title") check__titles ;;
"link") check__link ;;
"abbr") check__abbr ;;
"image") check__file_image ;;
"flink") check__file_link ;;
"fcode") check__file_code ;;
"fbrut") check__file_brut ;;
"icode") check__icode ;;
"strong") check__strong ;;
"bold") check__bold ;;
"em") check__emphasis ;;
"strike") check__strike ;;
esac
2022-02-27 19:16:16 +01:00
;;
esac
}
2022-06-14 18:51:19 +02:00
#======================================================================
2022-06-14 18:51:19 +02:00
# Call in posts_loop() for process before Checkers()
# Check if error in meta marker
# From get__needed_headers() in gsl__do_commons
# $1: marker
#======================================================================
2022-06-14 18:51:19 +02:00
check__meta_header() {
if ! [[ "$header_f1" ]];then
gsl__logs_print -e -h \
"$1" \
"Not set" \
"$PWD/$gsl_post"
return 1
fi
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
case "$1" in
"$gsl_marker_type")
gsl_post_type="$header_f1"
case "$gsl_post_type" in
page|post)
gsl__logs_print -i -h \
"$1" \
"Set to '$gsl_post_type'" \
"${PWD}/$gsl_post"
;;
*)
gsl__logs_print -e -h \
"$1" \
"Wrong '$gsl_post_type' ; $gsl_log_act_type" \
"${PWD}/$gsl_post"
;;
esac
;;
"$gsl_marker_css")
gsl_post_css=" $header_f1"
gsl__logs_print -i -h \
"$1" \
2022-06-14 18:51:19 +02:00
"Body template: $header_f1" \
"$PWD/$gsl_post"
;;
"$gsl_marker_title")
gsl_post_title="$header_f1"
;;
"$gsl_marker_date")
gsl_post_date="$header_f1"
if [[ `grep -i "fr" <<<"$site_lang"` ]];then
gsl_test_date='^[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]+$'
gsl_log_content="DD-MM-YYYY"
else
gsl_test_date='^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]+$'
gsl_log_content="YYYY-MM-DD"
fi
if [[ "$gsl_post_date" =~ $gsl_test_date ]];then
gsl_date_m=`awk -F- '{print $2}' <<<"$gsl_post_date"`
(( "$gsl_date_m" > 12 )) \
&& gsl__logs_print -e -h \
"$1" \
"'$gsl_post_date' ; Month: $gsl_date_m > 12..." \
"${PWD}/$gsl_post"
else
gsl__logs_print -e -h \
"$1" \
"Mismatch '$gsl_post_date' ; not $gsl_log_content" \
"${PWD}/$gsl_post"
fi
# timestamp date to db too (sidebar sort)
false_time=`date +%T`
if [[ `grep -i "fr" <<<"$site_lang"` ]];then
gsl_date_y=`awk -F- '{print $3}' <<<"$gsl_post_date"`
gsl_date_d=`awk -F- '{print $1}' <<<"$gsl_post_date"`
else
gsl_date_y=`awk -F- '{print $1}' <<<"$gsl_post_date"`
gsl_date_d=`awk -F- '{print $3}' <<<"$gsl_post_date"`
fi
date_epoch="$gsl_date_y-$gsl_date_m-$gsl_date_d $false_time"
date_epoch=`date +%s -u -d "$date_epoch"`
;;
"$gsl_marker_slug")
gsl_post_slug="$header_f1"
gsl_post_slug_src="$gsl_post_slug"
gsl_hash_slug_src=`cksum <<<"$gsl_post_slug_src"`
# Type page with "/" in
if [[ "$gsl_post_type" == "page" ]] && \
[[ `grep '/' <<<"$gsl_post_slug"` ]];then
gsl_post_slug=${gsl_post_slug////-}
gsl__logs_print -w -h \
"$1" \
"Has '/' for type $gsl_post_type ; Replaced with '-'" \
"${PWD}/$gsl_post"
fi
# Ensure no ending / for slug
gsl_post_slug=${gsl_post_slug/%\//}
# Has space
gsl_post_slug=${gsl_post_slug// /-}
gsl_hash_slug=`cksum <<<"$gsl_post_slug"`
if ! [[ "$gsl_hash_slug" == "$gsl_hash_slug_src" ]];then
mark_slug_src="$gsl_marker_slug $gsl_post_slug_src"
mark_slug_new="$gsl_marker_slug $gsl_post_slug"
sed -i \
"s^$mark_slug_src^$mark_slug_new^" \
"$gsl_post"
gsl__logs_print -w -h \
"$1" \
"Changed to: '$gsl_post_slug'" \
"${PWD}/$gsl_post"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
article__sum "$gsl_post"
fi
# Already used slug
while read -r "file_db"
do
gsl_slug_db_hash=`
awk -F= '/article_Hash_DB/ {print $2}' \
"$file_db"`
gsl_slug_db_type=`
awk -F= '/article_Type/ {print $2}' \
"$file_db"`
! [[ "$gsl_slug_db_type" == "$gsl_post_type" ]] \
&& continue
[[ "$gsl_slug_db_hash" == "$article_Hash_DB" ]] \
&& continue
gsl__logs_print -e -h \
"$1" \
"'$header_f1' already in use ; change it" \
"$file_db"
break
done < <(grep -sl "article_Slug=\"$gsl_post_slug\"" \
$gsl_dir_db_domain/*.db)
;;
"$gsl_marker_author")
gsl_post_author="$header_f1"
if ! [[ `grep "^$gsl_post_author$" "$gsl_file_domain_authors"` ]];then
gsl__logs_print -e -h \
"$1" \
"'$gsl_post_author' ; not registred !" \
"${PWD}/$gsl_post"
fi
;;
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
"$gsl_marker_info")
gsl_post_info="$header_f1"
if (( ${#gsl_post_info} <= 18 ));then
gsl__logs_print -w -h \
"$1" \
"'$gsl_post_info' ; not too short ?" \
"${PWD}/$gsl_post"
fi
;;
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
"$gsl_marker_tags")
gsl_post_tags="$header_f1"
gsl_stat_tags=`awk -F, '{print NF}' <<<$gsl_post_tags`
;;
esac
}
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
#======================================================================
# --------------------------------
# Do all checkers From: loop_posts
# --------------------------------
#======================================================================
Checkers() {
get__needed_headers "check" "$gsl_tmp_head"
! [[ $gsl_do_check ]] && return
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
stats__init # init stats values
gsl_tmp_db=`mktemp` # Create tmp DB for found files to add then to DB
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Check for links
read__line_with "^$gsl_marker_link" "check" \
"link" "metas" "$gsl_tmp_head"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Check abbrs
read__line_with "^$gsl_marker_abbr" "check" \
"abbr" "metas" "$gsl_tmp_head"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Check images
read__line_with "^$gsl_marker_image" "check" \
"image" "metas" "$gsl_tmp_head"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Check files
read__line_with "^$gsl_marker_flink" "check" \
"flink" "metas" "$gsl_tmp_head"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Check filesCODE
read__line_with "^$gsl_marker_fcode" "check" \
"fcode" "metas" "$gsl_tmp_head"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Check for brut code file
read__line_with "^$gsl_marker_fbrut" "check" \
"fbrut" "metas" "$gsl_tmp_head"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Check for content titles
read__line_with "^#[1-6]" "check" \
"title" "content" "$gsl_tmp_post"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Check icode marks match
read__line_with "$gsl_mark_icode" "check" \
"icode" "content" "$gsl_tmp_post"
# Check strong marks match
read__line_with "$gsl_mark_strong" "check" \
"strong" "content" "$gsl_tmp_post"
# Check bold marks match
read__line_with "$gsl_mark_bold" "check" \
"bold" "content" "$gsl_tmp_post"
# Check emphasis marks match
read__line_with "$gsl_mark_em" "check" \
"em" "content" "$gsl_tmp_post"
# Check strike (line-through) marks match
read__line_with "$gsl_mark_strike" "check" \
"strike" "content" "$gsl_tmp_post"
# Independant modules
check__paragraphs "$gsl_tmp_post" # Check for paragraphs markers
check__lists "$gsl_tmp_post" # Check for lists markers
check__blockquote "$gsl_tmp_post" # Check for blockquote markers
# Errors => remove from DB and srv WIP
[[ "$gsl_checker_err" ]] \
&& article_Errors="yes" \
|| article_Errors="no"
Stat__words "$gsl_tmp_post"
DB__set_status chk
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Remove temp files
rm -f "$gsl_tmp_post" \
"$gsl_tmp_head" \
"$gsl_tmp_db"
2022-02-27 19:16:16 +01:00
}
2022-06-14 18:51:19 +02:00
#----------------------------------------------------------------------
# -------------------------------------------------
# Modules checkers
# -------------------------------------------------
#----------------------------------------------------------------------
2022-02-27 19:16:16 +01:00
#======================================================================
2022-06-14 18:51:19 +02:00
# Checking titles
2022-02-27 19:16:16 +01:00
#======================================================================
2022-06-14 18:51:19 +02:00
check__titles() {
((gsl_stat_titles++))
mark_title=`awk '{print $1}' <<<"$gsl_line"`
content_title=`awk '{print $2}' <<<"$gsl_line"`
post_ln=$((ln + gsl_post_begin - 1))
[[ "$content_title" ]] && return
gsl__logs_print -e -c \
"Title" \
"Line: $post_ln ; No content for $mark_title" \
"${PWD}/$gsl_post"
}
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
#======================================================================
# Check link
#======================================================================
check__link() {
if ! [[ "$header_f1" && "$header_f2" ]];then
gsl__logs_print -e -h \
"$gsl_marker_link" \
"Line: $ln not set ; $gsl_log_act_link" \
"${PWD}/$gsl_post"
return
fi
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
if ! [[ "$header_f3" ]];then
gsl__logs_print -w -h \
"$gsl_marker_link" \
"Line: $ln No Alt-Text ; $gsl_log_act_link" \
"${PWD}/$gsl_post"
fi
2022-06-14 18:51:19 +02:00
if ! [[ `grep "\<_$header_f1\>" "$gsl_tmp_post"` ]];then
gsl__logs_print -e -c \
"$gsl_marker_link" \
"Line: $ln ; Unused: '_$header_f1'" \
"${PWD}/$gsl_post"
return
fi
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Get Online status
case "$header_f2" in
"http"*)
url_status=`
timeout 2 \
curl -o /dev/null --silent --head --write-out \
'%{http_code}' \
"$header_f2" 2>/dev/null \
|| url_status="T"`
;;
*)
url_status=NS
;;
esac
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Analyse Online Status
case "$url_status" in
1*|2*|3*)
gsl__logs_print -i -h \
"$gsl_marker_link" \
"Online: $url_status ; ${header_f2:0:30}..." \
"${PWD}/$gsl_post"
((gsl_stat_links_online++))
;;
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
NS)
gsl__logs_print -w -h \
"$gsl_marker_link" \
"No status ; ${header_f2:0:30}..." \
"${PWD}/$gsl_post"
;;
T)
gsl__logs_print -w -h \
"$gsl_marker_link" \
"Timeout ; ${header_f2:0:30}..." \
"${PWD}/$gsl_post"
;;
""|*)
gsl__logs_print -w -h \
"$gsl_marker_link" \
"Offline: $url_status ; ${header_f2:0:30}..." \
"${PWD}/$gsl_post"
;;
esac
# Stat: Count
((gsl_stat_links++))
}
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
#======================================================================
# Check paragraphs markers
#======================================================================
check__paragraphs() {
gsl_post_po=`
grep "^$gsl_mark_p_start$\|^$gsl_mark_p_start " "$1" \
| wc -l`
gsl_post_pc=`
grep "^$gsl_mark_p_close$" "$1" \
| wc -l`
if (( "$gsl_post_po" == 0 ));then
gsl__logs_print -w -c \
"Paragraphs" \
"Unused '$gsl_mark_p_start' & '$gsl_mark_p_close' at begining lines" \
2022-02-27 19:16:16 +01:00
"${PWD}/$gsl_post"
2022-06-14 18:51:19 +02:00
gsl_stat_p="0"
elif (( "$gsl_post_po" == "$gsl_post_pc" ));then
gsl_stat_p="$gsl_post_po"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
else
gsl__logs_print -e -c \
"Paragraphs" \
"Mismatch '$gsl_mark_p_start' & '$gsl_mark_p_close' ; not paired" \
"${PWD}/$gsl_post"
2022-02-27 19:16:16 +01:00
fi
}
2022-06-14 18:51:19 +02:00
2022-02-27 19:16:16 +01:00
#======================================================================
2022-06-14 18:51:19 +02:00
# Check paragraphs markers
2022-02-27 19:16:16 +01:00
#======================================================================
2022-06-14 18:51:19 +02:00
check__lists() {
gsl_post_lo=`grep "^<<$\|^<< " "$1" | wc -l`
gsl_post_lc=`grep "^>>$" "$1" | wc -l`
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
if (( "$gsl_post_lo" == "$gsl_post_lc" ));then
gsl_stat_lists="$gsl_post_lo"
2022-02-27 19:16:16 +01:00
else
2022-06-14 18:51:19 +02:00
gsl__logs_print -e -c \
"Lists" \
"Mismatch '<<' & '>>' ; not paired" \
2022-02-27 19:16:16 +01:00
"${PWD}/$gsl_post"
fi
}
2022-06-14 18:51:19 +02:00
2022-02-27 19:16:16 +01:00
#======================================================================
2022-06-14 18:51:19 +02:00
# Check blockquotes markers
2022-02-27 19:16:16 +01:00
#======================================================================
2022-06-14 18:51:19 +02:00
check__blockquote() {
gsl_post_bq=`grep "^$gsl_mark_blockquote" "$1" | wc -l`
gsl_post_bq_paired=$(( $gsl_post_bq % 2 ))
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
if [[ "$gsl_post_bq_paired" -eq 0 ]];then
gsl_stat_bq=$(( gsl_post_bq / 2 ))
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
else
gsl__logs_print -e -c \
"Blockquote" \
"Mismatch: '$gsl_mark_blockquote' ; not paired" \
"${PWD}/$gsl_post"
fi
}
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
#======================================================================
# Check ABBR
#======================================================================
check__abbr() {
if ! [[ "$header_f1" && "$header_f2" ]];then
gsl__logs_print -e -h \
"$gsl_marker_abbr" \
"Line: $ln not set ; $gsl_log_act_abbr" \
"${PWD}/$gsl_post"
# must be in caps lock
elif ! [[ "$header_f1" == ${header_f1^^} ]];then
gsl__logs_print -e -c \
"$gsl_marker_abbr" \
"Line: $ln ; '$header_f1' not UPPER case" \
"${PWD}/$gsl_post"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# ! forget space ↓
elif ! [[ `grep -E " $header_f1|^$header_f1 " "$gsl_tmp_post"` ]];then
gsl__logs_print -e -c \
"$gsl_marker_abbr" \
"Line: $ln ; Unused: '$header_f1'" \
"${PWD}/$gsl_post"
2022-02-27 19:16:16 +01:00
else
2022-06-14 18:51:19 +02:00
((gsl_stat_abbrs++))
fi
}
2022-02-27 19:16:16 +01:00
2022-03-01 18:39:46 +01:00
2022-06-14 18:51:19 +02:00
#======================================================================
# Check Flink
#======================================================================
check__file_link() {
if ! [[ "$header_f1" && "$header_f2" ]];then
gsl__logs_print -e -h \
"$gsl_marker_flink" \
"Line: $ln not set ; $gsl_log_act_flink" \
"${PWD}/$gsl_post"
return
fi
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
if ! [[ "$header_f3" ]];then
gsl__logs_print -w -h \
"$gsl_marker_flink" \
"Line: $ln No Alt-Text ; $gsl_log_act_flink" \
"${PWD}/$gsl_post"
2022-02-27 19:16:16 +01:00
fi
2022-06-14 18:51:19 +02:00
if ! [[ `grep "\<__$header_f1\>" "$gsl_tmp_post"` ]];then
gsl__logs_print -e -c \
"$gsl_marker_flink" \
"Unused: '__$header_f1'" \
"${PWD}/$gsl_post"
gsl_flink_err=true
fi
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
if ! [[ -f "$gsl_dir_domain_files/$header_f2" ]];then
gsl__logs_print -e -h \
"$gsl_marker_flink" \
"Not found: $header_f2" \
"$gsl_dir_domain_docs/$header_f2"
gsl_flink_err=true
fi
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
[[ $gsl_flink_err ]] && return
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Register file to DB
printf '%s\n' \
"# Flink_URI:$gsl_dir_domain_fles/$header_f2" \
>> "$gsl_tmp_db"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Stat
((gsl_stat_flinks++))
2022-02-27 19:16:16 +01:00
}
2022-06-14 18:51:19 +02:00
2022-02-27 19:16:16 +01:00
#======================================================================
2022-06-14 18:51:19 +02:00
# Check images
2022-02-27 19:16:16 +01:00
#======================================================================
2022-06-14 18:51:19 +02:00
check__file_image() {
if ! [[ "$header_f1" && "$header_f2" && "$header_f3" ]];then
gsl__logs_print -e -h \
"$gsl_marker_image" \
"Line: $ln not set ; $gsl_log_act_image" \
"${PWD}/$gsl_post"
return
fi
2022-04-25 13:17:09 +02:00
2022-06-14 18:51:19 +02:00
if ! [[ `grep "_image:$header_f1" "$gsl_tmp_post"` ]];then
gsl__logs_print -e -c \
"$gsl_marker_image" \
"Unused: '_image:$header_f1'" \
"${PWD}/$gsl_post"
gsl_image_err=true
fi
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
if ! [[ -f "$gsl_dir_domain_images/$header_f2" ]];then
gsl__logs_print -e -h \
2022-04-25 13:17:09 +02:00
"$gsl_marker_image" \
2022-06-14 18:51:19 +02:00
"Not found: $header_f2" \
"$gsl_dir_domain_images/$header_f2"
gsl_image_err=true
fi
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
[[ $gsl_image_err ]] && return
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Register file to DB
printf '%s\n' \
"# Image_URI:$gsl_dir_domain_images/$header_f2" \
>> "$gsl_tmp_db"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Stat
((gsl_stat_images++))
}
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
#======================================================================
# Check fcode: file code to convert and import in content
#======================================================================
check__file_code() {
if ! [[ "$header_f1" && "$header_f2" ]];then
gsl__logs_print -e -h \
"$gsl_marker_fcode" \
"Line: $ln not set ; $gsl_log_act_fcode" \
"${PWD}/$gsl_post"
return
fi
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
if ! [[ "$header_f3" ]];then
gsl__logs_print -w -h \
"$gsl_marker_fcode" \
"Line: $ln No Alt-Text ; $gsl_log_act_fcode" \
"${PWD}/$gsl_post"
fi
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
if ! [[ `grep "$gsl_mark_fcode:$header_f1" "$gsl_tmp_post"` ]];then
gsl__logs_print -e -c \
"$gsl_marker_fcode" \
"Unused: '$gsl_mark_fcode:$header_f1'" \
2022-02-27 19:16:16 +01:00
"${PWD}/$gsl_post"
2022-06-14 18:51:19 +02:00
gsl_fcode_err=true
fi
if ! [[ -f "$gsl_dir_domain_files/$header_f2" ]];then
gsl__logs_print -e -h \
"$gsl_marker_fcode" \
"Not found: $header_f2" \
"$gsl_dir_domain_precodes/$header_f2"
gsl_fcode_err=true
2022-02-27 19:16:16 +01:00
fi
2022-06-14 18:51:19 +02:00
[[ $gsl_fcode_err ]] && return
# Register file to DB
printf '%s\n' \
"# Fcode_URI:$gsl_dir_domain_files/$header_f2" \
>> "$gsl_tmp_db"
# Stat
((gsl_stat_fcodes++))
2022-02-27 19:16:16 +01:00
}
2022-06-14 18:51:19 +02:00
2022-02-27 19:16:16 +01:00
#======================================================================
2022-06-14 18:51:19 +02:00
# Check fbrut : brut file to import in content
2022-02-27 19:16:16 +01:00
#======================================================================
2022-06-14 18:51:19 +02:00
check__file_brut() {
if ! [[ "$header_f1" && "$header_f2" ]];then
gsl__logs_print -e -h \
"$gsl_marker_fbrut" \
"Line: $ln not set ; $gsl_log_act_fbrut" \
"${PWD}/$gsl_post"
return
fi
2022-03-12 16:16:21 +01:00
2022-06-14 18:51:19 +02:00
if ! [[ `grep "$gsl_mark_fbrut:$header_f1" "$gsl_tmp_post"` ]];then
gsl__logs_print -e -c \
"$gsl_marker_fbrut" \
"Unused: '$gsl_mark_fbrut:$header_f1'" \
"${PWD}/$gsl_post"
gsl_fbrut_err=true
fi
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
if ! [[ -f "$gsl_dir_domain_files/$header_f2" ]];then
gsl__logs_print -e -h \
"$gsl_marker_fbrut" \
"Not found: $header_f2" \
"$gsl_dir_domain_files/$header_f2"
gsl_fbrut_err=true
fi
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
[[ $gsl_fcode_err ]] && return
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Register file to DB
printf '%s\n' \
"# Fbrut_URI:$gsl_dir_domain_files/$header_f2" \
>> "$gsl_tmp_db"
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
# Stat
((gsl_stat_fbruts++))
}
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
#======================================================================
# Check iCode marks match nbr + stats
#======================================================================
check__icode() {
post_ln=$((ln + gsl_post_begin - 1))
mark_icode_nbr="${gsl_line//[^$gsl_mark_icode]}"
mark_icode_nbr=${#mark_icode_nbr}
mark_icode_paired=$(( $mark_icode_nbr % 2 ))
if [[ "$mark_icode_paired" -eq 0 ]];then
stat_icode_nbr=$(( mark_icode_nbr / 2 ))
gsl_stat_icodes=$(( gsl_stat_icodes + stat_icode_nbr ))
else
gsl__logs_print -e -c \
"iCode" \
"Line: $post_ln ; '$gsl_mark_icode...$gsl_mark_icode' not paired" \
"$PWD/$gsl_post"
2022-02-27 19:16:16 +01:00
fi
2022-06-14 18:51:19 +02:00
}
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
#======================================================================
# Check stronng marks match nbr + stats
#======================================================================
check__strong() {
post_ln=$((ln + gsl_post_begin - 1))
mark_strong_nbr="${gsl_line//[^$gsl_mark_strong]}"
mark_strong_nbr=${#mark_strong_nbr}
mark_strong_paired=$(( $mark_strong_nbr % 2 ))
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
if [[ "$mark_strong_paired" -eq 0 ]];then
stat_strong_nbr=$(( mark_strong_nbr / 2 ))
gsl_stat_strongs=$(( gsl_stat_strongs + stat_strong_nbr ))
2022-02-27 19:16:16 +01:00
else
2022-06-14 18:51:19 +02:00
gsl__logs_print -e -c \
"Strong" \
"Line: $post_ln ; '$gsl_mark_strong...$gsl_mark_strong' not paired" \
"$PWD/$gsl_post"
2022-02-27 19:16:16 +01:00
fi
}
2022-06-14 18:51:19 +02:00
#======================================================================
2022-06-14 18:51:19 +02:00
# Check Bold marks match nbr + stats
#======================================================================
2022-06-14 18:51:19 +02:00
check__bold() {
post_ln=$((ln + gsl_post_begin - 1))
mark_bold_nbr="${gsl_line//[^$gsl_mark_bold]}"
mark_bold_nbr=${#mark_bold_nbr}
mark_bold_paired=$(( $mark_bold_nbr % 2 ))
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
if [[ "$mark_bold_paired" -eq 0 ]];then
stat_bold_nbr=$(( mark_bold_nbr / 2 ))
gsl_stat_bolds=$(( gsl_stat_bolds + stat_bold_nbr ))
2022-02-27 19:16:16 +01:00
2022-04-25 13:17:09 +02:00
else
2022-06-14 18:51:19 +02:00
gsl__logs_print -e -c \
"Bold" \
"Line: $post_ln ; '$gsl_mark_bold...$gsl_mark_bold' not paired" \
"$PWD/$gsl_post"
2022-04-25 13:17:09 +02:00
fi
2022-06-14 18:51:19 +02:00
}
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
#======================================================================
# Check Bold marks match nbr + stats
#======================================================================
check__emphasis() {
post_ln=$((ln + gsl_post_begin - 1))
mark_em_nbr="${gsl_line//[^$gsl_mark_em]}"
mark_em_nbr=${#mark_em_nbr}
mark_em_paired=$(( $mark_em_nbr % 2 ))
2022-02-14 02:57:58 +01:00
2022-06-14 18:51:19 +02:00
if [[ "$mark_em_paired" -eq 0 ]];then
stat_em_nbr=$(( mark_em_nbr / 2 ))
gsl_stat_italics=$(( gsl_stat_italics + stat_em_nbr ))
2022-02-27 19:16:16 +01:00
2022-06-14 18:51:19 +02:00
else
gsl__logs_print -e -c \
"Emphasis" \
"Line: $post_ln ; '$gsl_mark_em...$gsl_mark_em' not paired" \
"$PWD/$gsl_post"
fi
2022-06-14 18:51:19 +02:00
}
2022-06-14 18:51:19 +02:00
#======================================================================
# Check strike (lt) marks match nbr + stats
#======================================================================
check__strike() {
post_ln=$((ln + gsl_post_begin - 1))
mark_lt_nbr="${gsl_line//[^$gsl_mark_strike]}"
mark_lt_nbr=${#mark_lt_nbr}
mark_lt_paired=$(( $mark_lt_nbr % 2 ))
if [[ "$mark_lt_paired" -eq 0 ]];then
stat_lt_nbr=$(( mark_lt_nbr / 2 ))
gsl_stat_strikes=$(( gsl_stat_strikes + stat_lt_nbr ))
2022-02-14 02:57:58 +01:00
2022-06-14 18:51:19 +02:00
else
gsl__logs_print -e -c \
"Strike" \
"Line: $post_ln ; '$gsl_mark_strike...$gsl_mark_strike' not paired" \
"$PWD/$gsl_post"
2022-02-14 02:57:58 +01:00
fi
}