From 332f1feb17f96b11765521e19a279e3c7fe3dcc1 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Thu, 17 Feb 2022 11:03:25 +0100 Subject: [PATCH] Add TYPE page/post ; In DB if no post error --- README.md | 16 ++++++++++ etc/gsl/gsl.conf | 6 ++-- usr/share/bash-completion/completions/gsl | 2 +- var/lib/gsl/README.md | 16 ++++++++++ var/lib/gsl/helps/gsl_help_write_post | 16 ++++++++++ var/lib/gsl/scripts/gsl__db_manager | 2 +- var/lib/gsl/scripts/gsl__post_checkers | 37 ++++++++++++++++++++--- var/lib/gsl/scripts/gsl__post_manager | 5 +-- var/lib/gsl/scripts/gsl__tools | 3 +- 9 files changed, 87 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 7b1c799..71e6c81 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,22 @@ date: YYYY-MM-DD tags: TAG1,OTHER TAG2,TAG3 (comma separated) ``` +### Admin Header +Admin can define specific type of content. If no type defined, GSL will +add at first line the default value: "type: post". + +TYPE: +- post < classic content +- page < used to define main index, 404, about... + +``` +type: TYPE +``` + +GSL will create html file according to slug. Do not add .html to slug. +- post < /slug/index.html +- page < /slug.html + ## Optional HEADERS (before #1) Register METAs for CONTENT. " : " field separator diff --git a/etc/gsl/gsl.conf b/etc/gsl/gsl.conf index f6ed815..049ed11 100644 --- a/etc/gsl/gsl.conf +++ b/etc/gsl/gsl.conf @@ -39,9 +39,6 @@ gsl_filename_auth="authors.db" #======================================================================= # GSL Internal Configuration #======================================================================= -# Reserved 10 posts ID (Home, about...) -gsl_post_min_ID=10 - # minimum size to check a post gsl_post_min_size=800 @@ -157,7 +154,8 @@ gsl_u_markers=( #----------------------------------------------------------------------- # Set HEADERS markers #----------------------------------------------------------------------- -gsl_marker_ID='ID: ' +# type: page / post +gsl_marker_type='type: ' gsl_marker_title='title: ' gsl_marker_slug='slug: ' gsl_marker_info='info: ' diff --git a/usr/share/bash-completion/completions/gsl b/usr/share/bash-completion/completions/gsl index c858307..974cc3e 100644 --- a/usr/share/bash-completion/completions/gsl +++ b/usr/share/bash-completion/completions/gsl @@ -9,4 +9,4 @@ _gsl_completions() return 0 } -complete -F _gsl_completions gsl +complete -F _gsl_completions 'gsl' diff --git a/var/lib/gsl/README.md b/var/lib/gsl/README.md index 7b1c799..71e6c81 100644 --- a/var/lib/gsl/README.md +++ b/var/lib/gsl/README.md @@ -112,6 +112,22 @@ date: YYYY-MM-DD tags: TAG1,OTHER TAG2,TAG3 (comma separated) ``` +### Admin Header +Admin can define specific type of content. If no type defined, GSL will +add at first line the default value: "type: post". + +TYPE: +- post < classic content +- page < used to define main index, 404, about... + +``` +type: TYPE +``` + +GSL will create html file according to slug. Do not add .html to slug. +- post < /slug/index.html +- page < /slug.html + ## Optional HEADERS (before #1) Register METAs for CONTENT. " : " field separator diff --git a/var/lib/gsl/helps/gsl_help_write_post b/var/lib/gsl/helps/gsl_help_write_post index 7fdb23d..2f3dd8f 100644 --- a/var/lib/gsl/helps/gsl_help_write_post +++ b/var/lib/gsl/helps/gsl_help_write_post @@ -17,6 +17,22 @@ date: YYYY-MM-DD tags: TAG1,OTHER TAG2,TAG3 (comma separated) ``` +### Admin Header +Admin can define specific type of content. If no type defined, GSL will +add at first line the default value: "type: post". + +TYPE: +- post < classic content +- page < used to define main index, 404, about... + +``` +type: TYPE +``` + +GSL will create html file according to slug. Do not add .html to slug. +- post < /slug/index.html +- page < /slug.html + ## Optional HEADERS (before #1) Register METAs for CONTENT. " : " field separator diff --git a/var/lib/gsl/scripts/gsl__db_manager b/var/lib/gsl/scripts/gsl__db_manager index ae149da..c3f9772 100644 --- a/var/lib/gsl/scripts/gsl__db_manager +++ b/var/lib/gsl/scripts/gsl__db_manager @@ -31,7 +31,7 @@ case "$gsl_process" in Checked) gsl_db_line=` printf '%s%s%s%s%s\n' \ - "$gsl_post_ID 1|" \ + "$gsl_post_type|" \ "$gsl_post|" \ "$gsl_post_hash|" \ "$gsl_post_size|" \ diff --git a/var/lib/gsl/scripts/gsl__post_checkers b/var/lib/gsl/scripts/gsl__post_checkers index 10a6087..8408717 100644 --- a/var/lib/gsl/scripts/gsl__post_checkers +++ b/var/lib/gsl/scripts/gsl__post_checkers @@ -10,11 +10,14 @@ gsl__post_all_checkers() { clear unset gsl_check_done - -echo -ne "\r\033[2K: Searching for #1..." +gsl_process="Checked" + +echo -ne "Searching for #1..." gsl__post_check_h1 || return -echo -n ": Searching for NEEDED HEADERS..." +echo -n "\r\033[2K: : Searching for NEEDED HEADERS..." gsl__post_check_needed_headers +echo -n "\r\033[2K: : Searching for Post TYPE..." +gsl__post_check_type echo -ne "\r\033[2K: Searching for PARAGRAPHS" gsl__post_check_paragraphs echo -ne "\r\033[2K: Searching for Content MARKERS..." @@ -39,7 +42,10 @@ echo -ne "\r\033[2K" && gsl log -s -w [[ "$gsl_checker_err" ]] \ - && gsl log -s -e + && gsl log -s -e \ + && return + +gsl__db_line_post } #======================================================================= @@ -165,6 +171,29 @@ if ! [[ "$gsl_post_begin" ]];then fi } +#======================================================================= +# Check/Set for Post ID +#======================================================================= +gsl__post_check_type() { +if [[ `awk -v m="$gsl_marker_type" -v l="$gsl_post_begin" \ + 'NR < l && $0 ~ m' \ + "$gsl_post"` ]];then + + gsl_post_type=`gsl__get_header "$gsl_marker_type" "$gsl_post"` + # No ID found + case "$gsl_post_type" in + page|post) true ;; + *) + sed -i "s|$gsl_marker_type.*|${gsl_marker_type}post|" \ + "$gsl_post" + ;; + esac +else + sed -i "1i${gsl_marker_type}post" \ + "$gsl_post" +fi +} + #======================================================================= # Check for paragraphs ( and ) #======================================================================= diff --git a/var/lib/gsl/scripts/gsl__post_manager b/var/lib/gsl/scripts/gsl__post_manager index cc66fa1..22fa8ef 100644 --- a/var/lib/gsl/scripts/gsl__post_manager +++ b/var/lib/gsl/scripts/gsl__post_manager @@ -58,11 +58,8 @@ do "Post" \ "$gsl_post" \ "${PWD}" - gsl__post_all_checkers - - # No error: Check/Write to DB (posts.db) gsl_process="Checked" - gsl__db_line_post + gsl__post_all_checkers ;; make) diff --git a/var/lib/gsl/scripts/gsl__tools b/var/lib/gsl/scripts/gsl__tools index d52653d..cb4fabe 100644 --- a/var/lib/gsl/scripts/gsl__tools +++ b/var/lib/gsl/scripts/gsl__tools @@ -46,8 +46,7 @@ for gsl_file in "$gsl_file_logs" \ "$gsl_file_db_stats" \ "$gsl_file_db_domains" do - gsl__check_file "$gsl_file" || \ - touch "$gsl_file" + gsl__check_file "$gsl_file" && touch "$gsl_file" done }