Add Make List; Pin Listing;updates,fixes

This commit is contained in:
Cyrille L 2022-03-08 17:53:40 +01:00
parent df77897e52
commit c477845d0c
11 changed files with 368 additions and 161 deletions

View File

@ -1,5 +1,4 @@
# GSL: Statique Littérateur # GSL: Statique Littérateur
------------------------------------------------------------------------ ------------------------------------------------------------------------
GSL is a multiple blogs/websites generator based on their domain, GSL is a multiple blogs/websites generator based on their domain,
@ -16,7 +15,6 @@ can easily get, in your webserver.
# GSL: Installation # GSL: Installation
------------------------------------------------------------------------ ------------------------------------------------------------------------
In your System / In your System /
``` ```
@ -109,7 +107,6 @@ You can select a specific post, with autocompletion to check and make
only that specified one. only that specified one.
# Create a Templates # Create a Templates
------------------------------------------------------------------------ ------------------------------------------------------------------------
You will have to create some CSS (styles.css) in your /DOMAIN/templates/ You will have to create some CSS (styles.css) in your /DOMAIN/templates/
@ -117,7 +114,6 @@ You will have to create some CSS (styles.css) in your /DOMAIN/templates/
- GLOBAL: /var/lib/gsl/domains/DOMAIN/templates/ - GLOBAL: /var/lib/gsl/domains/DOMAIN/templates/
# How to Write a Post # How to Write a Post
------------------------------------------------------------------------ ------------------------------------------------------------------------
Post has 2 sections : Before and After #1. #1 is the FIRST Title of your Post has 2 sections : Before and After #1. #1 is the FIRST Title of your
@ -205,7 +201,7 @@ this border**line** content
# Inline-code (¤ = alt-gr + $ on FR keyboard) # Inline-code (¤ = alt-gr + $ on FR keyboard)
¤push()¤ ¤push()¤
# Simple Blockquote # Simple Blockquote: Use 3 "-"
--- ---
( (
A simple great quote A simple great quote
@ -230,4 +226,19 @@ world a worse place
# For advanced blockquotes, you can also add, if known: # For advanced blockquotes, you can also add, if known:
_year: 2021 _year: 2021
_book: Esperanza 64 _book: Esperanza 64
# Create Lists
Use = to create an item. You can use infinite sub-items, but each Item
of a list MUST be on the same Line
(
Let's start a list
= Item 1 is *great*
== sub-item 1
== sub-item 2
=== sub-sub-item 1 of sub-item 2
== sub-item 3
= Item 2
** sub-item 1 of Item 2
This list is ended
)
``` ```

View File

@ -132,4 +132,3 @@ gsl_d=(\, \. \? \% \# \- \: \^ \/ \_ \| )
# Post-listing # Post-listing
gsl_list_max_posts=5 gsl_list_max_posts=5
gsl_list_lines_per_post=5

View File

@ -1,33 +1,56 @@
#!/bin/bash #!/bin/bash
# file: gsl
# Folder: /usr/local/bin
# By echolib
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#=======================================================================
# Tool: Check needed file and sourcee if asked
#=======================================================================
gsl__if_file() {
if ! [[ -f "$1" ]];then
echo "! Missing file: $1"
exit 1
fi
case "$2" in
source)
source "$1" || exit 1
;;
read)
cat "$1"
;;
post)
gsl_this_post="$1"
;;
esac
}
#======================================================================= #=======================================================================
# Checking Dependancies # Checking Dependancies
#======================================================================= #=======================================================================
# Get Tools # Get Tools
! [[ -f "/var/lib/gsl/scripts/gsl__tools" ]] \ gsl__if_file "/var/lib/gsl/scripts/gsl__tools" source
&& echo "! Missing file: /var/lib/gsl/scripts/gsl__tools" \
&& return
source "/var/lib/gsl/scripts/gsl__tools"
# Get conf # Get conf
gsl__check_source "/etc/gsl/gsl.conf" || exit 1 gsl__if_file "/etc/gsl/gsl.conf" source
# Get Logs Manager # Get Logs Manager
gsl__check_source "$gsl_dir_scripts/gsl__log_manager" || exit 1 gsl__if_file "$gsl_dir_scripts/gsl__log_manager" source
# Check/Create Files and Folders # Check/Create Files and Folders
gsl__create_ff gsl__create_ff
gsl__find_domain gsl__find_domain
gsl__check_source "$gsl_dir_scripts/gsl__auth_manager" || exit 1 gsl__if_file "$gsl_dir_scripts/gsl__auth_manager" source
gsl__authors_list check || exit 1 gsl__authors_list check || exit 1
gsl__check_source "$gsl_dir_scripts/gsl__new_website" || exit 1 gsl__if_file "$gsl_dir_scripts/gsl__new_website" source
gsl__check_source "$gsl_dir_scripts/gsl__post_checkers" || exit 1 gsl__if_file "$gsl_dir_scripts/gsl__post_checkers" source
gsl__check_source "$gsl_dir_scripts/gsl__post_manager" || exit 1 gsl__if_file "$gsl_dir_scripts/gsl__post_manager" source
gsl__check_source "$gsl_dir_scripts/gsl__db_manager" || exit 1 gsl__if_file "$gsl_dir_scripts/gsl__db_manager" source
gsl__check_source "$gsl_dir_scripts/gsl__post_makers" || exit 1 gsl__if_file "$gsl_dir_scripts/gsl__post_makers" source
gsl__check_source "$gsl_dir_scripts/gsl__page_creator" || exit 1 gsl__if_file "$gsl_dir_scripts/gsl__page_creator" source
gsl__check_source "$gsl_dir_scripts/gsl__do_commons" || exit 1 gsl__if_file "$gsl_dir_scripts/gsl__do_commons" source
#======================================================================= #=======================================================================
# Main # Main
@ -132,17 +155,14 @@ case "$1" in
check|-C) check|-C)
gsl__check_nbr_posts gsl__check_nbr_posts
gsl_process="chk"
case "$2" in case "$2" in
-F) -F)
gsl_force_check=true gsl_force_check=true
if [[ "$3" ]];then [[ "$3" ]] && gsl__if_file "$3" post
gsl__check_opt_post "$3"
fi
;; ;;
*) *)
if [[ "$2" ]];then [[ "$2" ]] && gsl__if_file "$2" post
gsl__check_opt_post "$2"
fi
;; ;;
esac esac
@ -165,17 +185,15 @@ case "$1" in
make|-M) make|-M)
gsl__check_nbr_posts gsl__check_nbr_posts
gsl_process="wip"
gsl_post_list="Add"
case "$2" in case "$2" in
-F) -F)
gsl_force_make=true gsl_force_make=true
if [[ "$3" ]];then [[ "$3" ]] && gsl__if_file "$3" post
gsl__check_opt_post "$3"
fi
;; ;;
*) *)
if [[ "$2" ]];then [[ "$2" ]] && gsl__if_file "$2" post
gsl__check_opt_post "$2"
fi
;; ;;
esac esac
@ -197,11 +215,24 @@ case "$1" in
;; ;;
post-list) post-list)
if [[ "$2" ]];then case "$2" in
gsl__check_opt_post "$2" add)
gsl_post_list="Add"
;;
pin)
gsl_post_list="Pin"
;;
*)
echo "! Bad Argument: $2"
exit 1
;;
esac
if [[ "$3" ]];then
gsl__if_file "$3" post
else else
echo "! Select a Post to add to list" echo "! Select a Post to add to list"
exit exit 1
fi fi
gsl__check_nbr_posts gsl__check_nbr_posts
@ -209,7 +240,7 @@ case "$1" in
"$gsl_log_i" \ "$gsl_log_i" \
"Starting" \ "Starting" \
"Process" \ "Process" \
"Post-List ; Add $2 from domain $gsl_find_domain" \ "Post-List ; $gsl_post_list $3 from domain $gsl_find_domain" \
"$gsl_dir_domain_tpl/last-posts-list.html" "$gsl_dir_domain_tpl/last-posts-list.html"
gsl__loop_posts post-list gsl__loop_posts post-list
@ -218,35 +249,29 @@ case "$1" in
"$gsl_log_i" \ "$gsl_log_i" \
"Stopping" \ "Stopping" \
"Process" \ "Process" \
"Post-List ; Add $2 from domain $gsl_find_domain" \ "Post-List ; $gsl_post_list $3 from domain $gsl_find_domain" \
"$gsl_dir_domain_tpl/last-posts-list.html" "$gsl_dir_domain_tpl/last-posts-list.html"
;; ;;
readme) readme)
gsl__if_file "/var/lib/gsl/README.md"
clear clear
cat /var/lib/gsl/README.md gsl__if_file "/var/lib/gsl/README.md" read
;; ;;
help|--help|-h) help|--help|-h)
gsl__if_file "$gsl_dir_helps/gsl_help"
clear clear
case "$2" in case "$2" in
"") "")
cat "$gsl_dir_helps/gsl_help" gsl__if_file "$gsl_dir_helps/gsl_help" read
;; ;;
new) new)
gsl__if_file "$gsl_dir_helps/gsl_infos_new_website" gsl__if_file "$gsl_dir_helps/gsl_infos_new_website" read
cat "$gsl_dir_helps/gsl_infos_new_website"
;; ;;
install) install)
gsl__if_file "$gsl_dir_helps/gsl_help_install" gsl__if_file "$gsl_dir_helps/gsl_help_install" read
cat "$gsl_dir_helps/gsl_help_install"
;; ;;
write|-w) write|-w)
gsl__if_file "$gsl_dir_helps/gsl_help_write_post" gsl__if_file "$gsl_dir_helps/gsl_help_write_post" read
cat "$gsl_dir_helps/gsl_help_write_post"
;; ;;
esac esac
;; ;;

