Fixes, updated:DB,Maker,Listings

This commit is contained in:
Cyrille L 2022-03-02 17:25:23 +01:00
parent 6e9acd406d
commit a2c31e41f4
7 changed files with 138 additions and 56 deletions

View File

@ -161,6 +161,16 @@ case "$1" in
make|-M)
gsl__check_nbr_posts
case "$2" in
-F)
gsl_force_make=true
[[ "$3" ]] && gsl__check_opt_post "$3"
;;
*)
[[ "$2" ]] && gsl__check_opt_post "$2"
;;
esac
gsl__logs_print \
"$gsl_log_i" \
"Starting" \

View File

@ -46,7 +46,7 @@ case "$gsl_process" in
Checked)
case "$gsl_db_post_status" in
Checked)
gsl__db_compare_post_hash || return
gsl__db_compare_post_hash || return # Do Nothing if same Hash
gsl__db_create_post
;;
Made)
@ -67,6 +67,18 @@ esac
# Create DB File from Data Post
#======================================================================
gsl__db_create_post() {
if [[ "$gsl_checker_err" ]];then
[[ -f "$gsl_file_db_post" ]] \
&& rm -f "$gsl_file_db_post" \
&& gsl__logs_print \
"$gsl_log_w" \
"DB" \
"Delete" \
"file ; error in $gsl_post" \
"$gsl_file_db_post"
return
fi
touch "$gsl_file_db_post"
# Main Print

View File

@ -4,15 +4,15 @@
# By echolib
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#-----------------------------------------------------------------------
#----------------------------------------------------------------------
# --------------------------------------------------
# From: gsl__all_makers | Create HTML Page
# --------------------------------------------------
#-----------------------------------------------------------------------
#----------------------------------------------------------------------
#-----------------------------------------------------------------------
#----------------------------------------------------------------------
# MAIN
#-----------------------------------------------------------------------
#----------------------------------------------------------------------
gsl__page_creator() {
#gsl__page_prepare_datas
gsl__check_templates
@ -21,9 +21,9 @@ gsl__page_create
cat -n "$gsl_srv_wip_page"
}
#-----------------------------------------------------------------------
#----------------------------------------------------------------------
# Get Datas for Post/Page
#-----------------------------------------------------------------------
#----------------------------------------------------------------------
gsl__page_prepare_datas() {
echo "D> $gsl_this_conf_domain"
@ -54,20 +54,62 @@ esac
gsl_uri_site_logo="$gsl_uri/templates/$gsl_site_logo"
}
#-----------------------------------------------------------------------
#----------------------------------------------------------------------
# Check if Post / Pages exists in server
#-----------------------------------------------------------------------
#----------------------------------------------------------------------
gsl__check_srv_files() {
if [[ -f "$1" ]];then
echo "! Replaced Page: $1"
fi
}
#-----------------------------------------------------------------------
# Create Final HTML Post/Page
#-----------------------------------------------------------------------
gsl__page_create() {
#======================================================================
# Create Post Listing
#======================================================================
gsl__page_create_listing() {
# Check if Post is in list ; Status Made
[[ "$gsl_db_post_status" == "Made" ]] \
&& gsl__logs_print \
"$gsl_log_i" \
"Post" \
"Make" \
"$gsl_post already added to Latest listings" \
"$gsl_file_db_posts" \
&& return
touch "$gsl_dir_domain_tpl/last-posts-list.html"
gsl_max_posts_list=5
gsl_cur_posts_list=`cat "$gsl_dir_domain_tpl/last-posts-list.html" | wc -l`
if (( $((gsl_cur_posts_list )) >= 25 ));then
echo "D> $gsl_cur_posts_list * $gsl_max_posts_list"
for i in `seq 1 5`;
do
sed -i "1d" "$gsl_dir_domain_tpl/last-posts-list.html"
done
fi
cat << EOPostSide >> "$gsl_dir_domain_tpl/last-posts-list.html"
<li>
<span class="${gsl_site_css}_list-post-title">$gsl_header_title</span>
<div class="${gsl_site_css}_list-post-metas">Le $gsl_header_date par $gsl_header_author<div>
<div class="${gsl_site_css}_list-post-info">$gsl_header_info</div>
</li>
EOPostSide
gsl__logs_print \
"$gsl_log_i" \
"Post" \
"Make" \
"$gsl_post added to Latest listings" \
"$gsl_file_db_posts"
}
#----------------------------------------------------------------------
# Create Final HTML Post/Page
#----------------------------------------------------------------------
gsl__page_create() {
cat << EOPAGE > "$gsl_srv_wip_page"
<!DOCTYPE html>
<html lang="${gsl_site_lang: :2}">
@ -81,14 +123,24 @@ cat << EOPAGE > "$gsl_srv_wip_page"
<section id="${gsl_site_css}_page-wrapper">
<article id="${gsl_site_css}_$gsl_header_slug">
<div id="${gsl_site_css}_metas">
<p id="${gsl_site_css}_auteur">Écrit par <strong>$gsl_header_author</strong> le $gsl_header_date</p>
</div>
`cat "$gsl_a11y_post"`
</article
</article>
<aside id="${gsl_site_css}_sidebar">
</aside
<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>
<ul aria-label="Liste d'Articles">
<!--# include file="$gsl_uri/templates/last-posts-list.html" -->
</ul>
</nav>
</div>
</aside>
</section>
`cat "$gsl_dir_domain_tpl/footer.html"`
@ -101,9 +153,9 @@ EOPAGE
rm -f "$gsl_html_meta"
}
#-----------------------------------------------------------------------
#----------------------------------------------------------------------
# Create META head for Post/Page
#-----------------------------------------------------------------------
#----------------------------------------------------------------------
gsl__html_meta_head() {
# Create file with metas to be included in Post/Page
gsl_html_meta=`mktemp`

View File

@ -378,7 +378,7 @@ fi
# Exists in Content
gsl_count_images=`
gsl__get_content_line "__image:$gsl_post_hf_1" "$gsl_post" | wc -l`
gsl__get_content_line "_image:$gsl_post_hf_1" "$gsl_post" | wc -l`
if (( $gsl_count_images > 0 ));then
@ -390,7 +390,7 @@ else
"$gsl_log_e" \
"Post" \
"$gsl_log_c_image" \
"Missing: __image:$gsl_post_hf_1" \
"Missing: _image:$gsl_post_hf_1" \
"${PWD}/$gsl_post"
gsl_checker_err=true
@ -435,7 +435,7 @@ fi
# Exists in Content
gsl_count_fcodes=`
gsl__get_content_line "__code:$gsl_post_hf_1" "$gsl_post" | wc -l`
gsl__get_content_line "_code:$gsl_post_hf_1" "$gsl_post" | wc -l`
if (( $gsl_count_fcodes > 0 ));then
@ -447,7 +447,7 @@ else
"$gsl_log_e" \
"Post" \
"$gsl_log_c_code" \
"Missing: __code:$gsl_post_hf_1" \
"Missing: _code:$gsl_post_hf_1" \
"${PWD}/$gsl_post"
gsl_checker_err=true

View File

@ -18,6 +18,9 @@ unset gsl_check_done
gsl__prepare_makers
gsl__page_prepare_datas
# Create Listng Page
gsl__page_create_listing
gsl__do_italics "make" "$gsl_tmp_post" # First
gsl__do_header "make" "$gsl_marker_link" "$gsl_post"
gsl__do_header "make" "$gsl_marker_abbr" "$gsl_post"
@ -304,27 +307,27 @@ echo -ne "\r\033[2K: Converting Paragraphs..."
while read -r "gsl_content_line_nbr" "gsl_content_line"
do
case "$gsl_content_line" in
")")
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_c," \
"$gsl_tmp_post"
;;
"("|"( 1")
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o1," \
"$gsl_tmp_post"
;;
"( 2")
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o2," \
"$gsl_tmp_post"
;;
"( 3")
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o3," \
"$gsl_tmp_post"
;;
*)
continue
;;
esac
case "$gsl_content_line" in
")")
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_c," \
"$gsl_tmp_post"
;;
"("|"( 1")
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o1," \
"$gsl_tmp_post"
;;
"( 2")
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o2," \
"$gsl_tmp_post"
;;
"( 3")
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o3," \
"$gsl_tmp_post"
;;
*)
continue
;;
esac
done < <(cat -n "$gsl_tmp_post")
}

