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 # Delimiters to seet for sed in case exists in inline-code
gsl_d=(\, \. \? \% \# \- \: \^ \/ \_ \| ) 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 case "$2" in
-F) -F)
gsl_force_check=true 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 esac
@ -164,10 +168,14 @@ case "$1" in
case "$2" in case "$2" in
-F) -F)
gsl_force_make=true 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 esac
@ -188,6 +196,32 @@ case "$1" in
"${PWD}" "${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) readme)
if [[ -f "/var/lib/gsl/README.md" ]];then if [[ -f "/var/lib/gsl/README.md" ]];then
clear clear

View File

@ -86,28 +86,33 @@ fi
#====================================================================== #======================================================================
gsl__page_create_listing() { gsl__page_create_listing() {
# Check if Post is in list ; Status Made # Check if Post is in list ; Status Made
case "$gsl_db_post_status" in case "$1" in
wip|www) selected)
gsl__logs_print \ true
"$gsl_log_i" \ ;;
"Post" \
"Make" \ *)
"$gsl_post already added to Latest listings" \ case "$gsl_db_post_status" in
"$gsl_file_db_posts" wip|www)
return gsl__logs_print \
"$gsl_log_i" \
"Post" \
"Make" \
"$gsl_post already added to Latest listings" \
"$gsl_file_db_posts"
return
;;
esac
;; ;;
esac esac
touch "$gsl_dir_domain_tpl/last-posts-list.html" 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_max_lines=$(( gsl_list_max_posts * gsl_list_lines_per_post))
gsl_list_cur_lines=` gsl_list_cur_lines=`
cat "$gsl_dir_domain_tpl/last-posts-list.html" \ cat "$gsl_dir_domain_tpl/last-posts-list.html" \
| wc -l` | wc -l`
if (( $((gsl_list_cur_lines )) >= $gsl_list_max_lines ));then if (( $((gsl_list_cur_lines )) >= $gsl_list_max_lines ));then
for i in `seq 1 $gsl_list_lines_per_post` for i in `seq 1 $gsl_list_lines_per_post`
do do
@ -124,11 +129,12 @@ cat << EOPostSide >> "$gsl_dir_domain_tpl/last-posts-list.html"
EOPostSide EOPostSide
gsl__logs_print \ gsl__logs_print \
"$gsl_log_i" \ "$gsl_log_w" \
"Post" \ "Post" \
"Make" \ "Make" \
"$gsl_post added to Latest listings" \ "$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 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 esac
done done
@ -130,8 +151,12 @@ done
# Check NAME post from [OPT] ; should be from autocompletion # Check NAME post from [OPT] ; should be from autocompletion
#======================================================================= #=======================================================================
gsl__check_opt_post() { gsl__check_opt_post() {
[[ `ls -1 *.gsl | grep "$1"` ]] \ if [[ `ls -1 *.gsl | grep "$1"` ]];then
&& gsl_this_post="$1" gsl_this_post="$1"
else
echo "! $1 Not Found"
exit
fi
} }
#======================================================================= #=======================================================================