From bf6197619926737d8e9b96fd40d314374865f18e Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Thu, 14 Apr 2022 14:14:42 +0200 Subject: [PATCH] =?UTF-8?q?Add=20ordered=20list=20with=20=C3=B8=20+=20read?= =?UTF-8?q?me?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++- control | 2 +- etc/gsl/gsl.conf | 1 + usr/local/bin/gsl | 43 +++++++++++++++++++++++---- var/lib/gsl/README.md | 4 ++- var/lib/gsl/scripts/gsl__db_manager | 18 ++++++----- var/lib/gsl/scripts/gsl__post_makers | 37 +++++++++++++++++------ var/lib/gsl/scripts/gsl__post_manager | 38 +++++++++++++++++++++-- 8 files changed, 119 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 6ba1006..3c9bc0a 100644 --- a/README.md +++ b/README.md @@ -387,7 +387,9 @@ _book: Esperanza 64 ### Créer des listes -Dans l'article, utilisez ```=``` pour définir l'arborescence). +Dans l'article... +- utilisez ```=``` pour définir l'arborescence d'une liste simple +- utilisez ```ø``` pour définir une liste ordonnée (alt+gr + o (FR azerty)) L'arborescence est "infinie". Chaque contenu de la liste *doit être sur la même ligne* ``` diff --git a/control b/control index 9ba7b33..0993d77 100644 --- a/control +++ b/control @@ -1,5 +1,5 @@ Package: egsl -Version: 0.0.20 +Version: 0.0.21 Section: custom Priority: optional Architecture: all diff --git a/etc/gsl/gsl.conf b/etc/gsl/gsl.conf index 12fb39e..062822e 100644 --- a/etc/gsl/gsl.conf +++ b/etc/gsl/gsl.conf @@ -101,6 +101,7 @@ gsl_mark_strong='\*\*' gsl_mark_italic='\/' gsl_mark_code="¤" gsl_mark_list='=' +gsl_mark_listo="ø" gsl_mark_blockquote='---' diff --git a/usr/local/bin/gsl b/usr/local/bin/gsl index bd5a6e6..49b93da 100755 --- a/usr/local/bin/gsl +++ b/usr/local/bin/gsl @@ -1,5 +1,5 @@ #!/bin/bash -# Version: 0.0.20 +# Version: 0.0.21 # file: gsl # Folder: /usr/local/bin # By echolib @@ -269,7 +269,6 @@ case "$1" in ;; check|-C) - gsl__check_nbr_posts case "$2" in -F) gsl_force_check=true @@ -339,7 +338,6 @@ case "$1" in ;; make|-M) - gsl__check_nbr_posts gsl_process="wip" gsl_post_list="Add" case "$2" in @@ -409,6 +407,40 @@ case "$1" in "$gsl_dir_domain_tpl/last-posts-list.html" ;; + list|-l) + ! [[ "$2" ]] \ + && echo "! Missing argument: OPT=add|-A/remove|-R" \ + && exit + + ! [[ "$3" ]] \ + && echo "! Missing argument: post [FILE]" \ + && exit + + gsl__if_file "$3" post + + case "$2" in + add|-A) gsl_listing_process="add" ;; + remove|-R) gsl_listing_process="remove" ;; + *) echo "! Bad argument: $2 ? OPT=add|-A/remove|-R";exit ;; + esac + + gsl__logs_print \ + "$gsl_log_i" \ + "Starting" \ + "Process" \ + "$1 ; $2 ; $3 from domain $gsl_find_domain" \ + "$gsl_dir_domain_tpl/last-posts-list.html" + + gsl__loop_posts listing + + gsl__logs_print \ + "$gsl_log_i" \ + "Stopping" \ + "Process" \ + "$1 ; $2 ; $3 from domain $gsl_find_domain" \ + "$gsl_dir_domain_tpl/last-posts-list.html" + ;; + www) ! [[ "$2" ]] \ && echo "! Missing argument: OPT=add/remove" \ @@ -450,8 +482,7 @@ case "$1" in gsl__if_file "$3" post ;; esac - - gsl__check_nbr_posts + gsl__logs_print \ "$gsl_log_i" \ "Starting" \ @@ -462,7 +493,7 @@ case "$1" in gsl_srv_www="$gsl_site_server/$gsl_site_ndd/www" gsl__srv_sync "$gsl_srv_www" gsl__loop_posts www "$2" - + gsl__logs_print \ "$gsl_log_i" \ "Stopping" \ diff --git a/var/lib/gsl/README.md b/var/lib/gsl/README.md index 6ba1006..3c9bc0a 100644 --- a/var/lib/gsl/README.md +++ b/var/lib/gsl/README.md @@ -387,7 +387,9 @@ _book: Esperanza 64 ### Créer des listes -Dans l'article, utilisez ```=``` pour définir l'arborescence). +Dans l'article... +- utilisez ```=``` pour définir l'arborescence d'une liste simple +- utilisez ```ø``` pour définir une liste ordonnée (alt+gr + o (FR azerty)) L'arborescence est "infinie". Chaque contenu de la liste *doit être sur la même ligne* ``` diff --git a/var/lib/gsl/scripts/gsl__db_manager b/var/lib/gsl/scripts/gsl__db_manager index d26ac41..3acdc19 100644 --- a/var/lib/gsl/scripts/gsl__db_manager +++ b/var/lib/gsl/scripts/gsl__db_manager @@ -50,10 +50,10 @@ gsl_checker_war=true if (( $gsl_post_hash == $gsl_db_post_hash ));then gsl__logs_print \ - "$gsl_log_w" \ + "$gsl_log_i" \ "Post" \ "Hash" \ - "$gsl_post checked with hash:$gsl_db_post_hash " \ + "$gsl_post checked with hash:$gsl_db_post_hash" \ "${PWD}/$gsl_post" else @@ -67,14 +67,16 @@ else "New" \ "$gsl_post not yet checked" \ "${PWD}/$gsl_post" + gsl_checker_war=true ;; *) - gsl__logs_print \ - "$gsl_log_w" \ - "Post" \ - "Hash" \ - "$gsl_post Changed ($gsl_post_hash)" \ - "${PWD}/$gsl_post" + gsl__logs_print \ + "$gsl_log_w" \ + "Post" \ + "Hash" \ + "$gsl_post Changed ($gsl_post_hash) !" \ + "${PWD}/$gsl_post" + gsl_checker_war=true ;; esac diff --git a/var/lib/gsl/scripts/gsl__post_makers b/var/lib/gsl/scripts/gsl__post_makers index 89a16e9..cb32eba 100644 --- a/var/lib/gsl/scripts/gsl__post_makers +++ b/var/lib/gsl/scripts/gsl__post_makers @@ -100,18 +100,32 @@ awk -v s="$1" \ # Convert List.Get first/last line item / repeat till no more mark #====================================================================== gsl__make_list() { -! [[ `awk -v m="$gsl_mark_list" \ - '$1 == m {print $1;exit}' \ - "$gsl_tmp_post"` ]] \ - && return +unset gsl_found_list +if [[ `awk -v m="$gsl_mark_list" \ + '$1 == m {print $1;exit}' \ + "$gsl_tmp_post"` ]];then + gsl_found_list=true +fi -gsl_last_line=`cat $gsl_tmp_post | wc -l` +if [[ `awk -v m="$gsl_mark_listo" \ + '$1 == m {print $1;exit}' \ + "$gsl_tmp_post"` ]];then + gsl_found_list=true +fi +if [[ $gsl_found_list ]];then + gsl__make_list_read + gsl__make_list +fi +} + +gsl__make_list_read() { # Get block lists by line numbers From Content +gsl_last_line=`cat $gsl_tmp_post | wc -l` while read -r "gsl_line" "gsl_content" do case "$gsl_content" in - "$gsl_mark_list"*) + "$gsl_mark_list"*|"$gsl_mark_listo"*) ! [[ $gsl_list ]] \ && gsl_list=true \ && gsl_list_o=$gsl_line \ @@ -121,6 +135,11 @@ do && gsl_list_c=$gsl_line \ && gsl__make_list_get_block \ && break + + case "$gsl_content" in + "$gsl_mark_list"*) gsl_html_uol="ul" ;; + "$gsl_mark_listo"*) gsl_html_uol="ol" ;; + esac ;; ""|*) @@ -189,14 +208,14 @@ do elif (( $gsl_diff_pm_mn > 0 ));then printf "%s%s\n" \ "" \ - "%.s\n' {1..eval $n} \ + printf "%.s\n" {1..eval $n} \ >> "$gsl_HTML_list" printf "%s%s\n" \ "" \ @@ -205,7 +224,7 @@ do fi done < <(cat -n "$gsl_file_block_list") -echo "" >> "$gsl_HTML_list" +echo "" >> "$gsl_HTML_list" # Remove useless list in tmp_post gsl_list_rm_tl=$(( $gsl_list_c - $gsl_list_o )) diff --git a/var/lib/gsl/scripts/gsl__post_manager b/var/lib/gsl/scripts/gsl__post_manager index c7e3d32..9cd00bf 100644 --- a/var/lib/gsl/scripts/gsl__post_manager +++ b/var/lib/gsl/scripts/gsl__post_manager @@ -10,6 +10,16 @@ # ----------------------------------------------------------- #----------------------------------------------------------------------- gsl__loop_posts() { +gsl__check_nbr_posts +(( $gsl_nbr_posts == 0 )) \ + && gsl__logs_print \ + "$gsl_log_i" \ + "Posts" \ + "Not found" \ + "$gsl_nbr_posts post. Nothing to do in" \ + "${PWD}" \ + && return + gsl__logs_print \ "$gsl_log_i" \ "Posts" \ @@ -57,8 +67,9 @@ do "$gsl_log_w" \ "wip" \ "Delete" \ - "$gsl_post_type ; $gsl_post has changed" \ + "$gsl_post_type ; $gsl_post has changed !" \ "$gsl_srv_wip_page" + gsl_checker_war=true fi if [[ -f "$gsl_file_db_post" ]];then @@ -67,8 +78,9 @@ do "$gsl_log_w" \ "DB" \ "Delete" \ - "file ; $gsl_post has changed" \ + "file ; $gsl_post has changed !" \ "$gsl_file_db_post" + gsl_checker_war=true fi fi @@ -116,6 +128,28 @@ do esac ;; + listing) + # Continue if post changed + [[ "$gsl_post_new_hash" ]] \ + && gsl__logs_print \ + "$gsl_log_e" \ + "Listing" \ + "$gsl_listing_process" \ + "file ; $gsl_post has changed !" \ + "$gsl_file_db_post" \ + && continue + + case "$gsl_listing_process" in + add) + echo "> Add $gsl_this_post to listing" + ;; + + rem) + echo "> Remove $gsl_this_post to listing" + ;; + esac + ;; + post-list) case "$gsl_db_post_status" in wip|www)