Added post-list [OPT] ; Add Post to HTML File Listing

This commit is contained in:
Cyrille L 2022-03-06 15:57:20 +01:00
parent 8cb881c7bb
commit 5420c8353a
4 changed files with 90 additions and 20 deletions

View File

@ -128,3 +128,8 @@ gsl_marker_file='file: '
# Delimiters to seet for sed in case exists in inline-code
gsl_d=(\, \. \? \% \# \- \: \^ \/ \_ \| )
# Post-listing
gsl_list_max_posts=5
gsl_list_lines_per_post=5

View File

@ -135,10 +135,14 @@ case "$1" in
case "$2" in
-F)
gsl_force_check=true
[[ "$3" ]] && gsl__check_opt_post "$3"
if [[ "$3" ]];then
gsl__check_opt_post "$3"
fi
;;
*)
[[ "$2" ]] && gsl__check_opt_post "$2"
if [[ "$2" ]];then
gsl__check_opt_post "$2"
fi
;;
esac
@ -164,10 +168,14 @@ case "$1" in
case "$2" in
-F)
gsl_force_make=true
[[ "$3" ]] && gsl__check_opt_post "$3"
if [[ "$3" ]];then
gsl__check_opt_post "$3"
fi
;;
*)
[[ "$2" ]] && gsl__check_opt_post "$2"
if [[ "$2" ]];then
gsl__check_opt_post "$2"
fi
;;
esac
@ -188,6 +196,32 @@ case "$1" in
"${PWD}"
;;
post-list)
if [[ "$2" ]];then
gsl__check_opt_post "$2"
else
echo "! Select a Post to add to list"
exit
fi
gsl__check_nbr_posts
gsl__logs_print \
"$gsl_log_i" \
"Starting" \
"Process" \
"Post-List ; Add $2 from domain $gsl_find_domain" \
"$gsl_dir_domain_tpl/last-posts-list.html"
gsl__loop_posts post-list
gsl__logs_print \
"$gsl_log_i" \
"Stopping" \
"Process" \
"Post-List ; Add $2 from domain $gsl_find_domain" \
"$gsl_dir_domain_tpl/last-posts-list.html"
;;
readme)
if [[ -f "/var/lib/gsl/README.md" ]];then
clear

View File

@ -86,28 +86,33 @@ fi
#======================================================================
gsl__page_create_listing() {
# Check if Post is in list ; Status Made
case "$gsl_db_post_status" in
wip|www)
gsl__logs_print \
"$gsl_log_i" \
"Post" \
"Make" \
"$gsl_post already added to Latest listings" \
"$gsl_file_db_posts"
return
case "$1" in
selected)
true
;;
*)
case "$gsl_db_post_status" in
wip|www)
gsl__logs_print \
"$gsl_log_i" \
"Post" \
"Make" \
"$gsl_post already added to Latest listings" \
"$gsl_file_db_posts"
return
;;
esac
;;
esac
touch "$gsl_dir_domain_tpl/last-posts-list.html"
gsl_list_max_posts=5
gsl_list_lines_per_post=5
gsl_list_max_lines=$(( gsl_list_max_posts * gsl_list_lines_per_post))
gsl_list_cur_lines=`
cat "$gsl_dir_domain_tpl/last-posts-list.html" \
| wc -l`
if (( $((gsl_list_cur_lines )) >= $gsl_list_max_lines ));then
for i in `seq 1 $gsl_list_lines_per_post`
do
@ -124,11 +129,12 @@ cat << EOPostSide >> "$gsl_dir_domain_tpl/last-posts-list.html"
EOPostSide
gsl__logs_print \
"$gsl_log_i" \
"$gsl_log_w" \
"Post" \
"Make" \
"$gsl_post added to Latest listings" \
"$gsl_file_db_posts"
"$gsl_dir_domain_tpl/last-posts-list.html"
gsl_checker_war=true
}
#----------------------------------------------------------------------

View File

@ -106,6 +106,27 @@ do
;;
esac
;;
post-list)
case "$gsl_db_post_status" in
wip|online)
gsl_process="wip"
gsl__post_begin
gsl__get_needed_headers
gsl__page_prepare_datas
gsl__page_create_listing selected
;;
*)
gsl__logs_print \
"$gsl_log_e" \
"Post" \
"Status" \
"$gsl_db_post_status: $gsl_post not Converted" \
"$gsl_file_db_posts"
gsl_checker_err=true
;;
esac
;;
esac
done
@ -130,8 +151,12 @@ done
# Check NAME post from [OPT] ; should be from autocompletion
#=======================================================================
gsl__check_opt_post() {
[[ `ls -1 *.gsl | grep "$1"` ]] \
&& gsl_this_post="$1"
if [[ `ls -1 *.gsl | grep "$1"` ]];then
gsl_this_post="$1"
else
echo "! $1 Not Found"
exit
fi
}
#=======================================================================