Added title list option + recode for gsl new

This commit is contained in:
Cyrille L 2022-04-12 17:56:54 +02:00
parent 0e5c836986
commit 9d75cb670f
5 changed files with 293 additions and 130 deletions

View File

@ -1,5 +1,5 @@
Package: egsl
Version: 0.0.15
Version: 0.0.16
Section: custom
Priority: optional
Architecture: all

View File

@ -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

View File

@ -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"
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
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
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
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
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
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
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
#=======================================================================
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/)"
"Put it in $gsl_save_dir_ndd/templates/"
fi
read -rp \
": Website logo file NAME ? " \
gsl_set_logo
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
#=======================================================================
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 classes like myweb_paragraph)"
"Will create specific HTML classes like myweb_paragraph"
fi
read -rp \
": CSS Acronym ? " \
gsl_set_css
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
#=======================================================================
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')"
"Used for meta rel='me'"
fi
read -rp \
": Author URL Profile ? " \
gsl_set_auth_url
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" \
"New" \
"Profile" \
"Create Folder configuration for $gsl_set_ndd" \
"$gsl_save_dir_ndd/"
fi
# 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" \
"Create" \
"Folder" \
"User Posts from $gsl_set_ndd" \
"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" \
"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,17 +479,24 @@ 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_log_w" \
"New" \
"Profile" \
"Add $gsl_save_dir_ndd to DB for $gsl_set_ndd" \
"$gsl_file_db_domains"
fi
}

View File

@ -260,7 +260,7 @@ cat << EOPAGE > "$gsl_srv_wip_page"
<aside id="${gsl_site_css}_sidebar">
<div class="${gsl_site_css}_wrapper" role="navigation">
<nav id="${gsl_site_css}_latest-posts">
<h1 class="${gsl_site_css}_latest-posts">Derniers articles</h1>
<h1 class="${gsl_site_css}_latest-posts">$gsl_site_listname</h1>
<ul aria-label="Liste d'Articles">
<!--# include file="$gsl_uri/templates/last-posts-list.html" -->
</ul>

View File

@ -208,10 +208,10 @@ if (( "$gsl_count_links" > 0 ));then
gsl_url_status=`
timeout 2 curl -o /dev/null --silent --head --write-out \
'%{http_code}' \
"$gsl_post_hf_2" 2>/dev/null || echo "408"`
"$gsl_post_hf_2" 2>/dev/null || gsl_url_status=408`
case "$gsl_url_status" in
0*|1*|2*|3*)
1*|2*|3*)
gsl__logs_print \
"$gsl_log_i" \
"Post" \
@ -226,7 +226,11 @@ if (( "$gsl_count_links" > 0 ));then
"$gsl_log_h_link" \
"Offline:$gsl_url_status ${gsl_post_hf_2:0:40}..." \
"${PWD}/$gsl_post"
# Decomment below if you want the offline link avoiding convertion
#gsl_checker_err=true
gsl_checker_war=true
return
;;
esac
@ -237,7 +241,7 @@ if (( "$gsl_count_links" > 0 ));then
else
gsl__logs_print \
"$gsl_log_i" \
"$gsl_log_e" \
"Post" \
"$gsl_log_c_link" \
"Unused: _$gsl_post_hf_1" \