diff --git a/README.md b/README.md index 5d4db1e..86a56c7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # GSL: Statique Littérateur +=== GSL is a multiple blogs/websites generator based on their domain, written in bash, for minimal dependancies. The websites are nearly all @@ -6,12 +7,14 @@ static, except for some includes that nginx can easily get, in your webserver. # Dependancies +=== - bash - coreutils - curl (to check Posts links response) # GSL: Installation +=== To avoid sudo, you should give permissions to USER @@ -42,6 +45,8 @@ To avoid sudo, you should give permissions to USER # How to configure a DOMAIN folder, and create a Post +=== + ## Set a DOMAIN - add a DOMAIN name (if not alrady done) ``` @@ -74,6 +79,101 @@ files and folders. You could install lightweight darkhttpd webserver on your PC to preview the website # Create a Templates +=== You will have to create some CSS in your /DOMAIN/templates/ - HOME: ~/.config/gsl/domains/DOMAIN/templates/ - GLOBAL: /var/lib/gsl/domains/DOMAIN/templates/ + +# How to Write a Post +=== +Post has 2 sections : Vefore and after #1. #1 is the FIRST Title of your +post. #(1-6) are HTML titles (

to

). +- Before #1 is used to set METAs HEADERS to configure your Post. +- After #1 is the CONTENT of your Post + +## NEEDED HEADERS (before #1) +Register METAs for HTML Page content + +``` +title: POST TITLE +slug: POST-TITLE (if space in slug GSL will convert them) +info: DESCRIPTION (about the Post) +author: NAME (must be registred with $ gsl author add) +date: YYYY-MM-DD +tags: TAG1,OTHER TAG2,TAG3 (comma separated) +``` + +## Optional HEADERS (before #1) +Register METAs for CONTENT. " : " field separator + +``` +abbr: SHORT : LONG +file: NAME : FILENAME : ALT-TEXT +link: NAME : URL : ALT-TEXT +code: NBR : FILENAME +image: NBR : FILENAME : ALT-TEXT +``` + +## CONTENT Post: +In Content Post, markers (i.e. [_,_],*_,_*...) must be on the SAME line. +For ABBRs, just write SHORT in your content + +``` +# Paragraphs +At begining of new line, open with ( and close with ) +( +This is a paragraph +) + +# Register in Header. link: My Great link : URL : ALT-TEXT +[_My Great Link_] + +# Write in ITALIC +/_this em text_/ + +# Write in STRONG +**_this strong content_** + +# BOLD +*_this bold content_* + +# Register in Header. file: My Great file : FILENAME : ALT-TEXT +<_My Great file_> + +# Inline-code (¤ = alt-gr + $ on FR keyboard) +¤_push()_¤ + +# Lists +=> list 1 +==> sublist 1 +===> sub-sublist 1 +=> list 2 + +# Simple Blockquote +--- +( +A simple great quote +) +--- + +# Advanced Blockquote +--- +_cite : Richard Matthew Stallman +_link : https://stallman.org/ +_lang : en +( +In the free/libre software movement, we develop software that respects +users' freedom, so we and you can escape from software that doesn't. I +could have made money this way, and perhaps amused myself writing code. +But I knew that at the end of my career, I would look back on years of +building walls to divide people, and feel I had spent my life making the +world a worse place +) +--- + +# Register in Header. image: 1 : FILENAME : ALT-TEXT +_image_ : 1 + +# Block-Code File: Register in Header. code: 1 : FILENAME +_code_ : 1 +``` diff --git a/etc/gsl/gsl.conf b/etc/gsl/gsl.conf index 99b7136..f6ed815 100644 --- a/etc/gsl/gsl.conf +++ b/etc/gsl/gsl.conf @@ -57,7 +57,9 @@ gsl_admin_sep_post='===============' # Date format gsl_test_date='^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]+$' -# Logs +#----------------------------------------------------------------------- +# Set LOG help Activity for NEEDED HEADERS +#----------------------------------------------------------------------- gsl_log_act_title='POST TITLE' gsl_log_act_author='REGISTRED NAME' gsl_log_act_date='YYYY-MM-DD' @@ -71,7 +73,16 @@ gsl_log_act_link='NAME : URL : ALT TEXT' gsl_log_act_file='NAME : FILENAME : ALT TEXT' #----------------------------------------------------------------------- -# Set CONTENT POTST markers +# Set LOG for CONTENT Process +#----------------------------------------------------------------------- +gsl_log_c_link="Content link" +gsl_log_c_abbr="Content abbr" +gsl_log_c_code="Content code" +gsl_log_c_image="Content image" +gsl_log_c_file="Content file" + +#----------------------------------------------------------------------- +# Set CONTENT POST markers #----------------------------------------------------------------------- gsl_mo_p='(' gsl_mo_link='\[_' @@ -104,6 +115,9 @@ gsl_mark_blockquote_link='_link :' gsl_mark_blockquote_book='_book :' gsl_mark_blockquote_lang='_lang :' +#----------------------------------------------------------------------- +# Set for Stats +#----------------------------------------------------------------------- gsl_o_markers=( $gsl_mo_link $gsl_mo_em @@ -123,12 +137,12 @@ $gsl_mc_file ) gsl_i_markers=( -Link -Italic -Strong -Bold -Code -File +"Content link" +"Content italic" +"Content strong" +"Content bold" +"Content code" +"Content file" ) gsl_u_markers=( @@ -143,16 +157,17 @@ gsl_u_markers=( #----------------------------------------------------------------------- # Set HEADERS markers #----------------------------------------------------------------------- -gsl_marker_ID=';; ID: ' -gsl_marker_title=';; title: ' -gsl_marker_slug=';; slug: ' -gsl_marker_info=';; info: ' -gsl_marker_author=';; author: ' -gsl_marker_date=';; date: ' +gsl_marker_ID='ID: ' +gsl_marker_title='title: ' +gsl_marker_slug='slug: ' +gsl_marker_info='info: ' +gsl_marker_author='author: ' +gsl_marker_date='date: ' +gsl_marker_tags='tags: ' #Optional (include brut text) -gsl_marker_code=';; code: ' -gsl_marker_image=';; image: ' -gsl_marker_abbr=';; abbr: ' -gsl_marker_link=';; link: ' -gsl_marker_file=';; file: ' +gsl_marker_code='code: ' +gsl_marker_image='image: ' +gsl_marker_abbr='abbr: ' +gsl_marker_link='link: ' +gsl_marker_file='file: ' diff --git a/usr/local/bin/gsl b/usr/local/bin/gsl index 6795cc4..59d7018 100755 --- a/usr/local/bin/gsl +++ b/usr/local/bin/gsl @@ -23,10 +23,9 @@ gsl__create_ff #======================================================================= case "$1" in author|-A) - gsl__find_domain && exit 1 + gsl__find_domain gsl__check_source "$gsl_dir_scripts/gsl__auth_manager" || exit 1 - - echo "# Domain: $gsl_find_domain" + case "$2" in "") gsl__authors_list @@ -86,7 +85,10 @@ case "$1" in "New Website" \ "$gsl_dir_scripts/gsl__new_website" - gsl author add + [[ -f "$gsl_file_db_domains" ]] && \ + [[ -d "$gsl_dir_user_posts" ]] \ + && cd "$gsl_dir_user_posts" \ + && gsl author add ;; log|-L) @@ -121,14 +123,14 @@ case "$1" in ;; check|-C) - gsl__find_domain || exit 1 + gsl__find_domain # || exit 1 gsl__check_source "$gsl_dir_scripts/gsl__auth_manager" || exit 1 gsl__authors_list check || exit 1 gsl__check_source "$gsl_dir_scripts/gsl__post_manager" || exit 1 gsl__check_source "$gsl_dir_scripts/gsl__post_checkers" || exit 1 - gsl__check_nbr_posts || exit 1 + gsl__check_nbr_posts gsl__check_source "$gsl_dir_scripts/gsl__db_manager" || exit 1 - + case "$2" in -F) gsl_force_check=true esac @@ -182,6 +184,10 @@ case "$1" in gsl__check_file "$gsl_dir_helps/gsl_help_install" || exit 1 cat "$gsl_dir_helps/gsl_help_install" ;; + write|-w) + gsl__check_file "$gsl_dir_helps/gsl_help_write_post" || exit 1 + cat "$gsl_dir_helps/gsl_help_write_post" + ;; esac ;; esac diff --git a/var/lib/gsl/README.md b/var/lib/gsl/README.md index 5d4db1e..86a56c7 100644 --- a/var/lib/gsl/README.md +++ b/var/lib/gsl/README.md @@ -1,4 +1,5 @@ # GSL: Statique Littérateur +=== GSL is a multiple blogs/websites generator based on their domain, written in bash, for minimal dependancies. The websites are nearly all @@ -6,12 +7,14 @@ static, except for some includes that nginx can easily get, in your webserver. # Dependancies +=== - bash - coreutils - curl (to check Posts links response) # GSL: Installation +=== To avoid sudo, you should give permissions to USER @@ -42,6 +45,8 @@ To avoid sudo, you should give permissions to USER # How to configure a DOMAIN folder, and create a Post +=== + ## Set a DOMAIN - add a DOMAIN name (if not alrady done) ``` @@ -74,6 +79,101 @@ files and folders. You could install lightweight darkhttpd webserver on your PC to preview the website # Create a Templates +=== You will have to create some CSS in your /DOMAIN/templates/ - HOME: ~/.config/gsl/domains/DOMAIN/templates/ - GLOBAL: /var/lib/gsl/domains/DOMAIN/templates/ + +# How to Write a Post +=== +Post has 2 sections : Vefore and after #1. #1 is the FIRST Title of your +post. #(1-6) are HTML titles (

