From 5420c8353acaa605a54234640573bf38a442d55f Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Sun, 6 Mar 2022 15:57:20 +0100 Subject: [PATCH] Added post-list [OPT] ; Add Post to HTML File Listing --- etc/gsl/gsl.conf | 5 ++++ usr/local/bin/gsl | 42 ++++++++++++++++++++++++--- var/lib/gsl/scripts/gsl__page_creator | 34 +++++++++++++--------- var/lib/gsl/scripts/gsl__post_manager | 29 ++++++++++++++++-- 4 files changed, 90 insertions(+), 20 deletions(-) diff --git a/etc/gsl/gsl.conf b/etc/gsl/gsl.conf index f6f834a..5f21e6d 100644 --- a/etc/gsl/gsl.conf +++ b/etc/gsl/gsl.conf @@ -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 diff --git a/usr/local/bin/gsl b/usr/local/bin/gsl index 45eccc5..8018d8f 100755 --- a/usr/local/bin/gsl +++ b/usr/local/bin/gsl @@ -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 diff --git a/var/lib/gsl/scripts/gsl__page_creator b/var/lib/gsl/scripts/gsl__page_creator index a5cb472..f6098bf 100644 --- a/var/lib/gsl/scripts/gsl__page_creator +++ b/var/lib/gsl/scripts/gsl__page_creator @@ -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 } #---------------------------------------------------------------------- diff --git a/var/lib/gsl/scripts/gsl__post_manager b/var/lib/gsl/scripts/gsl__post_manager index d2af782..7779d94 100644 --- a/var/lib/gsl/scripts/gsl__post_manager +++ b/var/lib/gsl/scripts/gsl__post_manager @@ -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 } #=======================================================================