View File

@ -24,9 +24,9 @@ do
if [[ "$gsl_this_post" ]];then
! [[ "$gsl_post" == "$gsl_this_post" ]] && continue
fi
gsl__get_sum "$gsl_post"
# Post too small
if (( "$gsl_post_size" <= $gsl_post_min_size ));then
gsl__logs_print \
@ -37,7 +37,7 @@ do
"${PWD}/$gsl_post"
continue
fi
# Set DB Post file
gsl_file_db_post="$gsl_dir_db/$gsl_post.db"
gsl__db_get_post_datas
@ -58,24 +58,28 @@ do
gsl_process="Checked"
gsl__all_checkers
;;
make)
gsl_process="Made"
gsl__db_compare_post_hash && continue
case "$gsl_db_post_status" in
Checked)
gsl__all_makers
;;
Made)
gsl__logs_print
"$gsl_log_w" \
"Post" \
"Make" \
"$gsl_post already Converted" \
"$gsl_file_db_posts"
continue
if [[ "$gsl_force_make" ]];then
gsl__all_makers
else
gsl__logs_print \
"$gsl_log_w" \
"Post" \
"Make" \
"$gsl_post already Converted" \
"$gsl_file_db_posts"
continue
fi
;;
esac
;;
@ -88,7 +92,7 @@ done
[[ "$gsl_checker_err" ]] \
&& gsl log -s -e
[[ "$gsl_check_done" ]] \
&& echo "# Check already done"
}

View File

@ -89,6 +89,7 @@ gsl_this_conf_domain=`grep "$1" "$gsl_file_db_domains"`
gsl_dir_domain_tpl="$gsl_this_conf_domain/templates"
gsl_dir_domain_files="$gsl_this_conf_domain/files"
gsl_dir_domain_images="$gsl_this_conf_domain/images"
gsl_dir_domain_listings="$gsl_this_conf_domain/X-tra"
for gsl_new_dir in `set -o posix ; set \
| grep "gsl_dir_domain" \