to

). +- Before #1 is used to set METAs HEADERS to configure your Post. +- After #1 is the CONTENT of your Post + +## NEEDED HEADERS (before #1) +Register METAs for HTML Page content + +``` +title: POST TITLE +slug: POST-TITLE (if space in slug GSL will convert them) +info: DESCRIPTION (about the Post) +author: NAME (must be registred with $ gsl author add) +date: YYYY-MM-DD +tags: TAG1,OTHER TAG2,TAG3 (comma separated) +``` + +## Optional HEADERS (before #1) +Register METAs for CONTENT. " : " field separator + +``` +abbr: SHORT : LONG +file: NAME : FILENAME : ALT-TEXT +link: NAME : URL : ALT-TEXT +code: NBR : FILENAME +image: NBR : FILENAME : ALT-TEXT +``` + +## CONTENT Post: +In Content Post, markers (i.e. [_,_],*_,_*...) must be on the SAME line. +For ABBRs, just write SHORT in your content + +``` +# Paragraphs +At begining of new line, open with ( and close with ) +( +This is a paragraph +) + +# Register in Header. link: My Great link : URL : ALT-TEXT +[_My Great Link_] + +# Write in ITALIC +/_this em text_/ + +# Write in STRONG +**_this strong content_** + +# BOLD +*_this bold content_* + +# Register in Header. file: My Great file : FILENAME : ALT-TEXT +<_My Great file_> + +# Inline-code (¤ = alt-gr + $ on FR keyboard) +¤_push()_¤ + +# Lists +=> list 1 +==> sublist 1 +===> sub-sublist 1 +=> list 2 + +# Simple Blockquote +--- +( +A simple great quote +) +--- + +# Advanced Blockquote +--- +_cite : Richard Matthew Stallman +_link : https://stallman.org/ +_lang : en +( +In the free/libre software movement, we develop software that respects +users' freedom, so we and you can escape from software that doesn't. I +could have made money this way, and perhaps amused myself writing code. +But I knew that at the end of my career, I would look back on years of +building walls to divide people, and feel I had spent my life making the +world a worse place +) +--- + +# Register in Header. image: 1 : FILENAME : ALT-TEXT +_image_ : 1 + +# Block-Code File: Register in Header. code: 1 : FILENAME +_code_ : 1 +``` diff --git a/var/lib/gsl/helps/gsl_help b/var/lib/gsl/helps/gsl_help index ef02b35..c5378aa 100644 --- a/var/lib/gsl/helps/gsl_help +++ b/var/lib/gsl/helps/gsl_help @@ -4,6 +4,7 @@ $ gsl [ARG] readme : Show README.md instructions help | -h [OPT] : This Help. Add FULL [ARG] for specifics install : Show process installation + write | -w : How to write a Post new | -N : Add and configure a new DOMAIN diff --git a/var/lib/gsl/helps/gsl_help_write_post b/var/lib/gsl/helps/gsl_help_write_post new file mode 100644 index 0000000..7fdb23d --- /dev/null +++ b/var/lib/gsl/helps/gsl_help_write_post @@ -0,0 +1,93 @@ +# How to Write a Post + +Post has 2 sections : Vefore and after #1. #1 is the FIRST Title of your +post. #(1-6) are HTML titles (

