From 9d75cb670f960e448c4259e7c6229c6c3e5a58f9 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Tue, 12 Apr 2022 17:56:54 +0200 Subject: [PATCH] Added title list option + recode for gsl new --- control | 2 +- usr/local/bin/gsl | 7 +- var/lib/gsl/scripts/gsl__new_website | 402 +++++++++++++++++-------- var/lib/gsl/scripts/gsl__page_creator | 2 +- var/lib/gsl/scripts/gsl__post_checkers | 10 +- 5 files changed, 293 insertions(+), 130 deletions(-) diff --git a/control b/control index e90d936..8d71280 100644 --- a/control +++ b/control @@ -1,5 +1,5 @@ Package: egsl -Version: 0.0.15 +Version: 0.0.16 Section: custom Priority: optional Architecture: all diff --git a/usr/local/bin/gsl b/usr/local/bin/gsl index c0bfcb0..0fb1df0 100755 --- a/usr/local/bin/gsl +++ b/usr/local/bin/gsl @@ -1,5 +1,5 @@ #!/bin/bash -# Version: 0.0.15 +# Version: 0.0.16 # file: gsl # Folder: /usr/local/bin # By echolib @@ -81,6 +81,8 @@ case "$1" in && cd "$gsl_dir_user_posts" \ && gsl author add + echo + gsl log -s -w exit ;; @@ -465,8 +467,9 @@ if [[ "$gsl_checker_war" ]];then gsl__logs_show fi -if [[ "$gsl_checker_war" ]];then +if [[ "$gsl_checker_err" ]];then echo gsl_logs_err=true gsl__logs_show + exit 1 fi diff --git a/var/lib/gsl/scripts/gsl__new_website b/var/lib/gsl/scripts/gsl__new_website index 149a2c0..8e067d6 100644 --- a/var/lib/gsl/scripts/gsl__new_website +++ b/var/lib/gsl/scripts/gsl__new_website @@ -11,7 +11,7 @@ # #======================================================================= gsl__new_website() { -gsl_if_file "$gsl_dir_helps/gsl_infos_new_website" source +gsl__if_file "$gsl_dir_helps/gsl_infos_new_website" read clear cat $gsl_dir_helps/gsl_infos_new_website @@ -20,19 +20,6 @@ printf '\n%s\n%s\n%s\n' \ "# Cancel with empty field" \ "# You will be asked to confirm at the end" -#======================================================================= -# Webserver URI -#======================================================================= -echo -e "\n# Webserver: /var/www (Or maybe elsewhere...)" -read -erp \ - ": Webserver URI ? " \ - gsl_set_server - -[[ ${gsl_set_server: -1} == "/" ]] \ - && gsl_set_server=${gsl_set_server::-1} - -gsl__check_settings $gsl_set_server || return - #======================================================================= # Domain URL #======================================================================= @@ -68,23 +55,65 @@ 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" \ +[[ -f "$gsl_dir_user_domains/$gsl_set_ndd/$gsl_set_file_ndd" ]] \ + && gsl_profile="$gsl_dir_user_domains/$gsl_set_ndd/$gsl_set_file_ndd" \ && gsl_set_user_conf="Y" -[[ -d "$gsl_dir_global_domains/$gsl_set_ndd" ]] \ - && gsl_profile="System: $gsl_dir_global_domains/$gsl_set_ndd" \ +[[ -f "$gsl_dir_global_domains/$gsl_set_ndd/$gsl_set_file_ndd" ]] \ + && gsl_profile="$gsl_dir_global_domains/$gsl_set_ndd/$gsl_set_file_ndd" \ && gsl_set_user_conf="N" if [[ "$gsl_profile" ]];then - echo "! A Profile exists in your $gsl_profile" - read -rp ": Continue (Y|*)" gsl_continue + gsl__logs_print \ + "$gsl_log_w" \ + "New" \ + "Profile" \ + "Found configuration from $gsl_set_ndd" \ + "$gsl_profile" + + echo -e "\n! A Profile exists: $gsl_profile" + read -rp ": Continue (Y|*) " gsl_continue case "$gsl_continue" in - Y|y) true ;; - *) gsl__check_settings $blank || return + Y|y) + source "$gsl_profile" && \ + gsl__logs_print \ + "$gsl_log_i" \ + "New" \ + "Profile" \ + "Load configuration from $gsl_set_ndd" \ + "$gsl_profile" + gsl_profile_exists=true + ;; + *) + return + ;; esac fi +#======================================================================= +# Webserver URI +#======================================================================= +[[ $gsl_profile_exists ]] \ + && echo -e "\n# Webserver registred: $gsl_site_server" \ + || echo -e "\n# Webserver: /var/www (Or maybe elsewhere...)" + +read -erp \ + ": Webserver URI ? " \ + gsl_set_server + +[[ ${gsl_set_server: -1} == "/" ]] \ + && gsl_set_server=${gsl_set_server::-1} + +if [[ $gsl_profile_exists ]];then + if ! [[ "$gsl_set_server" ]];then + [[ "$gsl_site_server" ]] \ + && gsl_set_server="$gsl_site_server" \ + || gsl__check_settings $gsl_set_server || return + fi +else + gsl__check_settings $gsl_set_server || return +fi + #======================================================================= # Personal use or global use ? #======================================================================= @@ -94,16 +123,17 @@ if ! [[ "$gsl_set_user_conf" ]];then ": 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" gsl_save_conf_ndd="$gsl_save_dir_ndd/$gsl_set_file_ndd" - gsl_ask="# Save to $gsl_save_conf_ndd ? " + gsl_ask="# Save to $gsl_save_conf_ndd (y|*) ? " ;; n|N) gsl_save_dir_ndd="$gsl_dir_global_domains/$gsl_set_ndd" gsl_save_conf_ndd="$gsl_save_dir_ndd/$gsl_set_file_ndd" - gsl_ask="# Save to $gsl_save_conf_ndd" + gsl_ask="# Save to $gsl_save_conf_ndd (y|*) ? " ;; *) echo "! Abandon... Maybe next time" && return ;; esac @@ -111,106 +141,253 @@ esac #======================================================================= # Website Title #======================================================================= -echo -e "\n# Title: My Compagny (or My beautiful website)" +[[ $gsl_profile_exists ]] \ + && echo -e "\n# Title registred: $gsl_site_title" \ + || echo -e "\n# Title: My Compagny (or My beautiful website)" + read -rp \ ": Website Title ? " \ gsl_set_title -gsl__check_settings $gsl_set_title || return +if [[ $gsl_profile_exists ]];then + if ! [[ "$gsl_set_title" ]];then + [[ "$gsl_site_title" ]] \ + && gsl_set_title="$gsl_site_title" \ + || gsl__check_settings $gsl_set_title || return + fi +else + gsl__check_settings $gsl_set_title || return +fi #======================================================================= # Website Description #======================================================================= -echo -e "\n# Description: writings about this website" +[[ $gsl_profile_exists ]] \ + && echo -e "\n# Description registred: $gsl_site_about" \ + || echo -e "\n# Description: writings about this website" + read -rp \ ": Website Description ? " \ gsl_set_about -gsl__check_settings $gsl_set_about || return +if [[ $gsl_profile_exists ]];then + if ! [[ "$gsl_set_about" ]];then + [[ "$gsl_site_about" ]] \ + && gsl_set_about="$gsl_site_about" \ + || gsl__check_settings $gsl_set_about || return + fi +else + gsl__check_settings $gsl_set_about || return +fi #======================================================================= # Contact Mail #======================================================================= -echo -e "\n# Mail: contact@example.com" +[[ $gsl_profile_exists ]] \ + && echo -e "\n# Mail registred: $gsl_site_mail" \ + || echo -e "\n# Mail: contact@example.com" + read -rp \ ": Contact Mail ? " \ gsl_set_mail -gsl__check_settings $gsl_set_mail || return +if [[ $gsl_profile_exists ]];then + if ! [[ "$gsl_set_mail" ]];then + [[ "$gsl_site_mail" ]] \ + && gsl_set_mail="$gsl_site_mail" \ + || gsl__check_settings $gsl_set_mail || return + fi +else + gsl__check_settings $gsl_set_mail || return +fi #======================================================================= # Website Keywords #======================================================================= -echo -e "\n# GENERIC pages Keywords: geek stuff,free (comma separated)" +if [[ $gsl_profile_exists ]];then + printf '\n%s\n %s\n' \ + "# GENERIC pages Keywords registred: $gsl_site_keys" \ + "! Will be used on each post !" +else + printf '\n%s\n %s\n' \ + "# GENERIC pages Keywords: geek stuff,free (comma separated)" \ + "! Will be used on each post !" +fi + read -rp \ ": Website Keywords for all Pages ? " \ gsl_set_keys -gsl__check_settings $gsl_set_keys || return +if [[ $gsl_profile_exists ]];then + if ! [[ "$gsl_set_keys" ]];then + [[ "$gsl_site_keys" ]] \ + && gsl_set_keys="$gsl_site_keys" \ + || gsl__check_settings $gsl_set_keys || return + fi +else + gsl__check_settings $gsl_set_keys || return +fi #======================================================================= # Language #======================================================================= -echo -e "\n# Language: fr (or en-GB...)" +[[ $gsl_profile_exists ]] \ + && echo -e "\n# Language registred: $gsl_site_lang" \ + || echo -e "\n# Language: fr (or en-GB...)" + read -rp \ ": Website Lang ? " \ gsl_set_lang -gsl__check_settings $gsl_set_lang || return +if [[ $gsl_profile_exists ]];then + if ! [[ "$gsl_set_lang" ]];then + [[ "$gsl_site_lang" ]] \ + && gsl_set_lang="$gsl_site_lang" \ + || gsl__check_settings $gsl_set_lang || return + fi +else + gsl__check_settings $gsl_set_lang || return +fi #======================================================================= # Copyright #======================================================================= -echo -e "\n# Copyright: 2022 TITLE CC-BY-SA" +[[ $gsl_profile_exists ]] \ + && echo -e "\n# Copyright registred: $gsl_site_cr" \ + || echo -e "\n# Copyright: 2022 TITLE CC-BY-SA" + read -rp \ ": Website Copyright ? " \ gsl_set_cr -gsl__check_settings $gsl_set_cr || return +if [[ $gsl_profile_exists ]];then + if ! [[ "$gsl_set_cr" ]];then + [[ "$gsl_site_cr" ]] \ + && gsl_set_cr="$gsl_site_cr" \ + || gsl__check_settings $gsl_set_cr || return + fi +else + gsl__check_settings $gsl_set_cr || return +fi + #======================================================================= # Website Logo #======================================================================= -printf '\n%s\n %s\n' \ - "# logo: my-logo.png" \ - "(Put it in $gsl_save_dir_ndd/templates/)" +if [[ $gsl_profile_exists ]];then + printf '\n%s\n %s\n' \ + "# logo registred: $gsl_site_logo" \ + "Put it in $gsl_save_dir_ndd/templates/" +else + printf '\n%s\n %s\n' \ + "# logo: my-logo.png" \ + "Put it in $gsl_save_dir_ndd/templates/" +fi + read -rp \ ": Website logo file NAME ? " \ gsl_set_logo -gsl__check_settings $gsl_set_logo || return +if [[ $gsl_profile_exists ]];then + if ! [[ "$gsl_set_logo" ]];then + [[ "$gsl_site_logo" ]] \ + && gsl_set_logo="$gsl_site_logo" \ + || gsl__check_settings $gsl_set_logo || return + fi +else + gsl__check_settings $gsl_set_logo || return +fi + + +#======================================================================= +# Last Posts listing name header +#======================================================================= +if [[ $gsl_profile_exists ]];then + printf '\n%s\n %s\n' \ + "# Title List Name registred: $gsl_site_listname" \ + "Title List to show before last posts" +else + printf '\n%s\n %s\n' \ + "# Title List Name: My Last Posts" \ + "Title List to show before last posts" +fi + +read -rp \ + ": Title List Name ? " \ + gsl_set_listname + +if [[ $gsl_profile_exists ]];then + if ! [[ "$gsl_set_listname" ]];then + [[ "$gsl_site_listname" ]] \ + && gsl_set_listname="$gsl_site_listname" \ + || gsl__check_settings $gsl_set_listname || return + fi +else + gsl__check_settings $gsl_set_listname || return +fi #======================================================================= # CSS Acronym #======================================================================= -printf '\n%s\n %s\n' \ - "# CSS (short) Acronym: myweb !No need to end with _" \ - "(Will create specific classes like myweb_paragraph)" +if [[ $gsl_profile_exists ]];then + printf '\n%s\n %s\n' \ + "# CSS (short) Acronym registred: $gsl_site_css" \ + "Will create specific HTML classes like ${gsl_site_css}_paragraph" +else + printf '\n%s\n %s\n' \ + "# CSS (short) Acronym: myweb !No need to end with _" \ + "Will create specific HTML classes like myweb_paragraph" +fi + read -rp \ ": CSS Acronym ? " \ gsl_set_css -gsl__check_settings $gsl_set_css || return +if [[ $gsl_profile_exists ]];then + if ! [[ "$gsl_set_css" ]];then + [[ "$gsl_site_css" ]] \ + && gsl_set_css="$gsl_site_css" \ + || gsl__check_settings $gsl_set_css || return + fi +else + gsl__check_settings $gsl_set_css || return +fi #======================================================================= # Author Reference #======================================================================= -printf '\n%s\n %s\n' \ - "# Author/Compagny URL Profile: https://..." \ - "(Used for meta rel='me')" +if [[ $gsl_profile_exists ]];then + printf '\n%s\n %s\n' \ + "# Author/Compagny URL Profile registred: $gsl_site_auth_url" \ + "Used for meta rel='me'" +else + printf '\n%s\n %s\n' \ + "# Author/Compagny URL Profile: https://..." \ + "Used for meta rel='me'" +fi + read -rp \ ": Author URL Profile ? " \ gsl_set_auth_url -gsl__check_settings $gsl_set_auth_url || return +if [[ $gsl_profile_exists ]];then + if ! [[ "$gsl_set_auth_url" ]];then + [[ "$gsl_site_auth_url" ]] \ + && gsl_set_auth_url="$gsl_site_auth_url" \ + || gsl__check_settings $gsl_set_auth_url || return + fi +else + gsl__check_settings $gsl_set_auth_url || return +fi #======================================================================= # 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" \ + "Leave Empty to manually do it later (see help)" \ "Autocompletion /NEWFOLDER (name of choice)" + read -erp \ ": Where will you add your files' [post].gsl ? " \ gsl_dir_user_posts @@ -219,7 +396,7 @@ read -erp \ # 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%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%s\n' \ "# New Website configurations..." \ ": Webserver|$gsl_set_server" \ ": URL|$gsl_set_url" \ @@ -231,95 +408,67 @@ 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' \ ": Language|$gsl_set_lang" \ ": Copyright|$gsl_set_cr" \ ": Logo File|$gsl_set_logo" \ + ": Title List|$gsl_set_listname" \ ": CSS Acro|$gsl_set_css" \ ": Author URL|$gsl_set_auth_url" \ ": User folder writings' Posts|$gsl_dir_user_posts" \ | column -t -s'|' + #======================================================================= # Ask to Confirm #======================================================================= echo -if [[ -d "$gsl_save_dir_ndd" ]];then - printf '%s\n%s\n' \ - "! A profile already exists in $gsl_save_dir_ndd" \ - "- Remove (A)LL Directories: $gsl_save_dir_ndd" \ - "- Remove (F)ile configurations : $gsl_save_conf_ndd" \ - "- Any other key to cancel" && \ - gsl__logs_print \ - "$gsl_log_w" \ - "Found" \ - "Profile" \ - "Configuration from $gsl_set_ndd" \ - "$gsl_save_conf_ndd" - - read -rp "! Remove (A|F|*) ? " \ - gsl_ask_remove - - case "$gsl_ask_remove" in - A) - rm -rf "$gsl_save_dir_ndd" && \ - gsl__logs_print \ - "$gsl_log_i" \ - "Remove" \ - "Folders" \ - "Configuration from $gsl_set_ndd" \ - "$gsl_save_dir_ndd" - ;; - F) - rm -f "$gsl_save_conf_ndd" && \ - gsl__logs_print \ - "$gsl_log_i" \ - "Remove" \ - "File" \ - "Configuration from $gsl_set_ndd" \ - "$gsl_save_conf_ndd" - gsl_set_confirm="Y" - ;; - *) echo "# Canceled";return ;; - esac -fi - -! [[ "$gsl_set_confirm" ]] \ - && read -rp "$gsl_ask ?" gsl_set_confirm +read -rp "$gsl_ask " gsl_set_confirm case "$gsl_set_confirm" in y|Y) + gsl__logs_print \ + "$gsl_log_w" \ + "New" \ + "Profile" \ + "Confirmed configuration from $gsl_set_ndd" \ + "$gsl_save_conf_ndd" + 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_save_dir_ndd" && \ + gsl__logs_print \ + "$gsl_log_i" \ + "New" \ + "Profile" \ + "Create Folder configuration for $gsl_set_ndd" \ + "$gsl_save_dir_ndd/" + fi - mkdir -p "$gsl_dir_user_posts" && \ - gsl__logs_print \ - "$gsl_log_i" \ - "Create" \ - "Folder" \ - "User Posts from $gsl_set_ndd" \ - "$gsl_dir_user_posts/" + # Create et set a folder for writings' posts + if [[ $gsl_dir_user_posts ]];then + mkdir -p "$gsl_dir_user_posts" && \ + gsl__logs_print \ + "$gsl_log_i" \ + "New" \ + "Profile" \ + "Create Folder Posts for $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/" + touch "$gsl_dir_user_posts/gsl.$gsl_set_ndd" && \ + gsl__logs_print \ + "$gsl_log_i" \ + "New" \ + "Profile" \ + "Folder set with gsl.$gsl_set_ndd" \ + "$gsl_dir_user_posts/" fi ;; + *) - gsl__new_website && return + return ;; esac #======================================================================= # Save config #======================================================================= -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' \ +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' \ "gsl_site_server=\"$gsl_set_server\"" \ "gsl_site_url=\"$gsl_set_url\"" \ "gsl_site_ndd=\"$gsl_set_ndd\"" \ @@ -330,18 +479,25 @@ 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' \ "gsl_site_lang=\"$gsl_set_lang\"" \ "gsl_site_cr=\"$gsl_set_cr\"" \ "gsl_site_logo=\"$gsl_set_logo\"" \ + "gsl_site_listname=\"$gsl_set_listname\"" \ "gsl_site_css=\"$gsl_set_css\"" \ "gsl_site_auth_url=\"$gsl_set_auth_url\"" \ - > "$gsl_save_conf_ndd" + > "$gsl_save_conf_ndd" && \ +gsl__logs_print \ + "$gsl_log_w" \ + "New" \ + "Profile" \ + "Write configuration for $gsl_set_ndd" \ + "$gsl_save_conf_ndd" if ! [[ `grep "$gsl_save_dir_ndd" "$gsl_file_db_domains"` ]];then - echo "$gsl_save_dir_ndd" >> "$gsl_file_db_domains" && \ - gsl__logs_print \ - "$gsl_log_i" \ - "Create" \ - "File" \ - "Configuration from $gsl_set_ndd" \ - "$gsl_file_db_domains" + echo "$gsl_save_dir_ndd" >> "$gsl_file_db_domains" && \ + gsl__logs_print \ + "$gsl_log_w" \ + "New" \ + "Profile" \ + "Add $gsl_save_dir_ndd to DB for $gsl_set_ndd" \ + "$gsl_file_db_domains" fi } diff --git a/var/lib/gsl/scripts/gsl__page_creator b/var/lib/gsl/scripts/gsl__page_creator index 201511a..895d535 100644 --- a/var/lib/gsl/scripts/gsl__page_creator +++ b/var/lib/gsl/scripts/gsl__page_creator @@ -260,7 +260,7 @@ cat << EOPAGE > "$gsl_srv_wip_page"