View File

@ -201,7 +201,7 @@ this border**line** content
# Inline-code (¤ = alt-gr + $ on FR keyboard) # Inline-code (¤ = alt-gr + $ on FR keyboard)
¤push()¤ ¤push()¤
# Simple Blockquote # Simple Blockquote: Use 3 "-"
--- ---
( (
A simple great quote A simple great quote
@ -226,4 +226,19 @@ world a worse place
# For advanced blockquotes, you can also add, if known: # For advanced blockquotes, you can also add, if known:
_year: 2021 _year: 2021
_book: Esperanza 64 _book: Esperanza 64
# Create Lists
Use = to create an item. You can use infinite sub-items, but each Item
of a list MUST be on the same Line
(
Let's start a list
= Item 1 is *great*
== sub-item 1
== sub-item 2
=== sub-sub-item 1 of sub-item 2
== sub-item 3
= Item 2
** sub-item 1 of Item 2
This list is ended
)
``` ```

View File

@ -26,6 +26,8 @@ $ gsl [ARG]
make | -M [OPT] [FILE] : Convert Posts from PWD folder or [FILE] make | -M [OPT] [FILE] : Convert Posts from PWD folder or [FILE]
to HTML file in server to HTML file in server
post-list [FILE] : Add back post from [FILE] to Last-Posts List post-list [OPT] [FILE] : Add post again from [FILE] to Last-Posts List
(When converting new post, it will be added) (When converting new post, it will be added)
Pin : Set Post from [FILE] to first in Last-Posts List
Add : Add Post from [FILE] to last in Last-Posts List

View File

@ -86,7 +86,7 @@ this border**line** content
# Inline-code (¤ = alt-gr + $ on FR keyboard) # Inline-code (¤ = alt-gr + $ on FR keyboard)
¤push()¤ ¤push()¤
# Simple Blockquote # Simple Blockquote: Use 3 "-"
--- ---
( (
A simple great quote A simple great quote
@ -111,4 +111,19 @@ world a worse place
# For advanced blockquotes, you can also add, if known: # For advanced blockquotes, you can also add, if known:
_year: 2021 _year: 2021
_book: Esperanza 64 _book: Esperanza 64
# Create Lists
Use = to create an item. You can use infinite sub-items, but each Item
of a list MUST be on the same Line
(
Let's start a list
= Item 1 is *great*
== sub-item 1
== sub-item 2
=== sub-sub-item 1 of sub-item 2
== sub-item 3
= Item 2
** sub-item 1 of Item 2
This list is ended
)
``` ```

View File

@ -26,14 +26,20 @@ if [[ -f "$gsl_file_db_post" ]];then
else else
gsl__logs_print \ case "$gsl_process" in
chk)
true
;;
*)
gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"DB" \ "DB" \
"Post" \ "Post" \
"$gsl_post missing. Check it first" \ "Missing from $gsl_post. Check it first" \
"$gsl_file_db_post" "$gsl_file_db_post"
gsl_checker_war=true gsl_checker_war=true
;;
esac
fi fi
} }
@ -43,21 +49,37 @@ fi
gsl__db_compare_post_hash() { gsl__db_compare_post_hash() {
gsl_checker_war=true gsl_checker_war=true
if ! (( $gsl_post_hash == $gsl_db_post_hash ));then if (( $gsl_post_hash == $gsl_db_post_hash ));then
gsl__logs_print \
"$gsl_log_w" \
"Post" \
"Hash" \
"$gsl_post Changed ($gsl_post_hash)" \
"${PWD}/$gsl_post"
gsl_post_new_hash=true
else
gsl__logs_print \ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"Post" \ "Post" \
"Hash" \ "Hash" \
"$gsl_post checked with hash:$gsl_db_post_hash " \ "$gsl_post checked with hash:$gsl_db_post_hash " \
"${PWD}/$gsl_post" "${PWD}/$gsl_post"
else
gsl_post_new_hash=true
case "$gsl_db_post_hash" in
0)
gsl__logs_print \
"$gsl_log_w" \
"Post" \
"New" \
"$gsl_post not yet checked" \
"${PWD}/$gsl_post"
;;
*)
gsl__logs_print \
"$gsl_log_w" \
"Post" \
"Hash" \
"$gsl_post Changed ($gsl_post_hash)" \
"${PWD}/$gsl_post"
;;
esac
fi fi
} }

