fix new checkers + URL 200
This commit is contained in:
parent
d7bb4c4a4e
commit
d552f298fd
|
@ -8,6 +8,7 @@ webserver.
|
|||
# Dependancies
|
||||
- bash
|
||||
- coreutils
|
||||
- curl (to check Posts links response)
|
||||
|
||||
|
||||
# GSL: Installation
|
||||
|
|
|
@ -121,12 +121,12 @@ 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__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 || exit 1
|
||||
gsl__check_source "$gsl_dir_scripts/gsl__db_manager" || exit 1
|
||||
|
||||
case "$2" in
|
||||
|
|
|
@ -8,6 +8,7 @@ webserver.
|
|||
# Dependancies
|
||||
- bash
|
||||
- coreutils
|
||||
- curl (to check Posts links response)
|
||||
|
||||
|
||||
# GSL: Installation
|
||||
|
|
|
@ -11,8 +11,10 @@ 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" ]] \
|
||||
&& touch "$gsl_file_auth_ndd"
|
||||
[[ -f "$gsl_file_auth_ndd" ]] \
|
||||
&& return
|
||||
|
||||
touch "$gsl_file_auth_ndd"
|
||||
}
|
||||
|
||||
#=======================================================================
|
||||
|
@ -21,12 +23,15 @@ gsl_file_auth_ndd="$gsl_save_dir_ndd/$gsl_filename_auth"
|
|||
gsl__authors_list() {
|
||||
gsl__authors_check
|
||||
|
||||
[[ -z `grep '[^[:space:]]' "$gsl_file_auth_ndd"` ]] \
|
||||
&& echo "! No Registred authors yet." \
|
||||
! [[ -z `grep '[^[:space:]]' "$gsl_file_auth_ndd"` ]] \
|
||||
&& gsl_authors=true \
|
||||
&& return
|
||||
|
||||
echo "! No Registred authors yet..."
|
||||
|
||||
case "$1" in
|
||||
check)
|
||||
[[ $gsl_authors ]] && return
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -36,17 +36,13 @@ gsl__logs_show() {
|
|||
[[ "$gsl_logs_err" ]] \
|
||||
&& gsl_logs_filter="$gsl_log_e"
|
||||
|
||||
[[ "$gsl_logs_last_session" ]] \
|
||||
&& gsl_log_show_session="Last session" \
|
||||
|| gsl_log_show_session="All"
|
||||
|
||||
# Last session show or not
|
||||
if [[ "$gsl_logs_last_session" ]];then
|
||||
gsl_log_start_line=`
|
||||
grep -n "Starting" "$gsl_file_logs" \
|
||||
| tail -1 \
|
||||
| awk -F: '{print $1}'`
|
||||
|
||||
echo
|
||||
awk -v sl="$gsl_log_start_line" \
|
||||
'NR >= sl' \
|
||||
"$gsl_file_logs" \
|
||||
|
|
|
@ -11,11 +11,11 @@ gsl__post_all_checkers() {
|
|||
clear
|
||||
unset gsl_check_done
|
||||
|
||||
echo -n ": Searching for needed Headers..."
|
||||
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"
|
||||
echo -ne "\r\033[2K: Searching for PARAGRAPHS"
|
||||
gsl__post_check_paragraphs
|
||||
echo -ne "\r\033[2K: Searching for Content MARKERS..."
|
||||
gsl__post_check_markers
|
||||
|
@ -23,10 +23,15 @@ echo -ne "\r\033[2K: Searching for BLOCKQUOTEs..."
|
|||
gsl__post_check_blockquote
|
||||
echo -ne "\r\033[2K: Searching for ABBRs..."
|
||||
gsl__post_check_abbr
|
||||
echo -ne "\r\033[2K: Searching for LINKs.."
|
||||
echo -ne "\r\033[2K: Searching for LINKs..."
|
||||
gsl__post_check_links
|
||||
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"
|
||||
|
||||
# End of checkers : show logs for war and err
|
||||
[[ "$gsl_checker_war" ]] \
|
||||
&& gsl log -s -w
|
||||
|
@ -319,9 +324,11 @@ gsl__post_check_abbr() {
|
|||
gsl_post_stat_abbr=0
|
||||
while read -r "gsl_header_content_line"
|
||||
do
|
||||
|
||||
# Get & Check HEADER CONTENT
|
||||
gsl__get_header_fields "$gsl_marker_abbr"
|
||||
gsl__check_header_fields "Post" "ABBR" "$gsl_log_act_abbr" || continue
|
||||
gsl__check_header_fields "Post" "ABBR" "$gsl_log_act_abbr" \
|
||||
|| continue
|
||||
|
||||
# Check POST CONTENT
|
||||
[[ `gsl__get_content_line \
|
||||
|
@ -338,6 +345,7 @@ do
|
|||
"Missing Content: $gsl_post_header_field_1" \
|
||||
"${PWD}/$gsl_post"
|
||||
gsl_checker_err=true
|
||||
|
||||
done < <(gsl__get_header "$gsl_marker_abbr" "$gsl_post")
|
||||
|
||||
gsl__logs_print \
|
||||
|
@ -357,29 +365,28 @@ 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" || continue
|
||||
gsl__check_header_fields "Post" "Link" "$gsl_log_act_link" \
|
||||
|| continue
|
||||
|
||||
# Not ALT TEXT ?
|
||||
if ! [[ "$gsl_post_header_field_3" ]];then
|
||||
gsl__logs_print \
|
||||
"$gsl_log_w" \
|
||||
"Post" \
|
||||
"Link" \
|
||||
"Line:$gsl_post_header_line_nbr > No ALT TEXT ?" \
|
||||
"${PWD}/$gsl_post"
|
||||
gsl_checker_war=true
|
||||
fi
|
||||
gsl__check_header_field3 "Post" "Link"
|
||||
|
||||
# Find if ref is in CONTENT
|
||||
if [[ `gsl__get_content_finder \
|
||||
-o "$gsl_mo_link" \
|
||||
-b "$gsl_post_header_field_1" \
|
||||
-c "$gsl_mc_link" \
|
||||
-f "$gsl_post" \
|
||||
| tail -1 ` ]];then
|
||||
(( gsl_post_stat_link ++ ))
|
||||
continue
|
||||
fi
|
||||
[[ `gsl__get_content_with_markers "$gsl_mo_link" "$gsl_mc_link"` ]] \
|
||||
&& gsl_post_stat_link=$(( $gsl_post_stat_link + 1 )) \
|
||||
&& continue
|
||||
|
||||
# Check URL
|
||||
(( `curl -o /dev/null --silent --head --write-out \
|
||||
'%{http_code}' \
|
||||
"$gsl_post_header_field_2"` == 200 )) \
|
||||
&& continue \
|
||||
|| gsl__logs_print \
|
||||
"$gsl_log_e" \
|
||||
"Post" \
|
||||
"Link" \
|
||||
"URL offline: $gsl_post_header_field_2" \
|
||||
"${PWD}/$gsl_post"
|
||||
|
||||
# Missing CONTENT
|
||||
gsl__logs_print \
|
||||
|
@ -392,3 +399,89 @@ do
|
|||
|
||||
done < <(gsl__get_header "$gsl_marker_link" "$gsl_post")
|
||||
}
|
||||
|
||||
#=======================================================================
|
||||
# Check Post for FILES HEADER + Content
|
||||
#=======================================================================
|
||||
gsl__post_check_files() {
|
||||
gsl_post_stat_file=0
|
||||
while read -r "gsl_header_content_line"
|
||||
do
|
||||
|
||||
# Get & Check Header CONTENT
|
||||
gsl__get_header_fields "$gsl_marker_file"
|
||||
gsl__check_header_fields "Post" "File" "$gsl_log_act_file" \
|
||||
|| continue
|
||||
|
||||
# Not ALT TEXT ?
|
||||
gsl__check_header_field3 "Post" "File"
|
||||
|
||||
# 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" \
|
||||
"File" \
|
||||
"Missing Content: <_${gsl_post_header_field_1}_>" \
|
||||
"${PWD}/$gsl_post"
|
||||
gsl_checker_err=true
|
||||
|
||||
done < <(gsl__get_header "$gsl_marker_file" "$gsl_post")
|
||||
}
|
||||
|
||||
#=======================================================================
|
||||
# Check Post for IMAGES HEADER + Content
|
||||
#=======================================================================
|
||||
gsl__post_check_images() {
|
||||
gsl_post_stat_image=0
|
||||
while read -r "gsl_header_content_line"
|
||||
do
|
||||
|
||||
# Get & Check Header CONTENT
|
||||
gsl__get_header_fields "$gsl_marker_image"
|
||||
gsl__check_header_fields "Post" "Image" "$gsl_log_act_image" \
|
||||
|| continue
|
||||
|
||||
# Not ALT TEXT ?
|
||||
gsl__check_header_field3 "Post" "Image"
|
||||
|
||||
# Find if ref is in CONTENT
|
||||
[[ `gsl__get_content_line \
|
||||
"$gsl_mark_image : $gsl_post_header_field_1" \
|
||||
"$gsl_post"` ]] \
|
||||
&& 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}" \
|
||||
"${PWD}/$gsl_post"
|
||||
gsl_checker_err=true
|
||||
|
||||
done < <(gsl__get_header "$gsl_marker_image" "$gsl_post")
|
||||
}
|
||||
|
|
|
@ -10,8 +10,10 @@
|
|||
gsl__check_nbr_posts() {
|
||||
gsl_nbr_posts=`ls -1 *.gsl 2>/dev/null | wc -l`
|
||||
|
||||
(( $gsl_nbr_posts == 0 )) \
|
||||
&& echo "! No Posts found with .gsl extension"
|
||||
(( $gsl_nbr_posts >= 1 )) \
|
||||
&& return
|
||||
|
||||
echo "! No Posts found with .gsl extension"
|
||||
}
|
||||
|
||||
#=======================================================================
|
||||
|
@ -138,6 +140,19 @@ awk -v line="$gsl_post_begin" -v s="$1" \
|
|||
"$2" || return
|
||||
}
|
||||
|
||||
#=======================================================================
|
||||
# Check CONTENT Post with markers... $1: Open Marker | $2: Close Marker
|
||||
#=======================================================================
|
||||
gsl__get_content_with_markers() {
|
||||
gsl__get_content_finder \
|
||||
-o "$1" \
|
||||
-b "$gsl_post_header_field_1" \
|
||||
-c "$2" \
|
||||
-f "$gsl_post" \
|
||||
| tail -1 \
|
||||
|| return
|
||||
}
|
||||
|
||||
#=======================================================================
|
||||
# Get CONTENT with marks | ! find from ONE line content
|
||||
#=======================================================================
|
||||
|
@ -182,7 +197,7 @@ gsl__get_line "$1$gsl_post_header_field_1" "$gsl_post"`
|
|||
}
|
||||
|
||||
#=======================================================================
|
||||
# Get Fields and line nbr from header from marker
|
||||
# Check NEEDED Fields from HEADER
|
||||
#=======================================================================
|
||||
gsl__check_header_fields() {
|
||||
if ! [[ "$gsl_post_header_field_1" ]] || \
|
||||
|
@ -198,3 +213,31 @@ if ! [[ "$gsl_post_header_field_1" ]] || \
|
|||
return
|
||||
fi
|
||||
}
|
||||
|
||||
#=======================================================================
|
||||
# Check OPTIONAL Field 3 from HEADER
|
||||
#=======================================================================
|
||||
gsl__check_header_field3() {
|
||||
if ! [[ "$gsl_post_header_field_3" ]];then
|
||||
case "$2" in
|
||||
Image)
|
||||
gsl__logs_print \
|
||||
"$gsl_log_e" \
|
||||
"$1" \
|
||||
"$2" \
|
||||
"Line:$gsl_post_header_line_nbr > No ALT TEXT ?" \
|
||||
"${PWD}/$gsl_post"
|
||||
gsl_checker_err=true
|
||||
;;
|
||||
*)
|
||||
gsl__logs_print \
|
||||
"$gsl_log_w" \
|
||||
"$1" \
|
||||
"$2" \
|
||||
"Line:$gsl_post_header_line_nbr > No ALT TEXT ?" \
|
||||
"${PWD}/$gsl_post"
|
||||
gsl_checker_war=true
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -78,16 +78,36 @@ if [[ "$gsl_find_domain" ]];then
|
|||
<<< $gsl_find_domain`
|
||||
|
||||
gsl_find_domain=${gsl_find_domain,,}
|
||||
gsl__check_domain "$gsl_find_domain"
|
||||
gsl__check_domain "$gsl_find_domain" || return
|
||||
fi
|
||||
}
|
||||
|
||||
#=======================================================================
|
||||
# Check and set domain from db
|
||||
# Check and set domain from DB
|
||||
#=======================================================================
|
||||
gsl__check_domain() {
|
||||
gsl_this_conf_domain=`grep "$1" "$gsl_file_db_domains"`
|
||||
|
||||
! [[ "$gsl_this_conf_domain" ]] \
|
||||
&& echo "! Domain Not found: $1"
|
||||
&& echo "! Domain Not found: $1" \
|
||||
&& return
|
||||
|
||||
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"
|
||||
|
||||
for gsl_new_dir in `set -o posix ; set \
|
||||
| grep "gsl_dir_domain" \
|
||||
| awk -F= '{print $2}'`
|
||||
do
|
||||
if ! [[ -d "$gsl_new_dir" ]];then
|
||||
mkdir -p "$gsl_new_dir" 2>/dev/null && \
|
||||
gsl__logs_print \
|
||||
"$gsl_log_i" \
|
||||
"Folder" \
|
||||
"Init..." \
|
||||
"Created" \
|
||||
"$gsl_new_dir"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue