From a2c31e41f480ac7d1ec6e002a4326b058fc042a5 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Wed, 2 Mar 2022 17:25:23 +0100 Subject: [PATCH] Fixes, updated:DB,Maker,Listings --- usr/local/bin/gsl | 10 +++ var/lib/gsl/scripts/gsl__db_manager | 14 ++++- var/lib/gsl/scripts/gsl__page_creator | 84 +++++++++++++++++++++----- var/lib/gsl/scripts/gsl__post_checkers | 8 +-- var/lib/gsl/scripts/gsl__post_makers | 45 +++++++------- var/lib/gsl/scripts/gsl__post_manager | 32 +++++----- var/lib/gsl/scripts/gsl__tools | 1 + 7 files changed, 138 insertions(+), 56 deletions(-) diff --git a/usr/local/bin/gsl b/usr/local/bin/gsl index 9d812d1..45eccc5 100755 --- a/usr/local/bin/gsl +++ b/usr/local/bin/gsl @@ -161,6 +161,16 @@ case "$1" in make|-M) gsl__check_nbr_posts + case "$2" in + -F) + gsl_force_make=true + [[ "$3" ]] && gsl__check_opt_post "$3" + ;; + *) + [[ "$2" ]] && gsl__check_opt_post "$2" + ;; + esac + gsl__logs_print \ "$gsl_log_i" \ "Starting" \ diff --git a/var/lib/gsl/scripts/gsl__db_manager b/var/lib/gsl/scripts/gsl__db_manager index e9f0fab..f303a33 100644 --- a/var/lib/gsl/scripts/gsl__db_manager +++ b/var/lib/gsl/scripts/gsl__db_manager @@ -46,7 +46,7 @@ case "$gsl_process" in Checked) case "$gsl_db_post_status" in Checked) - gsl__db_compare_post_hash || return + gsl__db_compare_post_hash || return # Do Nothing if same Hash gsl__db_create_post ;; Made) @@ -67,6 +67,18 @@ esac # Create DB File from Data Post #====================================================================== gsl__db_create_post() { +if [[ "$gsl_checker_err" ]];then + [[ -f "$gsl_file_db_post" ]] \ + && rm -f "$gsl_file_db_post" \ + && gsl__logs_print \ + "$gsl_log_w" \ + "DB" \ + "Delete" \ + "file ; error in $gsl_post" \ + "$gsl_file_db_post" + return +fi + touch "$gsl_file_db_post" # Main Print diff --git a/var/lib/gsl/scripts/gsl__page_creator b/var/lib/gsl/scripts/gsl__page_creator index bb65507..b575710 100644 --- a/var/lib/gsl/scripts/gsl__page_creator +++ b/var/lib/gsl/scripts/gsl__page_creator @@ -4,15 +4,15 @@ # By echolib # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 -#----------------------------------------------------------------------- +#---------------------------------------------------------------------- # -------------------------------------------------- # From: gsl__all_makers | Create HTML Page # -------------------------------------------------- -#----------------------------------------------------------------------- +#---------------------------------------------------------------------- -#----------------------------------------------------------------------- +#---------------------------------------------------------------------- # MAIN -#----------------------------------------------------------------------- +#---------------------------------------------------------------------- gsl__page_creator() { #gsl__page_prepare_datas gsl__check_templates @@ -21,9 +21,9 @@ gsl__page_create cat -n "$gsl_srv_wip_page" } -#----------------------------------------------------------------------- +#---------------------------------------------------------------------- # Get Datas for Post/Page -#----------------------------------------------------------------------- +#---------------------------------------------------------------------- gsl__page_prepare_datas() { echo "D> $gsl_this_conf_domain" @@ -54,20 +54,62 @@ esac gsl_uri_site_logo="$gsl_uri/templates/$gsl_site_logo" } -#----------------------------------------------------------------------- +#---------------------------------------------------------------------- # Check if Post / Pages exists in server -#----------------------------------------------------------------------- +#---------------------------------------------------------------------- gsl__check_srv_files() { if [[ -f "$1" ]];then echo "! Replaced Page: $1" fi } -#----------------------------------------------------------------------- -# Create Final HTML Post/Page -#----------------------------------------------------------------------- -gsl__page_create() { +#====================================================================== +# Create Post Listing +#====================================================================== +gsl__page_create_listing() { +# Check if Post is in list ; Status Made +[[ "$gsl_db_post_status" == "Made" ]] \ + && gsl__logs_print \ + "$gsl_log_i" \ + "Post" \ + "Make" \ + "$gsl_post already added to Latest listings" \ + "$gsl_file_db_posts" \ + && return + +touch "$gsl_dir_domain_tpl/last-posts-list.html" + +gsl_max_posts_list=5 +gsl_cur_posts_list=`cat "$gsl_dir_domain_tpl/last-posts-list.html" | wc -l` +if (( $((gsl_cur_posts_list )) >= 25 ));then + echo "D> $gsl_cur_posts_list * $gsl_max_posts_list" + for i in `seq 1 5`; + do + sed -i "1d" "$gsl_dir_domain_tpl/last-posts-list.html" + done +fi + +cat << EOPostSide >> "$gsl_dir_domain_tpl/last-posts-list.html" +
  • + $gsl_header_title +
  • +EOPostSide + +gsl__logs_print \ + "$gsl_log_i" \ + "Post" \ + "Make" \ + "$gsl_post added to Latest listings" \ + "$gsl_file_db_posts" +} + +#---------------------------------------------------------------------- +# Create Final HTML Post/Page +#---------------------------------------------------------------------- +gsl__page_create() { cat << EOPAGE > "$gsl_srv_wip_page" @@ -81,14 +123,24 @@ cat << EOPAGE > "$gsl_srv_wip_page"
    +

    Écrit par $gsl_header_author le $gsl_header_date

    + `cat "$gsl_a11y_post"` -
    + + +
    `cat "$gsl_dir_domain_tpl/footer.html"` @@ -101,9 +153,9 @@ EOPAGE rm -f "$gsl_html_meta" } -#----------------------------------------------------------------------- +#---------------------------------------------------------------------- # Create META head for Post/Page -#----------------------------------------------------------------------- +#---------------------------------------------------------------------- gsl__html_meta_head() { # Create file with metas to be included in Post/Page gsl_html_meta=`mktemp` diff --git a/var/lib/gsl/scripts/gsl__post_checkers b/var/lib/gsl/scripts/gsl__post_checkers index 827e55a..bf69a96 100644 --- a/var/lib/gsl/scripts/gsl__post_checkers +++ b/var/lib/gsl/scripts/gsl__post_checkers @@ -378,7 +378,7 @@ fi # Exists in Content gsl_count_images=` -gsl__get_content_line "__image:$gsl_post_hf_1" "$gsl_post" | wc -l` +gsl__get_content_line "_image:$gsl_post_hf_1" "$gsl_post" | wc -l` if (( $gsl_count_images > 0 ));then @@ -390,7 +390,7 @@ else "$gsl_log_e" \ "Post" \ "$gsl_log_c_image" \ - "Missing: __image:$gsl_post_hf_1" \ + "Missing: _image:$gsl_post_hf_1" \ "${PWD}/$gsl_post" gsl_checker_err=true @@ -435,7 +435,7 @@ fi # Exists in Content gsl_count_fcodes=` -gsl__get_content_line "__code:$gsl_post_hf_1" "$gsl_post" | wc -l` +gsl__get_content_line "_code:$gsl_post_hf_1" "$gsl_post" | wc -l` if (( $gsl_count_fcodes > 0 ));then @@ -447,7 +447,7 @@ else "$gsl_log_e" \ "Post" \ "$gsl_log_c_code" \ - "Missing: __code:$gsl_post_hf_1" \ + "Missing: _code:$gsl_post_hf_1" \ "${PWD}/$gsl_post" gsl_checker_err=true diff --git a/var/lib/gsl/scripts/gsl__post_makers b/var/lib/gsl/scripts/gsl__post_makers index d10feab..ff20d68 100644 --- a/var/lib/gsl/scripts/gsl__post_makers +++ b/var/lib/gsl/scripts/gsl__post_makers @@ -18,6 +18,9 @@ unset gsl_check_done gsl__prepare_makers gsl__page_prepare_datas +# Create Listng Page +gsl__page_create_listing + gsl__do_italics "make" "$gsl_tmp_post" # First gsl__do_header "make" "$gsl_marker_link" "$gsl_post" gsl__do_header "make" "$gsl_marker_abbr" "$gsl_post" @@ -304,27 +307,27 @@ echo -ne "\r\033[2K: Converting Paragraphs..." while read -r "gsl_content_line_nbr" "gsl_content_line" do -case "$gsl_content_line" in - ")") - sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_c," \ - "$gsl_tmp_post" - ;; - "("|"( 1") - sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o1," \ - "$gsl_tmp_post" - ;; - "( 2") - sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o2," \ - "$gsl_tmp_post" - ;; - "( 3") - sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o3," \ - "$gsl_tmp_post" - ;; - *) - continue - ;; -esac + case "$gsl_content_line" in + ")") + sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_c," \ + "$gsl_tmp_post" + ;; + "("|"( 1") + sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o1," \ + "$gsl_tmp_post" + ;; + "( 2") + sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o2," \ + "$gsl_tmp_post" + ;; + "( 3") + sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o3," \ + "$gsl_tmp_post" + ;; + *) + continue + ;; + esac done < <(cat -n "$gsl_tmp_post") } diff --git a/var/lib/gsl/scripts/gsl__post_manager b/var/lib/gsl/scripts/gsl__post_manager index 44dfa08..597970c 100644 --- a/var/lib/gsl/scripts/gsl__post_manager +++ b/var/lib/gsl/scripts/gsl__post_manager @@ -24,9 +24,9 @@ do if [[ "$gsl_this_post" ]];then ! [[ "$gsl_post" == "$gsl_this_post" ]] && continue fi - + gsl__get_sum "$gsl_post" - + # Post too small if (( "$gsl_post_size" <= $gsl_post_min_size ));then gsl__logs_print \ @@ -37,7 +37,7 @@ do "${PWD}/$gsl_post" continue fi - + # Set DB Post file gsl_file_db_post="$gsl_dir_db/$gsl_post.db" gsl__db_get_post_datas @@ -58,24 +58,28 @@ do gsl_process="Checked" gsl__all_checkers ;; - + make) gsl_process="Made" gsl__db_compare_post_hash && continue - + case "$gsl_db_post_status" in Checked) gsl__all_makers ;; - + Made) - gsl__logs_print - "$gsl_log_w" \ - "Post" \ - "Make" \ - "$gsl_post already Converted" \ - "$gsl_file_db_posts" - continue + if [[ "$gsl_force_make" ]];then + gsl__all_makers + else + gsl__logs_print \ + "$gsl_log_w" \ + "Post" \ + "Make" \ + "$gsl_post already Converted" \ + "$gsl_file_db_posts" + continue + fi ;; esac ;; @@ -88,7 +92,7 @@ done [[ "$gsl_checker_err" ]] \ && gsl log -s -e - + [[ "$gsl_check_done" ]] \ && echo "# Check already done" } diff --git a/var/lib/gsl/scripts/gsl__tools b/var/lib/gsl/scripts/gsl__tools index fde3ff4..4885f32 100644 --- a/var/lib/gsl/scripts/gsl__tools +++ b/var/lib/gsl/scripts/gsl__tools @@ -89,6 +89,7 @@ gsl_this_conf_domain=`grep "$1" "$gsl_file_db_domains"` gsl_dir_domain_tpl="$gsl_this_conf_domain/templates" gsl_dir_domain_files="$gsl_this_conf_domain/files" gsl_dir_domain_images="$gsl_this_conf_domain/images" +gsl_dir_domain_listings="$gsl_this_conf_domain/X-tra" for gsl_new_dir in `set -o posix ; set \ | grep "gsl_dir_domain" \