View File

@ -44,9 +44,6 @@ done
gsl__page_prepare_datas() { gsl__page_prepare_datas() {
#echo "D> $gsl_this_conf_domain" #echo "D> $gsl_this_conf_domain"
# Source config website (DATAS)
source "$gsl_this_conf_domain/$gsl_find_domain.conf"
# Check for Files & Folders in server # Check for Files & Folders in server
gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip" gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip"
@ -86,41 +83,55 @@ fi
#====================================================================== #======================================================================
gsl__page_create_listing() { gsl__page_create_listing() {
# Check if Post is in list ; Status Made # Check if Post is in list ; Status Made
case "$1" in gsl_checker_war=true
selected) gsl_listing_file="$gsl_dir_domain_listings/$gsl_post.list"
true
;;
*) if [[ `ls -1 "$gsl_listing_file"* 2>/dev/null` ]];then
case "$gsl_db_post_status" in
wip|www)
gsl__logs_print \ gsl__logs_print \
"$gsl_log_i" \ "$gsl_log_w" \
"Post" \ "Post" \
"Make" \ "List" \
"$gsl_post already added to Latest listings" \ "$gsl_post_list $gsl_post already added to Latests" \
"$gsl_file_db_posts" "$gsl_dir_domain_listings/"
return return
fi
case "$gsl_post_list" in
Pin)
gsl__page_create_listing_file "$gsl_listing_file.1"
;; ;;
esac Add)
# search for last listing number
gsl_listing_last=`
ls -1 *"$gsl_dir_domain_listings/"*".list."* \
| tail -1 2>/dev/null`
# Get Last listing number
! [[ $gsl_listing_last ]] \
&& gsl_listing_last_n=0 \
|| gsl_listing_last_n=${gsl_listing_last: -1}
# Set last listing number for this post
(( $gsl_listing_last_n <= $(( gsl_list_max_posts - 1)) )) \
&& gsl_listing_last_n=$(( $gsl_listing_last_n + 1 ))
gsl__page_create_listing_file \
"$gsl_listing_file.$gsl_listing_last_n"
;; ;;
esac esac
touch "$gsl_dir_domain_tpl/last-posts-list.html" cat "$gsl_dir_domain_listings/"*.list.* \
> "$gsl_dir_domain_tpl/last-posts-list.html" \
&& gsl__logs_print \
"$gsl_log_w" \
"Post" \
"List" \
"Create Latest Listing (Merged .list.*)"\
"$gsl_dir_domain_tpl/last-post-list.html"
}
gsl_list_max_lines=$(( gsl_list_max_posts * gsl_list_lines_per_post)) gsl__page_create_listing_file() {
gsl_list_cur_lines=` cat << EOPostSide > "$1"
cat "$gsl_dir_domain_tpl/last-posts-list.html" \
| wc -l`
if (( $((gsl_list_cur_lines )) >= $gsl_list_max_lines ));then
for i in `seq 1 $gsl_list_lines_per_post`
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> <li>
<span class="${gsl_site_css}_list-post-title">$gsl_header_title</span> <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-metas">Le $gsl_header_date par $gsl_header_author<div>
@ -131,10 +142,9 @@ EOPostSide
gsl__logs_print \ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"Post" \ "Post" \
"Make" \ "List" \
"$gsl_post added to Latest listings" \ "$gsl_post_list $gsl_post to Latests"\
"$gsl_dir_domain_tpl/last-posts-list.html" "$1"
gsl_checker_war=true
} }
#---------------------------------------------------------------------- #----------------------------------------------------------------------