to

). +- Before #1 is used to set METAs HEADERS to configure your Post. +- After #1 is the CONTENT of your Post + +## NEEDED HEADERS (before #1) +Register METAs for HTML Page content + +``` +title: POST TITLE +slug: POST-TITLE (if space in slug GSL will convert them) +info: DESCRIPTION (about the Post) +author: NAME (must be registred with $ gsl author add) +date: YYYY-MM-DD +tags: TAG1,OTHER TAG2,TAG3 (comma separated) +``` + +## Optional HEADERS (before #1) +Register METAs for CONTENT. " : " field separator + +``` +abbr: SHORT : LONG +file: NAME : FILENAME : ALT-TEXT +link: NAME : URL : ALT-TEXT +code: NBR : FILENAME +image: NBR : FILENAME : ALT-TEXT +``` + +## CONTENT Post: +In Content Post, markers (i.e. [_,_],*_,_*...) must be on the SAME line. +For ABBRs, just write SHORT in your content + +``` +# Paragraphs +At begining of new line, open with ( and close with ) +( +This is a paragraph +) + +# Register in Header. link: My Great link : URL : ALT-TEXT +[_My Great Link_] + +# Write in ITALIC +/_this em text_/ + +# Write in STRONG +**_this strong content_** + +# BOLD +*_this bold content_* + +# Register in Header. file: My Great file : FILENAME : ALT-TEXT +<_My Great file_> + +# Inline-code (¤ = alt-gr + $ on FR keyboard) +¤_push()_¤ + +# Lists +=> list 1 +==> sublist 1 +===> sub-sublist 1 +=> list 2 + +# Simple Blockquote +--- +( +A simple great quote +) +--- + +# Advanced Blockquote +--- +_cite : Richard Matthew Stallman +_link : https://stallman.org/ +_lang : en +( +In the free/libre software movement, we develop software that respects +users' freedom, so we and you can escape from software that doesn't. I +could have made money this way, and perhaps amused myself writing code. +But I knew that at the end of my career, I would look back on years of +building walls to divide people, and feel I had spent my life making the +world a worse place +) +--- + +# Register in Header. image: 1 : FILENAME : ALT-TEXT +_image_ : 1 + +# Block-Code File: Register in Header. code: 1 : FILENAME +_code_ : 1 +``` diff --git a/var/lib/gsl/scripts/gsl__auth_manager b/var/lib/gsl/scripts/gsl__auth_manager index 9d4fdbe..85a24ea 100644 --- a/var/lib/gsl/scripts/gsl__auth_manager +++ b/var/lib/gsl/scripts/gsl__auth_manager @@ -11,8 +11,12 @@ gsl__authors_check() { gsl_save_dir_ndd=`grep "$gsl_find_domain" "$gsl_file_db_domains"` gsl_file_auth_ndd="$gsl_save_dir_ndd/$gsl_filename_auth" -[[ -f "$gsl_file_auth_ndd" ]] \ - && return +if [[ -f "$gsl_file_auth_ndd" ]];then + [[ -z `grep '[^[:space:]]' "$gsl_file_auth_ndd"` ]] \ + && echo "# Domain: $gsl_find_domain" \ + && echo "! No Registred authors yet..." \ + && return 1 +fi touch "$gsl_file_auth_ndd" } @@ -21,19 +25,18 @@ touch "$gsl_file_auth_ndd" # List Authors from DOMAIN #======================================================================= gsl__authors_list() { -gsl__authors_check - -! [[ -z `grep '[^[:space:]]' "$gsl_file_auth_ndd"` ]] \ - && gsl_authors=true \ - && return - -echo "! No Registred authors yet..." case "$1" in check) - [[ $gsl_authors ]] && return + gsl__authors_check || return return ;; + add) + gsl__authors_check || return + ;; + remove) + gsl__authors_check || return + ;; esac echo -e "\n# Authors Registred:" @@ -47,8 +50,7 @@ done < <(cat -n "$gsl_file_auth_ndd") # Add Author(s) for DOMAIN to authors.db in Profile User #======================================================================= gsl__authors_add() { -gsl__authors_check -gsl__authors_list +gsl__authors_list add printf '\n%s\n%s\n%s\n \n' \ "# You can add one or more Authors" \ @@ -77,8 +79,7 @@ gsl__authors_list # Remove Author(s) for DOMAIN from authors.db in Profile User #======================================================================= gsl__authors_remove() { -gsl__authors_check -gsl__authors_list +gsl__authors_list remove || exit 1 printf '\n%s\n%s\n%s\n \n' \ "# You can REMOVE one or more Authors" \ diff --git a/var/lib/gsl/scripts/gsl__new_website b/var/lib/gsl/scripts/gsl__new_website index 4e20b7d..92c017d 100644 --- a/var/lib/gsl/scripts/gsl__new_website +++ b/var/lib/gsl/scripts/gsl__new_website @@ -23,34 +23,35 @@ printf '\n%s\n%s\n%s\n' \ #======================================================================= # Webserver URI #======================================================================= -echo -e "\n# Webserver: /var/www ! NO ending / (Or maybe elsewhere...)" +echo -e "\n# Webserver: /var/www (Or maybe elsewhere...)" read -erp \ ": Webserver URI ? " \ gsl_set_server -gsl__check_settings $gsl_set_server \ - && [[ "$gsl_process_stop" ]] \ - && return +[[ ${gsl_set_server: -1} == "/" ]] \ + && gsl_set_server=${gsl_set_server::-1} + +gsl__check_settings $gsl_set_server || return #======================================================================= # Domain URL #======================================================================= -printf '\n%s %s\n' \ - "# URL: www.example.com !NO ending /" \ +printf '\n%s\n %s\n' \ + "# URL: www.example.com" \ "(https:// will be added if missing or force with http://)" read -rp \ ": Website URL ? " \ gsl_set_url -gsl__check_settings $gsl_set_url \ - && [[ "$gsl_process_stop" ]] \ - && return +[[ ${gsl_set_url: -1} == "/" ]] \ + && gsl_set_url=${gsl_set_url::-1} + +gsl__check_settings $gsl_set_url || return gsl_https='https://' case "$gsl_set_url" in "https://"*) gsl_set_ndd=${gsl_set_url/$gsl_https/} - echo "D> Case: $gsl_set_ndd" ;; "http://"*) gsl_http="http://" @@ -67,13 +68,32 @@ esac gsl_set_ndd=`awk -F"." '{print $(NF-1)"."$NF}' <<< $gsl_set_ndd` gsl_set_file_ndd="$gsl_set_ndd.conf" +[[ -d "$gsl_dir_user_domains/$gsl_set_ndd" ]] \ + && gsl_profile="HOME: $gsl_dir_user_domains/$gsl_set_ndd" \ + && gsl_set_user_conf="Y" + +[[ -d "$gsl_dir_global_domains/$gsl_set_ndd" ]] \ + && gsl_profile="System: $gsl_dir_global_domains/$gsl_set_ndd" \ + && gsl_set_user_conf="N" + +if [[ "$gsl_profile" ]];then + echo "! A Profile exists in your $gsl_profile" + read -rp ": Continue (Y|*)" gsl_continue + case "$gsl_continue" in + Y|y) true ;; + *) gsl__check_settings $blank || return + esac +fi + #======================================================================= # Personal use or global use ? #======================================================================= -echo -e "\n# Save Domain in Home or Global" -read -rp \ - ": Home Use (y/n) ? " \ - gsl_set_user_conf +if ! [[ "$gsl_set_user_conf" ]];then + echo -e "\n# Save Domain in Home or Global" + read -rp \ + ": Home Use (y/n) ? " \ + gsl_set_user_conf +fi case "$gsl_set_user_conf" in y|Y) gsl_save_dir_ndd="$gsl_dir_user_domains/$gsl_set_ndd" @@ -96,9 +116,7 @@ read -rp \ ": Website Title ? " \ gsl_set_title -gsl__check_settings $gsl_set_title \ - && [[ "$gsl_process_stop" ]] \ - && return +gsl__check_settings $gsl_set_title || return #======================================================================= # Website Description @@ -107,9 +125,8 @@ echo -e "\n# Description: writings about this website" read -rp \ ": Website Description ? " \ gsl_set_about -gsl__check_settings $gsl_set_about\ - && [[ "$gsl_process_stop" ]] \ - && return + +gsl__check_settings $gsl_set_about || return #======================================================================= # Contact Mail @@ -119,21 +136,17 @@ read -rp \ ": Contact Mail ? " \ gsl_set_mail -gsl__check_settings $gsl_set_mail \ - && [[ "$gsl_process_stop" ]] \ - && return +gsl__check_settings $gsl_set_mail || return #======================================================================= # Website Keywords #======================================================================= -echo -e "\n# Keywords: geek,logiciels libre,friends (comma separated)" +echo -e "\n# GENERIC pages Keywords: geek stuff,free (comma separated)" read -rp \ - ": Website Keywords ? " \ + ": Website Keywords for all Pages ? " \ gsl_set_keys -gsl__check_settings $gsl_set_keys \ - && [[ "$gsl_process_stop" ]] \ - && return +gsl__check_settings $gsl_set_keys || return #======================================================================= # Language @@ -143,9 +156,7 @@ read -rp \ ": Website Lang ? " \ gsl_set_lang -gsl__check_settings $gsl_set_lang \ - && [[ "$gsl_process_stop" ]] \ - && return +gsl__check_settings $gsl_set_lang || return #======================================================================= # Copyright @@ -155,57 +166,58 @@ read -rp \ ": Website Copyright ? " \ gsl_set_cr -gsl__check_settings $gsl_set_cr \ - && [[ "$gsl_process_stop" ]] \ - && return +gsl__check_settings $gsl_set_cr || return #======================================================================= # Website Logo #======================================================================= -printf '\n%s %s\n' \ +printf '\n%s\n %s\n' \ "# logo: my-logo.png" \ "(Put it in $gsl_save_dir_ndd/templates/)" read -rp \ ": Website logo file NAME ? " \ gsl_set_logo -gsl__check_settings $gsl_set_logo \ - && [[ "$gsl_process_stop" ]] \ - && return +gsl__check_settings $gsl_set_logo || return #======================================================================= # CSS Acronym #======================================================================= -printf '\n%s %s\n' \ +printf '\n%s\n %s\n' \ "# CSS (short) Acronym: myweb !No need to end with _" \ "(Will create specific classes like myweb_paragraph)" read -rp \ ": CSS Acronym ? " \ gsl_set_css -gsl__check_settings $gsl_set_css \ - && [[ "$gsl_process_stop" ]] \ - && return +gsl__check_settings $gsl_set_css || return #======================================================================= # Author Reference #======================================================================= -printf '\n%s %s\n' \ - "# Author URL Profile: https://..." \ +printf '\n%s\n %s\n' \ + "# Author/Compagny URL Profile: https://..." \ "(Used for meta rel='me')" read -rp \ ": Author URL Profile ? " \ gsl_set_auth_url -gsl__check_settings $gsl_set_auth_url \ - && [[ "$gsl_process_stop" ]] \ - && return +gsl__check_settings $gsl_set_auth_url || return + +#======================================================================= +# Folder for Posts +#======================================================================= +printf '\n%s\n %s\n %s\n' \ + "# You can set here a folder for your writings' Posts" + "or manually do it later or add another one later" + "Autocompletion /NEWFOLDER (name of choice)" +read -erp ": Where will you add your files' Post ? " gsl_dir_user_posts #======================================================================= # Show Resume #======================================================================= clear -printf '%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n' \ +printf '%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n' \ "# New Website configurations..." \ ": Webserver|$gsl_set_server" \ ": URL|$gsl_set_url" \ @@ -219,6 +231,7 @@ printf '%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n' \ ": Logo File|$gsl_set_logo" \ ": CSS Acro|$gsl_set_css" \ ": Author URL|$gsl_set_auth_url" \ + ": User folder writings' Posts|$gsl_dir_user_posts" | column -t -s'|' #======================================================================= @@ -269,19 +282,36 @@ fi && read -rp "$gsl_ask ?" gsl_set_confirm case "$gsl_set_confirm" in - y|Y) - ! [[ -d "$gsl_save_dir_ndd/templates" ]] \ - && mkdir -p "$gsl_save_dir_ndd/templates" \ - && gsl__logs_print \ - "$gsl_log_i" \ - "Create" \ - "Folder" \ - "Configuration from $gsl_set_ndd" \ - "$gsl_save_dir_ndd/templates" - ;; - *) - gsl__new_website && return - ;; + y|Y) + if ! [[ -d "$gsl_save_dir_ndd" ]];then + mkdir -p "$gsl_save_dir_ndd" && \ + gsl__logs_print \ + "$gsl_log_i" \ + "Create" \ + "Folder" \ + "Configuration from $gsl_set_ndd" \ + "$gsl_save_dir_ndd/" + + mkdir -p "$gsl_dir_user_posts" && \ + gsl__logs_print \ + "$gsl_log_i" \ + "Create" \ + "Folder" \ + "User Posts from $gsl_set_ndd" \ + "$gsl_dir_user_posts/" + + touch "$gsl_dir_user_posts/gsl.$gsl_set_ndd" && \ + gsl__logs_print \ + "$gsl_log_i" \ + "Create" \ + "File" \ + "gsl.$gsl_set_ndd" \ + "$gsl_dir_user_posts/" + fi + ;; + *) + gsl__new_website && return + ;; esac #======================================================================= @@ -317,11 +347,7 @@ fi # Check if no Response from $@ #======================================================================= gsl__check_settings() { - case "$@" in - "") - gsl_process_stop=true - echo "! Abandon... Maybe next time" - return - ;; - esac +[[ "$@" ]] && return +echo "! Abandon... Maybe next time" +return } diff --git a/var/lib/gsl/scripts/gsl__post_checkers b/var/lib/gsl/scripts/gsl__post_checkers index aefffe6..10a6087 100644 --- a/var/lib/gsl/scripts/gsl__post_checkers +++ b/var/lib/gsl/scripts/gsl__post_checkers @@ -11,10 +11,10 @@ gsl__post_all_checkers() { clear unset gsl_check_done +echo -ne "\r\033[2K: Searching for #1..." +gsl__post_check_h1 || return echo -n ": Searching for NEEDED HEADERS..." gsl__post_check_needed_headers -echo -ne "\r\033[2K: Searching for #1..." -gsl__post_check_h1 echo -ne "\r\033[2K: Searching for PARAGRAPHS" gsl__post_check_paragraphs echo -ne "\r\033[2K: Searching for Content MARKERS..." @@ -29,6 +29,8 @@ echo -ne "\r\033[2K: Searching for FILES..." gsl__post_check_files echo -ne "\r\033[2K: Searching for IMAGES..." gsl__post_check_images +echo -ne "\r\033[2K: Searching for BLOCK-CODES..." +gsl__post_check_bcodes echo -ne "\r\033[2K" @@ -49,61 +51,48 @@ gsl__post_check_needed_headers() { #----------------------------------------------------------------------- # Title gsl_header_title=`gsl__get_header "$gsl_marker_title" "$gsl_post"` -! [[ "$gsl_header_title" ]] \ - && gsl__logs_print \ - "$gsl_log_e" \ - "Title" \ - "Post" \ - "Missing" \ - "${PWD}/$gsl_post" \ - && gsl_checker_err=true +gsl__check_needed_headers \ + "$gsl_header_title" \ + "$gsl_marker_title" \ + "POST TITLE" # Slug gsl_header_slug=`gsl__get_header "$gsl_marker_slug" "$gsl_post"` -! [[ "$gsl_header_slug" ]] \ - && gsl__logs_print \ - "$gsl_log_e" \ - "Slug" \ - "Post" \ - "Missing" \ - "${PWD}/$gsl_post" \ - && gsl_checker_err=true \ +gsl__check_needed_headers \ + "$gsl_header_slug" \ + "$gsl_marker_slug" \ + "POST-TITLE" \ && gsl_slug_err=true # Author gsl_header_author=`gsl__get_header "$gsl_marker_author" "$gsl_post"` -! [[ "$gsl_header_author" ]] \ - && gsl__logs_print \ - "$gsl_log_e" \ - "Author" \ - "Post" \ - "Missing" \ - "${PWD}/$gsl_post" \ - && gsl_checker_err=true \ +gsl__check_needed_headers \ + "$gsl_header_author" \ + "$gsl_marker_author" \ + "REGISTRED NAME" \ && gsl_author_err=true # Date gsl_header_date=`gsl__get_header "$gsl_marker_date" "$gsl_post"` -! [[ "$gsl_header_date" ]] \ - && gsl__logs_print \ - "$gsl_log_e" \ - "Date" \ - "Post" \ - "Missing" \ - "${PWD}/$gsl_post" \ - && gsl_checker_err=true \ +gsl__check_needed_headers \ + "$gsl_header_date" \ + "$gsl_marker_date" \ + "YYYY-MM-DD" \ && gsl_date_err=true # Description gsl_header_info=`gsl__get_header "$gsl_marker_info" "$gsl_post"` -! [[ "$gsl_header_info" ]] \ - && gsl__logs_print \ - "$gsl_log_e" \ - "Infos" \ - "Post" \ - "Missing" \ - "${PWD}/$gsl_post" \ - && gsl_checker_err=true +gsl__check_needed_headers \ + "$gsl_header_info" \ + "$gsl_marker_info" \ + "DESCRIPTION" + +# Tags +gsl_header_tags=`gsl__get_header "$gsl_marker_tags" "$gsl_post"` +gsl__check_needed_headers \ + "$gsl_header_tags" \ + "$gsl_marker_tags" \ + "TAG1,OTHER TAG2,TAG3" #----------------------------------------------------------------------- # Check for VALID Content HEADERS @@ -114,8 +103,8 @@ if ! [[ "$gsl_author_err" ]] && \ gsl__logs_print \ "$gsl_log_e" \ - "Author" \ "Post" \ + "Header $gsl_marker_author" \ "$gsl_header_author not registred for domain $gsl_find_domain" \ "${PWD}/$gsl_post" gsl_checker_err=true @@ -127,8 +116,8 @@ if ! [[ "$gsl_date_err" ]] && \ gsl__logs_print \ "$gsl_log_e" \ - "Date" \ "Post" \ + "Header $gsl_marker_date" \ "$gsl_header_date not YYYY-MM-DD" \ "${PWD}/$gsl_post" gsl_checker_err=true @@ -141,12 +130,12 @@ if ! [[ "$gsl_slug_err" ]];then if ! [[ "$gsl_header_slug" == "$gsl_header_slug_test" ]];then gsl_new_header_slug="$gsl_marker_slug$gsl_header_slug_test" sed -i \ - "s|$gsl_marker_slug$gsl_header_slug|$gsl_new_header_slug" \ + "s|$gsl_marker_slug$gsl_header_slug|$gsl_new_header_slug|" \ "$gsl_post" && \ gsl__logs_print \ "$gsl_log_w" \ - "Slug" \ "Post" \ + "Header $gsl_marker_slug" \ "Changed: $gsl_header_slug_test" \ "${PWD}/$gsl_post" @@ -168,9 +157,9 @@ grep -n "#1" $gsl_post \ if ! [[ "$gsl_post_begin" ]];then gsl__logs_print \ "$gsl_log_e" \ - "Begin" \ "Post" \ - "Missing content: #1 TITLE" \ + "Content begin" \ + "Missing: #1 TITLE" \ "${PWD}/$gsl_post" gsl_checker_err=true fi @@ -197,8 +186,8 @@ awk -v line="$gsl_post_begin" \ if (( "$gsl_post_p_open_nbr" == 0 ));then gsl__logs_print \ "$gsl_log_e" \ - "Paragraph" \ "Post" \ + "Content paragraphs" \ "Missing content: ( and ) at begining lines" \ "${PWD}/$gsl_post" gsl_checker_err=true @@ -210,8 +199,8 @@ if (( "$gsl_post_p_open_nbr" == "$gsl_post_p_close_nbr" ));then else gsl__logs_print \ "$gsl_log_e" \ - "Paragraph" \ "Post" \ + "Content paragraphs" \ "Mismatch: (=$gsl_post_p_open_nbr ; )=$gsl_post_p_close_nbr" \ "${PWD}/$gsl_post" gsl_checker_err=true @@ -311,7 +300,7 @@ if [[ "$gsl_post_blockquotes_nbr_r" -eq 0 ]];then gsl__logs_print \ "$gsl_log_i" \ "Post" \ - "Blockquotes" \ + "Content citations" \ "NBR=$gsl_post_stat_bq > $gsl_mark_blockquote (2x)" \ "${PWD}/$gsl_post" fi @@ -327,7 +316,7 @@ do # Get & Check HEADER CONTENT gsl__get_header_fields "$gsl_marker_abbr" - gsl__check_header_fields "Post" "ABBR" "$gsl_log_act_abbr" \ + gsl__check_header_fields "Post" "Header $gsl_marker_abbr" "$gsl_log_act_abbr" \ || continue # Check POST CONTENT @@ -341,8 +330,8 @@ do gsl__logs_print \ "$gsl_log_e" \ "Post" \ - "ABBR" \ - "Missing Content: $gsl_post_header_field_1" \ + "$gsl_log_c_abbr" \ + "Missing: $gsl_post_header_field_1" \ "${PWD}/$gsl_post" gsl_checker_err=true @@ -351,7 +340,7 @@ done < <(gsl__get_header "$gsl_marker_abbr" "$gsl_post") gsl__logs_print \ "$gsl_log_i" \ "Post" \ - "ABBR" \ + "Header $gsl_marker_abbr" \ "NBR=$gsl_post_stat_abbr" \ "${PWD}/$gsl_post" } @@ -365,11 +354,11 @@ while read -r "gsl_header_content_line" do # Get & Check Header CONTENT gsl__get_header_fields "$gsl_marker_link" - gsl__check_header_fields "Post" "Link" "$gsl_log_act_link" \ + gsl__check_header_fields "Post" "Header $gsl_marker_link" "$gsl_log_act_link" \ || continue # Not ALT TEXT ? - gsl__check_header_field3 "Post" "Link" + gsl__check_header_field3 "Post" "Header $gsl_marker_link" # Find if ref is in CONTENT [[ `gsl__get_content_with_markers "$gsl_mo_link" "$gsl_mc_link"` ]] \ @@ -384,7 +373,7 @@ do || gsl__logs_print \ "$gsl_log_e" \ "Post" \ - "Link" \ + "Header $gsl_marker_link" \ "URL offline: $gsl_post_header_field_2" \ "${PWD}/$gsl_post" @@ -392,8 +381,8 @@ do gsl__logs_print \ "$gsl_log_e" \ "Post" \ - "Link" \ - "Missing Content: [_${gsl_post_header_field_1}_]" \ + "$gsl_log_c_link" \ + "Missing: [_${gsl_post_header_field_1}_]" \ "${PWD}/$gsl_post" gsl_checker_err=true @@ -410,36 +399,79 @@ do # Get & Check Header CONTENT gsl__get_header_fields "$gsl_marker_file" - gsl__check_header_fields "Post" "File" "$gsl_log_act_file" \ + gsl__check_header_fields "Post" "Header $gsl_marker_file" "$gsl_log_act_file" \ || continue # Not ALT TEXT ? - gsl__check_header_field3 "Post" "File" + gsl__check_header_field3 "Post" "Header $gsl_marker_file" + if ! [[ -f "$gsl_dir_domain_files/$gsl_post_header_field_2" ]];then + gsl__logs_print \ + "$gsl_log_e" \ + "Post" \ + "Header $gsl_marker_file" \ + "Not found: $gsl_post_header_field_2" \ + "$gsl_dir_domain_files/$gsl_post_header_field_2" + gsl_checker_err=true + fi + # Find if ref is in CONTENT [[ `gsl__get_content_with_markers "$gsl_mo_file" "$gsl_mc_file"` ]] \ && gsl_post_stat_file=$(( $gsl_post_stat_file + 1 )) \ && continue - [[ -f "$gsl_dir_domain_files/$gsl_post_header_field_2" ]] \ - && continue \ - || gsl__logs_print \ - "$gsl_log_e" \ - "Post" \ - "File" \ - "Not found: $gsl_post_header_field_2" \ - "$gsl_dir_domain_files/$gsl_post_header_field_2" + # Missing CONTENT + gsl__logs_print \ + "$gsl_log_e" \ + "Post" \ + "$gsl_log_c_file" \ + "Missing: <_${gsl_post_header_field_1}_>" \ + "${PWD}/$gsl_post" + gsl_checker_err=true + +done < <(gsl__get_header "$gsl_marker_file" "$gsl_post") +} + +#======================================================================= +# Check Post for CODES HEADER + Content +#======================================================================= +gsl__post_check_bcodes() { +gsl_post_stat_bcode=0 +while read -r "gsl_header_content_line" +do + + # Get & Check Header CONTENT + gsl__get_header_fields "$gsl_marker_code" + gsl__check_header_fields "Post" "Header $gsl_marker_code" "$gsl_log_act_code" \ + || continue + + if ! [[ -f "$gsl_dir_domain_files/$gsl_post_header_field_2" ]];then + gsl__logs_print \ + "$gsl_log_e" \ + "Post" \ + "Header $gsl_marker_code" \ + "Not found: $gsl_post_header_field_2" \ + "$gsl_dir_domain_files/$gsl_post_header_field_2" + gsl_checker_err=true + fi + + # Find if ref is in CONTENT + [[ `gsl__get_content_line \ + "$gsl_mark_code : $gsl_post_header_field_1" \ + "$gsl_post"` ]] \ + && gsl_post_stat_bcode=$(( $gsl_post_stat_bocde + 1 )) \ + && continue # Missing CONTENT gsl__logs_print \ "$gsl_log_e" \ "Post" \ - "File" \ - "Missing Content: <_${gsl_post_header_field_1}_>" \ + "$gsl_log_c_code" \ + "Missing: $gsl_mark_code : ${gsl_post_header_field_1}" \ "${PWD}/$gsl_post" gsl_checker_err=true -done < <(gsl__get_header "$gsl_marker_file" "$gsl_post") +done < <(gsl__get_header "$gsl_marker_code" "$gsl_post") } #======================================================================= @@ -452,12 +484,22 @@ do # Get & Check Header CONTENT gsl__get_header_fields "$gsl_marker_image" - gsl__check_header_fields "Post" "Image" "$gsl_log_act_image" \ + gsl__check_header_fields "Post" "Header $gsl_marker_image" "$gsl_log_act_image" \ || continue # Not ALT TEXT ? - gsl__check_header_field3 "Post" "Image" + gsl__check_header_field3 "Post" "Header $gsl_marker_image" + if ! [[ -f "$gsl_dir_domain_files/$gsl_post_header_field_2" ]];then + gsl__logs_print \ + "$gsl_log_e" \ + "Post" \ + "Header $gsl_marker_image" \ + "Not found: $gsl_post_header_field_2" \ + "$gsl_dir_domain_files/$gsl_post_header_field_2" + gsl_checker_err=true + fi + # Find if ref is in CONTENT [[ `gsl__get_content_line \ "$gsl_mark_image : $gsl_post_header_field_1" \ @@ -465,21 +507,12 @@ do && gsl_post_stat_image=$(( $gsl_post_stat_image + 1 )) \ && continue - [[ -f "$gsl_dir_domain_files/$gsl_post_header_field_2" ]] \ - && continue \ - || gsl__logs_print \ - "$gsl_log_e" \ - "Post" \ - "image" \ - "Not found: $gsl_post_header_field_2" \ - "$gsl_dir_domain_files/$gsl_post_header_field_2" - # Missing CONTENT gsl__logs_print \ "$gsl_log_e" \ "Post" \ - "Image" \ - "Missing Content: _image_ : ${gsl_post_header_field_1}" \ + "$gsl_log_c_image" \ + "Missing: $gsl_mark_image : ${gsl_post_header_field_1}" \ "${PWD}/$gsl_post" gsl_checker_err=true diff --git a/var/lib/gsl/scripts/gsl__post_manager b/var/lib/gsl/scripts/gsl__post_manager index daca754..2047885 100644 --- a/var/lib/gsl/scripts/gsl__post_manager +++ b/var/lib/gsl/scripts/gsl__post_manager @@ -10,10 +10,9 @@ gsl__check_nbr_posts() { gsl_nbr_posts=`ls -1 *.gsl 2>/dev/null | wc -l` -(( $gsl_nbr_posts >= 1 )) \ - && return - -echo "! No Posts found with .gsl extension" +! (( $gsl_nbr_posts >= 1 )) \ + && echo "! No Posts found with .gsl extension" \ + && exit 1 } #======================================================================= @@ -117,9 +116,11 @@ awk -v s="$1" \ # Get everything after the marker... $1: marker | $2: File #======================================================================= gsl__get_header() { -awk -F"$1" -v marker="$1" \ - '{if ($0 ~ marker) print $2}' \ +awk -F"$1" -v marker="$1" -v l="$gsl_post_begin" \ + 'NR < l && $0 ~ marker {print $2}' \ "$2" 2>/dev/null + +# '{if ($0 ~ marker) print $2}' \ } #======================================================================= @@ -182,6 +183,21 @@ elif [[ "$ivar" ]];then fi } +#======================================================================= +# Check & get NEEDED HEADERS | $1 VAR CONTENT $2 LOG Proc $3 LOG Act +#======================================================================= +gsl__check_needed_headers() { +! [[ "$1" ]] \ + && gsl__logs_print \ + "$gsl_log_e" \ + "Post" \ + "Header $2" \ + "Missing: POST TITLE" \ + "${PWD}/$gsl_post" \ + && gsl_checker_err=true +} + + #======================================================================= # Get Fields and line nbr from header from marker #======================================================================= diff --git a/var/lib/gsl/scripts/gsl__tools b/var/lib/gsl/scripts/gsl__tools index edcba06..d52653d 100644 --- a/var/lib/gsl/scripts/gsl__tools +++ b/var/lib/gsl/scripts/gsl__tools @@ -60,26 +60,23 @@ find . -maxdepth 1 -not -type d -type f \ -iname "gsl.*.*" 2>/dev/null \ | wc -l` -if (( $gsl_nbr_domains > 1 ));then - echo "! Too much domains registred here: Set only One per folder" - return -elif (( $gsl_nbr_domains == 0 ));then - echo "! No registred domain here: change or set folder. See help new" - return -fi +(( $gsl_nbr_domains > 1 )) \ + && echo "! Too much domains registred here: Set only One per folder" \ + && exit $gsl_nbr_domains +(( $gsl_nbr_domains == 0 )) \ + && echo "! No registred domain here: change or set folder. See help new" \ + && exit 1 gsl_find_domain=` find . -maxdepth 1 -not -type d -type f \ -iname "gsl.*.*" 2>/dev/null` -if [[ "$gsl_find_domain" ]];then - gsl_find_domain=` - awk -F"." '{print $(NF-1)"."$NF}' \ - <<< $gsl_find_domain` - - gsl_find_domain=${gsl_find_domain,,} - gsl__check_domain "$gsl_find_domain" || return -fi +gsl_find_domain=` +awk -F"." '{print $(NF-1)"."$NF}' \ + <<< $gsl_find_domain` + +gsl_find_domain=${gsl_find_domain,,} +gsl__check_domain "$gsl_find_domain" } #======================================================================= @@ -90,7 +87,7 @@ gsl_this_conf_domain=`grep "$1" "$gsl_file_db_domains"` ! [[ "$gsl_this_conf_domain" ]] \ && echo "! Domain Not found: $1" \ - && return + && exit 1 gsl_dir_domain_tpl="$gsl_this_conf_domain/templates" gsl_dir_domain_files="$gsl_this_conf_domain/files"