Updated DB & Logs ; Post Status

This commit is contained in:
Cyrille L 2022-03-06 01:47:58 +01:00
parent 96c314fd8c
commit 4250a5fb9c
4 changed files with 75 additions and 57 deletions

View File

@ -9,6 +9,8 @@
# Get Post Hash & Status From Database
#======================================================================
gsl__db_get_post_datas() {
gsl_db_post_hash=0
if [[ -f "$gsl_file_db_post" ]];then
gsl_db_post_hash=`
@ -22,6 +24,16 @@ if [[ -f "$gsl_file_db_post" ]];then
awk -F: 'NR == 2 {print $2}' \
"$gsl_file_db_post"`
else
gsl__logs_print \
"$gsl_log_w" \
"DB" \
"Post" \
"$gsl_post missing. Check it first" \
"$gsl_file_db_post"
gsl_checker_war=true
fi
}
@ -30,6 +42,7 @@ fi
#======================================================================
gsl__db_compare_post_hash() {
gsl_checker_war=true
if ! (( $gsl_post_hash == $gsl_db_post_hash ));then
gsl__logs_print \
"$gsl_log_w" \
@ -43,7 +56,7 @@ else
"$gsl_log_w" \
"Post" \
"Hash" \
"$gsl_post already checked" \
"$gsl_post checked with hash:$gsl_db_post_hash " \
"${PWD}/$gsl_post"
fi
}
@ -52,29 +65,24 @@ fi
# Set Post Status in Database according to proceess
#======================================================================
gsl__db_set_post_status() {
echo "D> DB:$gsl_file_db_post $gsl_process > $gsl_db_post_status"
case "$gsl_process" in
chk)
case "$gsl_db_post_status" in
chk)
gsl__db_compare_post_hash
[[ "$gsl_post_new_hash" ]] || return # Do Nothing if same Hash
gsl__db_create_post
;;
wip)
gsl__db_compare_post_hash
[[ "$gsl_post_new_hash" ]] || return # Do Nothing if same Hash
gsl_process="wip"
gsl__db_create_post
;;
www)
gsl__db_compare_post_hash
[[ "$gsl_post_new_hash" ]] || return # Do Nothing if same Hash
gsl_process="www"
gsl__db_create_post
;;
""|=)
echo "D> Create..."
gsl__db_create_post
;;
esac
@ -100,7 +108,6 @@ esac
# Create DB File from Data Post
#======================================================================
gsl__db_create_post() {
echo "D> DB: $gsl_process > $gsl_db_post_status > $gsl_checker_err"
if [[ "$gsl_checker_err" ]];then
[[ -f "$gsl_file_db_post" ]] \
&& rm -f "$gsl_file_db_post" \

View File

@ -47,9 +47,6 @@ gsl__page_prepare_datas() {
# Source config website (DATAS)
source "$gsl_this_conf_domain/$gsl_find_domain.conf"
# Get Needed Headers DATAS
gsl__get_needed_headers
# Check for Files & Folders in server
gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip"
@ -75,7 +72,12 @@ gsl_uri_site_logo="$gsl_uri/templates/$gsl_site_logo"
#----------------------------------------------------------------------
gsl__check_srv_files() {
if [[ -f "$1" ]];then
echo "! Replace Page: $1"
gsl__logs_print \
"$gsl_log_i" \
"SRV" \
"Files" \
"Exists" \
"$1"
fi
}
@ -107,7 +109,6 @@ cat "$gsl_dir_domain_tpl/last-posts-list.html" \
if (( $((gsl_list_cur_lines )) >= $gsl_list_max_lines ));then
echo "D> $gsl_list_cur_lines > $gsl_list_max_lines"
for i in `seq 1 $gsl_list_lines_per_post`
do
sed -i "1d" "$gsl_dir_domain_tpl/last-posts-list.html"

View File

@ -18,8 +18,7 @@ unset gsl_check_done
# Code readability a11y
gsl_a11y_post=`mktemp`
gsl__prepare_makers
gsl__page_prepare_datas
gsl__post_content_only
mkdir -p "$gsl_srv_wip"
gsl__srv_sync
@ -53,6 +52,7 @@ rm -f "$gsl_tmp_post" # No more Needed tmp file post
# Create HTML Page using gsl_a11y_post
# cat "$gsl_a11y_post"
gsl__page_creator
gsl__db_set_post_status
rm -f "$gsl_a11y_post" # No more Needed a11y post
}
@ -72,24 +72,6 @@ awk -v s="$1" \
"$2" || return
}
#=======================================================================
# Get NEEDED infos, and create TMP file from CONTENT
#=======================================================================
gsl__prepare_makers() {
# Getting NEEDED infos
gsl_post_type=`
awk -F"$gsl_marker_type" '{print $2}' "$gsl_post"`
gsl_post_begin=`
grep -n "#1" $gsl_post \
| head -1 \
| awk -F: '{print $1}'`
# Get extra Headers DATAS
#gsl_header_images=`gsl__get_header "$gsl_marker_image" "$gsl_post"`
gsl__post_content_only
}
#=======================================================================
# ---------------------------------
# Converters