View File

@ -29,6 +29,7 @@ gsl__do_italics "make" "$gsl_tmp_post" # First
gsl__do_header "make" "$gsl_marker_link" "$gsl_post" gsl__do_header "make" "$gsl_marker_link" "$gsl_post"
gsl__do_header "make" "$gsl_marker_abbr" "$gsl_post" gsl__do_header "make" "$gsl_marker_abbr" "$gsl_post"
gsl__do_strongs_bolds "make" "$gsl_tmp_post" gsl__do_strongs_bolds "make" "$gsl_tmp_post"
gsl__make_list
gsl__do_icode "make" "$gsl_tmp_post" gsl__do_icode "make" "$gsl_tmp_post"
gsl__make_titles gsl__make_titles
gsl_ct=0 && gsl__make_titles_div_open gsl_ct=0 && gsl__make_titles_div_open
@ -77,6 +78,135 @@ awk -v s="$1" \
# Converters # Converters
# --------------------------------- # ---------------------------------
#======================================================================= #=======================================================================
#----------------------------------------------------------------------
#======================================================================
# Convert List.Get first/last line item / repeat till no more mark
#======================================================================
gsl__make_list() {
! [[ `awk -v m="$gsl_mark_list" \
'$1 == m {print $1;exit}' \
"$gsl_tmp_post"` ]] \
&& return
gsl_last_line=`cat $gsl_tmp_post | wc -l`
# Get block lists by line numbers From Content
while read -r "gsl_line" "gsl_content"
do
case "$gsl_content" in
"$gsl_mark_list"*)
! [[ $gsl_list ]] \
&& gsl_list=true \
&& gsl_list_o=$gsl_line \
&& continue
[[ $gsl_list ]] && (( $gsl_line == $gsl_last_line )) \
&& gsl_list_c=$gsl_line \
&& gsl__make_list_get_block \
&& break
;;
""|*)
[[ "$gsl_list" ]] \
&& gsl_list_c=$(( gsl_line - 1 )) \
&& unset gsl_list \
&& gsl__make_list_get_block \
&& break
;;
esac
done < <(cat -n "$gsl_tmp_post")
}
#======================================================================
# Convert List. tmp file block list. replace mark with number
#======================================================================
gsl__make_list_get_block() {
echo -ne "\r\033[2K: Converting Block-List... $gsl_list_o > $gsl_list_c"
# Create tmp file with this block-list and marks converted
gsl_file_block_list=`mktemp`
while read -r "mark" "content"
do
echo "${#mark} $content" >> "$gsl_file_block_list"
done < <(awk -v o="$gsl_list_o" -v c="$gsl_list_c" \
'NR >= o && NR <= c' \
"$gsl_tmp_post")
gsl__make_list_convert
# No more needed
unset gsl_list_o gsl_list_c
rm -f "$gsl_file_block_list"
}
#======================================================================
# Convert List. tmp HTML file.
#======================================================================
gsl__make_list_convert() {
# Get previeous line mark number
gsl__make_list_get_prev_mark() {
pm=`
awk -v pm="$(( $ln - 1))" \
'NR == pm {print $1}' \
"$gsl_file_block_list"`
! [[ $pm ]] && pm=0
}
# Create tmp file with HTML block-list
gsl_HTML_list=`mktemp`
#ln: line number ; mn: mark number
while read -r "ln" "mn" "content"
do
gsl__make_list_get_prev_mark
gsl_diff_pm_mn=$(( mn - pm ))
if (( $gsl_diff_pm_mn == 0 ));then
printf "%s%s\n" \
"" \
"<li>$content</li>" \
>> "$gsl_HTML_list"
elif (( $gsl_diff_pm_mn > 0 ));then
printf "%s%s\n" \
"" \
"<ul>" \
>> "$gsl_HTML_list"
printf "%s%s\n" \
"" \
"<li>$content</li>" \
>> "$gsl_HTML_list"
elif (( $gsl_diff_pm_mn < 0 ));then
printf '</ul>%.s\n' {1..eval $n} \
>> "$gsl_HTML_list"
printf "%s%s\n" \
"" \
"<li>$content</li>" \
>> "$gsl_HTML_list"
fi
done < <(cat -n "$gsl_file_block_list")
echo "</ul>" >> "$gsl_HTML_list"
# Remove useless list in tmp_post
gsl_list_rm_tl=$(( $gsl_list_c - $gsl_list_o ))
for rml in `seq 0 $gsl_list_rm_tl`
do
sed -i "${gsl_list_o}d" "$gsl_tmp_post"
done
# Insert new HTML file list in tmp_post
gsl_list_line_i=$(( gsl_list_o - 1))
sed -i "${gsl_list_line_i}r $gsl_HTML_list" "$gsl_tmp_post"
rm -f "$gsl_HTML_list" # No more needed HTML tmp file list
gsl__make_list
}
#----------------------------------------------------------------------
#====================================================================== #======================================================================
# Replace gsl_mark_fcode # Replace gsl_mark_fcode
#====================================================================== #======================================================================

View File

@ -46,7 +46,6 @@ do
# From COMMAND [OPT] # From COMMAND [OPT]
case "$1" in case "$1" in
check) check)
gsl_process="chk"
if ! [[ "$gsl_force_check" ]];then if ! [[ "$gsl_force_check" ]];then
! [[ "$gsl_post_new_hash" ]] && continue ! [[ "$gsl_post_new_hash" ]] && continue
fi fi
@ -61,7 +60,6 @@ do
;; ;;
make) make)
gsl_process="wip"
gsl__post_begin gsl__post_begin
gsl__get_needed_headers gsl__get_needed_headers
gsl__page_prepare_datas gsl__page_prepare_datas
@ -73,11 +71,6 @@ do
;; ;;
wip) wip)
# Should not be used...
[[ "$gsl_force_make" ]] \
&& gsl__all_makers \
&& continue
if [[ "$gsl_post_new_hash" ]];then if [[ "$gsl_post_new_hash" ]];then
rm -f "$gsl_srv_wip_page" && \ rm -f "$gsl_srv_wip_page" && \
gsl__logs_print \ gsl__logs_print \
@ -94,6 +87,11 @@ do
"file ; changes in $gsl_post" \ "file ; changes in $gsl_post" \
"$gsl_file_db_post" "$gsl_file_db_post"
else else
# Should not be used...
[[ "$gsl_force_make" ]] \
&& gsl__all_makers \
&& continue
gsl__logs_print \ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"Post" \ "Post" \
@ -114,7 +112,7 @@ do
gsl__post_begin gsl__post_begin
gsl__get_needed_headers gsl__get_needed_headers
gsl__page_prepare_datas gsl__page_prepare_datas
gsl__page_create_listing selected gsl__page_create_listing
;; ;;
*) *)
gsl__logs_print \ gsl__logs_print \
@ -183,7 +181,7 @@ awk -v l="$gsl_post_begin" \
gsl__post_begin() { gsl__post_begin() {
gsl_post_begin=` gsl_post_begin=`
grep -n "#1" $gsl_post \ awk -v m="#1" \
| head -1 \ '$1 == m {print NR;exit}' \
| awk -F: '{print $1}'` "$gsl_post"`
} }