View File

@ -12,8 +12,8 @@
gsl__loop_posts() {
gsl__logs_print \
"$gsl_log_i" \
"Found" \
"Posts" \
"Found" \
"$gsl_nbr_posts" \
"${PWD}"
@ -41,13 +41,13 @@ do
# Set DB Post file
gsl_file_db_post="$gsl_dir_db/$gsl_post.db"
gsl__db_get_post_datas
gsl__db_compare_post_hash
# From COMMAND [OPT]
case "$1" in
check)
gsl_process="chk"
if ! [[ "$gsl_force_check" ]];then
gsl__db_compare_post_hash
! [[ "$gsl_post_new_hash" ]] && continue
fi
@ -60,31 +60,52 @@ do
gsl__all_checkers
;;
make)
gsl_process="wip"
gsl__page_prepare_datas
case "$gsl_db_post_status" in
chk)
gsl__all_makers
;;
make)
gsl_process="wip"
gsl__post_begin
gsl__get_needed_headers
gsl__page_prepare_datas
# echo "D> $gsl_this_conf_domain/$gsl_find_domain.conf"
wip)
if [[ "$gsl_force_make" ]];then
case "$gsl_db_post_status" in
chk)
gsl__all_makers
else
gsl__logs_print \
"$gsl_log_w" \
"Post" \
"Make" \
"$gsl_post already Converted" \
"$gsl_file_db_posts"
gsl_checker_war=true
continue
fi
;;
esac
;;
;;
wip)
# Should not be used...
[[ "$gsl_force_make" ]] \
&& gsl__all_makers \
&& continue
if [[ "$gsl_post_new_hash" ]];then
rm -f "$gsl_srv_wip_page" && \
gsl__logs_print \
"$gsl_log_w" \
"wip" \
"Delete" \
"file ; changes in $gsl_post" \
"$gsl_srv_wip_page"
rm -f "$gsl_file_db_post" && \
gsl__logs_print \
"$gsl_log_w" \
"DB" \
"Delete" \
"file ; changes in $gsl_post" \
"$gsl_file_db_post"
else
gsl__logs_print \
"$gsl_log_w" \
"Post" \
"Make" \
"$gsl_post already Converted" \
"$gsl_file_db_posts"
gsl_checker_war=true
continue
fi
;;
esac
;;
esac
done
@ -134,3 +155,10 @@ awk -v l="$gsl_post_begin" \
"$gsl_post" \
> "$gsl_tmp_post"
}
gsl__post_begin() {
gsl_post_begin=`
grep -n "#1" $gsl_post \
| head -1 \
| awk -F: '{print $1}'`
}