View File

@ -4,28 +4,6 @@
# By echolib # By echolib
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#=======================================================================
# Tool: Source if found
#=======================================================================
gsl__check_source() {
if [[ -f "$1" ]];then
source "$1"
else
echo "! Missing file: $1"
exit 1
fi
}
#=======================================================================
# Tool: Check needed file
#=======================================================================
gsl__if_file() {
if ! [[ -f "$1" ]];then
echo "! Missing $1"
exit 1
fi
}
#======================================================================= #=======================================================================
# Check Needed Folders, and create needed files # Check Needed Folders, and create needed files
#======================================================================= #=======================================================================
@ -45,7 +23,7 @@ done
for gsl_file in "$gsl_file_logs" \ for gsl_file in "$gsl_file_logs" \
"$gsl_file_db_domains" "$gsl_file_db_domains"
do do
gsl__if_file "$gsl_file" && touch "$gsl_file" ! [[ -f "$gsl_file" ]] && touch "$gsl_file"
done done
} }
@ -106,6 +84,8 @@ do
"$gsl_new_dir" "$gsl_new_dir"
fi fi
done done
gsl__if_file "$gsl_this_conf_domain/$gsl_find_domain.conf" source
} }
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
@ -124,7 +104,7 @@ gsl_post_size=`awk '{print $2}' <<< "$gsl_post_sum"`
} }
#======================================================================= #=======================================================================
# Get line nbr from Post... $1: TERM | $2: File # Get line nbr from TERM in FIle... $1: TERM | $2: File
#======================================================================= #=======================================================================
gsl__get_line() { gsl__get_line() {
awk -v s="$1" \ awk -v s="$1" \