2022-02-17 17:21:35 +01:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
# file: gsl__post_makers
|
|
|
|
|
# Folder: /var/lib/gsl/scripts
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# By echolib (XMPP: im@echolib.re)
|
2022-02-17 17:21:35 +01:00
|
|
|
|
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
2022-03-05 18:06:48 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
# ---------------
|
|
|
|
|
# SIDEBAR Section
|
|
|
|
|
# ---------------
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
#======================================================================
|
|
|
|
|
# Get arguments from COMMAND (sidebar)
|
|
|
|
|
# $1: process
|
|
|
|
|
# $2: position
|
|
|
|
|
# $3: file
|
|
|
|
|
#======================================================================
|
|
|
|
|
sidebar__OPTIONS() {
|
|
|
|
|
|
|
|
|
|
# Check OPTIONS except for "latest"
|
|
|
|
|
# ---------------------------------
|
|
|
|
|
sidebar__check_args() {
|
|
|
|
|
# Position
|
|
|
|
|
[[ "$1" = *[!0-9]* ]] \
|
|
|
|
|
&& gsl__invalid_option "$1" "position (1 to $site_max_list)"
|
|
|
|
|
|
|
|
|
|
(( "$1" == "0" || "$1" > "$site_max_list" )) \
|
|
|
|
|
&& gsl__invalid_option "$1" "position (1 to $site_max_list)"
|
2022-03-02 14:27:50 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
position="$1"
|
|
|
|
|
|
|
|
|
|
# file post
|
|
|
|
|
if__file "$2" post
|
|
|
|
|
gsl_post="$2"
|
|
|
|
|
! [[ -f "$gsl_dir_db_domain/$gsl_this_post.db" ]] \
|
|
|
|
|
&& echo "! Article not check yet" \
|
|
|
|
|
&& exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
|
add|-a)
|
|
|
|
|
sidebar__check_args "$2" "$3"
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
replace|-r)
|
|
|
|
|
sidebar__check_args "$2" "$3"
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
latest|-l|oldest|-o)
|
|
|
|
|
db__if_file;position="1 to $site_max_list"
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
*)
|
|
|
|
|
gsl__invalid_option "$1" "add|replace|latest|oldest"
|
|
|
|
|
;;
|
2022-04-14 11:00:07 +02:00
|
|
|
|
esac
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Start process
|
|
|
|
|
create__HTML_translation
|
|
|
|
|
sidebar__create "$1" "$position"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#======================================================================
|
|
|
|
|
# Sidebar: create /templates/sidebar.html
|
|
|
|
|
# $1: process
|
|
|
|
|
# $2: Position
|
|
|
|
|
# $3: DB file
|
|
|
|
|
#======================================================================
|
|
|
|
|
sidebar__create() {
|
|
|
|
|
log__process_begin "Sidebar"
|
2022-03-05 20:15:53 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
gsl__logs_print -i -s $1 \
|
|
|
|
|
"Position: $2 in final sidebar" \
|
|
|
|
|
"$gsl_dir_domain_tpl/sidebar.html"
|
2022-03-10 14:47:00 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
mkdir -p "$gsl_dir_domain_sidebar"
|
|
|
|
|
case "$1" in
|
|
|
|
|
latest|-l) sort_arg='-k2' ;;
|
|
|
|
|
oldest|-o) sort_arg='-k2r' ;;
|
|
|
|
|
esac
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
case "$1" in
|
|
|
|
|
latest|-l|oldest|-o)
|
|
|
|
|
sidebar_pos=0
|
|
|
|
|
while read -r "sorted_file"
|
|
|
|
|
do
|
|
|
|
|
((sidebar_pos++))
|
|
|
|
|
sidebar_HTML_item="$gsl_dir_domain_sidebar/$sidebar_pos.html"
|
|
|
|
|
db_name=`awk -F: '{print $1}' <<<"$sorted_file"`
|
|
|
|
|
source "$db_name"
|
|
|
|
|
gsl_post=`basename "$article_URI"`
|
|
|
|
|
|
|
|
|
|
gsl__logs_print -i -sdb $1 \
|
|
|
|
|
"Position: $sidebar_pos ; $article_epoch" \
|
|
|
|
|
"$sidebar_HTML_item"
|
|
|
|
|
|
|
|
|
|
srv__files datas
|
|
|
|
|
create__HTML_sidebar_item "$sidebar_HTML_item"
|
|
|
|
|
done < <(grep "Date" "$gsl_dir_db_domain/"*.gsl.db \
|
|
|
|
|
| sort -t= $sort_arg \
|
|
|
|
|
| head -n $site_max_list)
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
replace|-r)
|
|
|
|
|
gsl__logs_print -i -sdb $1 \
|
|
|
|
|
"Position: $2" \
|
|
|
|
|
"$gsl_dir_domain_sidebar/$2.html"
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
source "$gsl_dir_db_domain/$gsl_this_post.db"
|
|
|
|
|
create__HTML_sidebar_item "$gsl_dir_domain_sidebar/$2.html"
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
add|-a)
|
|
|
|
|
for i in `seq $site_max_list -1 $2`
|
|
|
|
|
do
|
|
|
|
|
if (( $i == $site_max_list)) &&
|
|
|
|
|
[[ -f "$gsl_dir_domain_sidebar/$i.html" ]];then
|
|
|
|
|
rm -f "$gsl_dir_domain_sidebar/$i.html"
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
[[ -f "$gsl_dir_domain_sidebar/$i.html" ]] \
|
|
|
|
|
&& mv "$gsl_dir_domain_sidebar/$i.html" \
|
|
|
|
|
"$gsl_dir_domain_sidebar/$(( i + 1 )).html"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
gsl__logs_print -i -sdb $1 \
|
|
|
|
|
"Position: $2" \
|
|
|
|
|
"$gsl_dir_domain_sidebar/$2.html"
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
source "$gsl_dir_db_domain/$gsl_this_post.db"
|
|
|
|
|
create__HTML_sidebar_item "$gsl_dir_domain_sidebar/$2.html"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
create__HTML_sidebar "$1" "$gsl_dir_domain_tpl/sidebar.html"
|
|
|
|
|
|
|
|
|
|
gsl__logs_print -w -sdb "Tips" \
|
|
|
|
|
"Do not forget to sync ; use gsl sync" \
|
|
|
|
|
"$gsl_dir_domain_tpl/sidebar.html"
|
|
|
|
|
|
|
|
|
|
unset gsl_post
|
|
|
|
|
log__process_end "Sidebar"
|
2022-02-19 18:17:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-08 17:53:40 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
# ------------
|
|
|
|
|
# MAKE Section
|
|
|
|
|
# ------------
|
2022-03-08 17:53:40 +01:00
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
#======================================================================
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Get arguments from COMMAND (make)
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__OPTIONS() {
|
|
|
|
|
gsl_proc="wip"
|
2022-04-23 17:51:46 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
while test "$2"
|
2022-03-08 17:53:40 +01:00
|
|
|
|
do
|
2022-06-14 18:51:19 +02:00
|
|
|
|
case "$2" in
|
|
|
|
|
-F)
|
|
|
|
|
gsl_force_make=true
|
|
|
|
|
log_info_force="Force "
|
2022-03-08 17:53:40 +01:00
|
|
|
|
;;
|
2022-06-14 18:51:19 +02:00
|
|
|
|
|
|
|
|
|
*".gsl")
|
|
|
|
|
if__file "$2" post
|
|
|
|
|
gsl_post="$2"
|
|
|
|
|
post_only="$2"
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
-N)
|
|
|
|
|
gsl_make_newer=true
|
|
|
|
|
unset gsl_force_make
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
*)
|
|
|
|
|
[[ "$gsl_post" ]] || [[ $gsl_force_make ]] \
|
|
|
|
|
&& echo "! Unused argument: $2" \
|
|
|
|
|
|| gsl__invalid_option "$2" "-F|(FILE)"
|
2022-03-08 17:53:40 +01:00
|
|
|
|
;;
|
|
|
|
|
esac
|
2022-06-14 18:51:19 +02:00
|
|
|
|
shift
|
2022-04-23 17:51:46 +02:00
|
|
|
|
done
|
2022-03-08 17:53:40 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
[[ "$gsl_post" ]] || log_info_all=" ALL"
|
|
|
|
|
|
|
|
|
|
log__process_begin "${log_info_force}Make${log_info_all}"
|
|
|
|
|
posts__loop make
|
2022-03-08 17:53:40 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# For logs ; set post or unset if all
|
|
|
|
|
[[ $log_info_all ]] && unset gsl_post
|
|
|
|
|
[[ $post_only ]] && gsl_post="$post_only"
|
2022-04-23 17:51:46 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
log__process_end "${log_info_force}Make${log_info_all}"
|
2022-03-08 17:53:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#=======================================================================
|
|
|
|
|
# From: posts__loop() ; Convert Post to HTML
|
|
|
|
|
# But, before: Compare hash ans existing files
|
|
|
|
|
#=======================================================================
|
|
|
|
|
Makers() {
|
|
|
|
|
# Check if hashes not match
|
|
|
|
|
! [[ "$gsl_do_make" ]] && return
|
|
|
|
|
|
|
|
|
|
# OPT: -F (force)
|
|
|
|
|
gsl_do_make=true
|
|
|
|
|
if [[ "$gsl_force_make" ]];then
|
|
|
|
|
if [[ "$gsl_srv_wip_file" ]];then
|
|
|
|
|
gsl__logs_print -w -g -M \
|
|
|
|
|
"WIP: Force again HTML $article_Type" \
|
|
|
|
|
"$PWD/$gsl_post"
|
|
|
|
|
fi
|
2022-03-08 17:53:40 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Not force
|
|
|
|
|
else
|
|
|
|
|
# if file exists (value is true)
|
|
|
|
|
if [[ "$gsl_srv_wip_file" ]];then
|
2022-06-15 17:55:43 +02:00
|
|
|
|
if (( $article_Status_chk == $article_Status_wip ));then
|
|
|
|
|
gsl__logs_print -w -g -M \
|
|
|
|
|
"WIP: Already done ; Use -F to force" \
|
|
|
|
|
"$gsl_srv_post_wip"
|
|
|
|
|
unset gsl_do_make
|
|
|
|
|
fi
|
2022-06-14 18:51:19 +02:00
|
|
|
|
fi
|
|
|
|
|
fi
|
2022-04-23 17:51:46 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
! [[ "$gsl_do_make" ]] && return
|
2022-03-08 17:53:40 +01:00
|
|
|
|
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
# Set HTML to replace first marker
|
|
|
|
|
# Closed HTML are static > in gsl.conf
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
HTML_icode_start="<code class=\"${site_css}_icode\">"
|
|
|
|
|
HTML_strong_start="<strong class=\"${site_css}_strong\">"
|
|
|
|
|
HTML_em_start="<i class=\"${site_css}_em\">"
|
2022-06-18 18:02:14 +02:00
|
|
|
|
HTML_strike_start="<span class=\"${site_css}_strike\">"
|
2022-06-14 18:51:19 +02:00
|
|
|
|
HTML_bold_start="<b class=\"${site_css}_bold\">"
|
2022-03-08 17:53:40 +01:00
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# makers modules
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
# Titles
|
|
|
|
|
read__line_with "^#[1-6]" "make" "title" "content" "$gsl_tmp_post"
|
2022-03-08 17:53:40 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Paragraphs
|
|
|
|
|
make__paragraphs "$gsl_mark_p_start " "$gsl_mark_p_close" "$gsl_tmp_post"
|
2022-04-23 17:51:46 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# New Line (convert | in <br />)
|
|
|
|
|
make__br "$gsl_mark_newline" "$gsl_tmp_post"
|
|
|
|
|
|
|
|
|
|
# abbr
|
|
|
|
|
read__line_with "^$gsl_marker_abbr" "make" \
|
|
|
|
|
"abbr" "metas" "$gsl_tmp_head"
|
2022-03-05 19:25:04 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# links
|
|
|
|
|
read__line_with "^$gsl_marker_link" "make" \
|
|
|
|
|
"link" "metas" "$gsl_tmp_head"
|
2022-03-05 19:25:04 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# flink
|
|
|
|
|
read__line_with "^$gsl_marker_flink" "make" \
|
|
|
|
|
"flink" "metas" "$gsl_tmp_head"
|
2022-03-05 19:25:04 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
# Convert words between marks (icode, strong, emphasis, bolds)
|
|
|
|
|
# If these markers are in inline code, replace by temp marker + sed back
|
|
|
|
|
# Strong
|
|
|
|
|
make__loop_line "$gsl_mark_strong" "between" "$gsl_tmp_post" \
|
|
|
|
|
"$HTML_strong_start" "$HTML_strong_close" "ß"
|
|
|
|
|
# Bold
|
|
|
|
|
make__loop_line "$gsl_mark_bold" "between" "$gsl_tmp_post" \
|
|
|
|
|
"$HTML_bold_start" "$HTML_bold_close" "ð"
|
|
|
|
|
# Emphasis
|
|
|
|
|
make__loop_line "$gsl_mark_em" "between" "$gsl_tmp_post" \
|
|
|
|
|
"$HTML_em_start" "$HTML_em_close" "đ"
|
|
|
|
|
# Strike
|
|
|
|
|
make__loop_line "$gsl_mark_strike" "between" "$gsl_tmp_post" \
|
|
|
|
|
"$HTML_strike_start" "$HTML_strike_close" "ŋ"
|
|
|
|
|
# ! At last do : iCodes
|
|
|
|
|
make__loop_line "$gsl_mark_icode" "between" "$gsl_tmp_post" \
|
|
|
|
|
"$HTML_icode_start" "$HTML_icode_close"
|
|
|
|
|
|
|
|
|
|
# For lines having markers in inline-code, replace temp markers
|
|
|
|
|
if [[ ${incode_line[@]} ]];then
|
|
|
|
|
for ln in ${incode_line[@]}
|
2022-03-05 19:25:04 +01:00
|
|
|
|
do
|
2022-06-14 18:51:19 +02:00
|
|
|
|
sed -i "${ln}s^ß^•^g" "$gsl_tmp_post" # Strong
|
|
|
|
|
sed -i "${ln}s^ð^·^g" "$gsl_tmp_post" # Bold
|
|
|
|
|
sed -i "${ln}s^đ^”^g" "$gsl_tmp_post" # Emphasis
|
|
|
|
|
sed -i "${ln}s^ŋ^×^g" "$gsl_tmp_post" # Strike
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
#----------------------------------------------------------------------
|
2022-03-05 19:25:04 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Image
|
|
|
|
|
read__line_with "^$gsl_marker_image" "make" \
|
|
|
|
|
"image" "metas" "$gsl_tmp_head"
|
2022-03-05 19:25:04 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# lists
|
|
|
|
|
make__lists "$gsl_tmp_post"
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Quotes
|
|
|
|
|
make__quotes "$gsl_tmp_post"
|
2022-04-07 17:12:50 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# File code
|
|
|
|
|
read__line_with "^$gsl_marker_fcode" "make" \
|
|
|
|
|
"fcode" "metas" "$gsl_tmp_head"
|
2022-04-13 18:33:11 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# At the very end, make brut codes
|
|
|
|
|
read__line_with "^$gsl_marker_fbrut" "make" \
|
|
|
|
|
"fbrut" "metas" "$gsl_tmp_head"
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# a11y + div between titles
|
|
|
|
|
make__div_title "$gsl_tmp_post"
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# a11y (tabulation)
|
|
|
|
|
spc=' ' # 8 spaces. Main content (2*4)
|
|
|
|
|
sed -i -e "s|^|$spc|" "$gsl_tmp_post"
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Create wip HTML page
|
|
|
|
|
create__HTML_page
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
rm -f "$gsl_tmp_post"
|
|
|
|
|
DB__set_status "wip"
|
|
|
|
|
}
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
2022-04-07 18:47:48 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# Loop called by each content module, till nothing found
|
|
|
|
|
# $1: marker
|
|
|
|
|
# $2: mark (between)
|
|
|
|
|
# $3: file
|
|
|
|
|
# $4: HTML Start
|
|
|
|
|
# $5: HTML Close
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__loop_line() {
|
|
|
|
|
read__line_with \
|
|
|
|
|
"$1" "make" \
|
|
|
|
|
"$2" "content" \
|
|
|
|
|
"$3" "$4" "$5" "$6"
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
! [[ "$gsl_line" ]] && return
|
2022-02-21 17:25:08 +01:00
|
|
|
|
}
|
2022-04-23 17:51:46 +02:00
|
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# Filter content
|
|
|
|
|
# Called from read__line_with() in gsl__do_commons
|
|
|
|
|
# $1: marker
|
|
|
|
|
# $2: mark
|
|
|
|
|
# $3: file
|
|
|
|
|
# $4: HTML start
|
|
|
|
|
# $5: HTML close
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__headers_from_filter() {
|
|
|
|
|
case "$2" in
|
|
|
|
|
title) make__titles "$3" ;;
|
|
|
|
|
between) make__words "$1" "$2" "$3" "$4" "$5" "$6" ;;
|
|
|
|
|
abbr) make__abbrs "$5" "$gsl_tmp_post" ;;
|
|
|
|
|
link|flink) make__links "$gsl_tmp_post" "$2" ;;
|
|
|
|
|
fcode) make__file_codes "$gsl_tmp_post" ;;
|
|
|
|
|
fbrut) make__file_bruts "$gsl_tmp_post" ;;
|
|
|
|
|
image) make__file_images "$gsl_tmp_post" ;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
2022-03-01 12:39:16 +01:00
|
|
|
|
|
2022-04-25 13:17:09 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# From make loop_line()
|
|
|
|
|
# Convert words between marks (strong, icode, emphasis)
|
|
|
|
|
# $1: marker
|
|
|
|
|
# #2: mark (betwee)
|
|
|
|
|
# $3: file
|
|
|
|
|
# $4: HTML start
|
|
|
|
|
# $5: HTML close
|
|
|
|
|
# $6: temp marker (if legacy in inline code)
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__words() {
|
|
|
|
|
icm=0
|
|
|
|
|
for (( i=0; i<${#gsl_line}; i++ ))
|
|
|
|
|
do
|
|
|
|
|
|
|
|
|
|
# For markers not "inline-code", set characters to bypass
|
|
|
|
|
case "${gsl_line:$i:1}" in
|
|
|
|
|
"$gsl_mark_icode")
|
|
|
|
|
if [[ "$1" != "$gsl_mark_icode" ]];then
|
|
|
|
|
icm=$(( icm + 1 ))
|
|
|
|
|
incode=true;incode_s=$i
|
|
|
|
|
icm_p=$(( $icm % 2 ))
|
|
|
|
|
[[ $icm_p -eq 0 ]] && unset incode
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
case "${gsl_line:$i:1}" in
|
|
|
|
|
"$1")
|
|
|
|
|
if [[ $incode ]] && (( "$i" > $incode_s ));then
|
|
|
|
|
# Get line containing temp markers and replace
|
|
|
|
|
[[ `grep "$ln" <<<"${incode_line[@]}"` ]] || incode_line+=($ln)
|
|
|
|
|
sed -i -r "${ln}s|^(.{"$i"})"$1"|\1$6|" "$3"
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ $open ]];then
|
|
|
|
|
unset open
|
|
|
|
|
sed -i -r "${ln}s|^(.{"$i"})"$1"|\1$5|" "$3"
|
|
|
|
|
break
|
2022-04-25 13:17:09 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
else
|
|
|
|
|
open=true
|
|
|
|
|
sed -i -r "${ln}s|^(.{"$i"})"$1"|\1$4|" "$3"
|
|
|
|
|
break
|
2022-04-25 13:17:09 +02:00
|
|
|
|
fi
|
2022-03-02 17:25:23 +01:00
|
|
|
|
;;
|
|
|
|
|
esac
|
2022-06-14 18:51:19 +02:00
|
|
|
|
done
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
make__loop_line "$1" "$2" "$3" "$4" "$5" "$6"
|
|
|
|
|
}
|
2022-03-05 19:25:04 +01:00
|
|
|
|
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# Make HTML Titles
|
|
|
|
|
# $1: file (from $5 of read__line_with)
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__titles() {
|
|
|
|
|
while read -r "t" "content"
|
|
|
|
|
do
|
|
|
|
|
tn=${t: -1}
|
|
|
|
|
HTML_title=`
|
|
|
|
|
printf '%s%s%s\n' \
|
|
|
|
|
"<h$tn class=\"${site_css}_title ${site_css}_title-$tn\">" \
|
|
|
|
|
"$content" \
|
|
|
|
|
"</h$tn>"`
|
|
|
|
|
|
|
|
|
|
sed -i "${ln}s^.*^$HTML_title^" "$1"
|
|
|
|
|
done <<<"$gsl_line"
|
|
|
|
|
}
|
2022-03-05 19:25:04 +01:00
|
|
|
|
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# Make HTML paragraphs
|
|
|
|
|
# $1: marker open
|
|
|
|
|
# $2: marker close
|
|
|
|
|
# $3: file
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__paragraphs() {
|
|
|
|
|
[[ `grep "^$2$" "$3"` ]] \
|
|
|
|
|
&& sed -i "s,^$2$,$HTML_p_close,g" "$3" \
|
|
|
|
|
|| return
|
|
|
|
|
|
|
|
|
|
while read -r "lnpm" "class"
|
|
|
|
|
do
|
|
|
|
|
ln=`awk -F: '{print $1}' <<<$lnpm`
|
|
|
|
|
pm=`awk -F: '{print $2}' <<<$lnpm`
|
|
|
|
|
|
|
|
|
|
if [[ $class ]];then
|
|
|
|
|
HTML_p="<p class=\"${site_css}_p $class\">"
|
|
|
|
|
sed -i "${ln}s^$pm $class^$HTML_p^" "$3"
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
HTML_p="<p class=\"${site_css}_p\">"
|
|
|
|
|
sed -i "${ln}s^$pm^$HTML_p^" "$3"
|
|
|
|
|
fi
|
|
|
|
|
done < <(grep -n '^($\|^'"$1" "$3")
|
2022-02-19 18:17:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# Convert new line "|" to <br /> ($HTML_br)
|
|
|
|
|
# $1: marker
|
|
|
|
|
# $2: file
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__br() {
|
|
|
|
|
[[ `grep "^$1$" "$2"` ]] \
|
|
|
|
|
&& sed -i "s,^$1$,$HTML_br,g" "$2"
|
|
|
|
|
}
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# HTML abbr: SHORT must have 1 space before/after, or both
|
|
|
|
|
# $1: file header
|
|
|
|
|
# $2: file post
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__abbrs() {
|
|
|
|
|
! [[ "$header_f1" ]] && return
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
abbr_title="title=\"$header_f2\""
|
|
|
|
|
abbr_class="class=\"${site_css}_abbr\""
|
|
|
|
|
abbr_words="<abbr $abbr_class $abbr_title>$header_f1</abbr>"
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
sed -i "s^ $header_f1 ^ $abbr_words ^g" "$2"
|
|
|
|
|
sed -i "s^$header_f1 ^$abbr_words ^g" "$2"
|
|
|
|
|
sed -i "s^ $header_f1^ $abbr_words^g" "$2"
|
|
|
|
|
}
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# HTML link: + to open in new window
|
|
|
|
|
# $1: file post
|
|
|
|
|
# $2: mark type
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__links() {
|
|
|
|
|
! [[ "$header_f1" ]] && return
|
|
|
|
|
|
|
|
|
|
[[ "$header_f3" ]] \
|
|
|
|
|
&& link_title=" title=\"$header_f3\""
|
|
|
|
|
|
|
|
|
|
# link or flink
|
|
|
|
|
case "$2" in
|
|
|
|
|
"link")
|
|
|
|
|
mt="$gsl_mark_link"
|
|
|
|
|
cssn="link"
|
|
|
|
|
unset luri
|
|
|
|
|
;;
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
"flink")
|
|
|
|
|
mt="$gsl_mark_flink"
|
|
|
|
|
cssn="link-file"
|
|
|
|
|
luri="${srv_uri}files/"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
link_class="class=\"${site_css}_$cssn\""
|
|
|
|
|
link_class2="class=\"${site_css}_$cssn ${site_css}_$cssn-window\""
|
|
|
|
|
link_words=`
|
|
|
|
|
printf '%s%s%s\n' \
|
|
|
|
|
"<a $link_class href=\"$luri$header_f2\"" \
|
|
|
|
|
"$link_title>" \
|
|
|
|
|
"$header_f1</a>"`
|
|
|
|
|
|
|
|
|
|
link_words2=`
|
|
|
|
|
printf '%s%s%s\n' \
|
|
|
|
|
"<a target=\"_blank\" $link_class2 href=\"$luri$header_f2\"" \
|
|
|
|
|
"$link_title>" \
|
|
|
|
|
"$header_f1</a>"`
|
|
|
|
|
|
|
|
|
|
sed -i "s^$mt${header_f1}+^$link_words2^g" "$1"
|
|
|
|
|
sed -i "s^$mt$header_f1^$link_words^g" "$1"
|
|
|
|
|
}
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# HTML code : create tmp file with source code
|
|
|
|
|
# converted in HTML version with <pre>, and replace mark with tmp file
|
|
|
|
|
# $1: file post
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__file_codes() {
|
|
|
|
|
pre_class="class=\"${site_css}_code-block ${site_css}_code-block-$header_f1\""
|
|
|
|
|
pre_css_line="class=\"${site_css}_code-line\""
|
|
|
|
|
pre_css_content="class=\"${site_css}_code-content\""
|
|
|
|
|
pre_css_source="class=\"${site_css}_code-link\""
|
|
|
|
|
pre_css_p="class=\"${site_css}_code-p\""
|
|
|
|
|
|
|
|
|
|
# No Alt-Text ; generate
|
|
|
|
|
if [[ "$header_f3" ]];then
|
|
|
|
|
pre_title=" title=\"Code: source\""
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
header_f3="Code: source"
|
|
|
|
|
fi
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
gsl_tmp_code=`mktemp`
|
|
|
|
|
cat << EOCODE > "$gsl_tmp_code"
|
|
|
|
|
<pre $pre_class>
|
|
|
|
|
$(while read -r "code_ln" "code_content"
|
|
|
|
|
do
|
|
|
|
|
printf '%2s%s%s\n' "" \
|
|
|
|
|
"<span $pre_css_line>$code_ln</span>" \
|
|
|
|
|
"<span $pre_css_content>$code_content</span>"
|
|
|
|
|
done < <(cat -n "$gsl_dir_domain_files/$header_f2"))
|
|
|
|
|
</pre>
|
2022-06-18 18:02:14 +02:00
|
|
|
|
<div $pre_css_p>
|
2022-06-14 18:51:19 +02:00
|
|
|
|
<a $pre_css_source
|
|
|
|
|
target="_blank"
|
|
|
|
|
href="${srv_uri}files/$header_f2"$pre_title>
|
|
|
|
|
$header_f3
|
|
|
|
|
</a>
|
2022-06-18 18:02:14 +02:00
|
|
|
|
</div>
|
2022-06-14 18:51:19 +02:00
|
|
|
|
EOCODE
|
|
|
|
|
|
|
|
|
|
# for/from make__file_codes (Replace mark till no more)
|
|
|
|
|
# $1: file post
|
|
|
|
|
#-------------------------------------------------
|
|
|
|
|
make__file_codes_replace() {
|
|
|
|
|
lncode=`
|
|
|
|
|
grep -n "$gsl_mark_fcode:$header_f1" "$1" \
|
|
|
|
|
| head -n1 \
|
|
|
|
|
| awk -F: '{print $1}'`
|
|
|
|
|
|
|
|
|
|
[[ "$lncode" ]] || return
|
|
|
|
|
|
|
|
|
|
sed -i "${lncode}r $gsl_tmp_code" "$1"
|
|
|
|
|
sed -i "${lncode}d" "$1"
|
|
|
|
|
make__file_codes_replace "$1"
|
|
|
|
|
}
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
make__file_codes_replace "$1"
|
|
|
|
|
rm -f "$gsl_tmp_code"
|
2022-02-21 17:25:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# Replace marks with brut file. Must be done at the end !
|
|
|
|
|
# $1: file post
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__file_bruts() {
|
|
|
|
|
lncode=`
|
|
|
|
|
grep -n "$gsl_mark_fbrut:$header_f1" "$1" \
|
|
|
|
|
| head -n1 \
|
|
|
|
|
| awk -F: '{print $1}'`
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
[[ "$lncode" ]] || return
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
sed -i "${lncode}r $gsl_dir_domain_files/$header_f2" "$1"
|
|
|
|
|
sed -i "${lncode}d" "$1"
|
|
|
|
|
make__file_bruts "$1"
|
2022-02-19 18:17:09 +01:00
|
|
|
|
}
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
2022-04-07 17:12:50 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# Make images
|
|
|
|
|
# $1: file post
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__file_images() {
|
|
|
|
|
this_image=`grep -n "$gsl_mark_image:$header_f1" "$1"`
|
|
|
|
|
[[ "$this_image" ]] || return
|
|
|
|
|
|
2022-06-18 12:16:52 +02:00
|
|
|
|
mark_image=${this_image#*:} # Get content mark to replace
|
2022-06-14 18:51:19 +02:00
|
|
|
|
while IFS=: read -r "ln" \
|
2022-04-14 11:00:07 +02:00
|
|
|
|
"marker" \
|
2022-06-14 18:51:19 +02:00
|
|
|
|
"f1" \
|
|
|
|
|
"class" \
|
2022-04-14 11:00:07 +02:00
|
|
|
|
"width" \
|
|
|
|
|
"height" \
|
|
|
|
|
"target"
|
2022-03-02 14:27:50 +01:00
|
|
|
|
do
|
2022-06-14 18:51:19 +02:00
|
|
|
|
case "$class" in
|
|
|
|
|
R|r|D|d) image_class="${site_css}_image-right" ;;
|
|
|
|
|
G|g|L|l) image_class="${site_css}_image-left" ;;
|
|
|
|
|
C|c|D|d) image_class="${site_css}_image-center" ;;
|
|
|
|
|
"+") image_class="${site_css}_image-center";target=true ;;
|
|
|
|
|
"") image_class="${site_css}_image-center";unset width height ;;
|
|
|
|
|
*) image_class="$class";link_class=" $class" ;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
case "$width" in
|
2022-06-18 18:02:14 +02:00
|
|
|
|
"+") target=true;unset width ;;
|
2022-06-14 18:51:19 +02:00
|
|
|
|
esac
|
2022-04-11 18:06:38 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
case "$height" in
|
2022-06-18 18:02:14 +02:00
|
|
|
|
"+") target=true;unset height ;;
|
2022-03-02 14:27:50 +01:00
|
|
|
|
esac
|
2022-04-07 17:12:50 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
image_css="class=\"${site_css}_image $image_class\""
|
|
|
|
|
image_src="src=\"${srv_uri}images/$header_f2\""
|
|
|
|
|
image_alt="alt=\"$header_f3\" title=\"$header_f3\""
|
2022-04-14 11:00:07 +02:00
|
|
|
|
|
2022-06-15 17:22:25 +02:00
|
|
|
|
if [[ "$height" && "$width" ]];then
|
|
|
|
|
image_style=" style=\"width:$width;height:$height;\""
|
|
|
|
|
elif [[ "$width" ]];then
|
|
|
|
|
image_style=" style=\"width:${width};\""
|
|
|
|
|
elif [[ "$height" ]];then
|
|
|
|
|
image_style=" style=\"height:${height};\""
|
|
|
|
|
fi
|
2022-04-11 18:06:38 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
HTML_image=`
|
|
|
|
|
printf '%s%s\n' \
|
|
|
|
|
"<img $image_css $image_src $image_alt" \
|
2022-06-15 17:22:25 +02:00
|
|
|
|
"$image_style />"`
|
2022-06-14 18:51:19 +02:00
|
|
|
|
|
|
|
|
|
if [[ "$target" ]];then
|
|
|
|
|
image_clink="class=\"${site_css}_image-link$link_class\""
|
|
|
|
|
HTML_image=`
|
2022-06-15 17:22:25 +02:00
|
|
|
|
printf '%s%s%s\n' \
|
|
|
|
|
"<a $image_clink href=\"${srv_uri}images/$header_f2\">" \
|
2022-06-14 18:51:19 +02:00
|
|
|
|
"$HTML_image" \
|
|
|
|
|
"</a>"`
|
|
|
|
|
fi
|
|
|
|
|
done <<<"$this_image"
|
2022-04-07 17:12:50 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
sed -i "${ln}s^$mark_image^$HTML_image^" "$1"
|
|
|
|
|
make__file_images "$1"
|
2022-02-27 19:16:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-07 17:12:50 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# Lists (independant module)
|
|
|
|
|
# repeat for each ^>> found
|
|
|
|
|
# Put bloc list in a file: gsl_tmp_list_brut
|
|
|
|
|
# Convert list to HTML in a new file: gsl_tmp_list_HTML
|
|
|
|
|
# Replace gsl bloc with new file
|
|
|
|
|
# $1: file
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__lists() {
|
|
|
|
|
# Check for last bloc Item list
|
|
|
|
|
[[ `grep '^>>' "$1"` ]] || return
|
|
|
|
|
|
|
|
|
|
unset mark list mn sign muo_class my_class
|
|
|
|
|
|
|
|
|
|
# Define start and close line number
|
|
|
|
|
list_ln_start=`grep -n "^<<" "$1" | head -n 1 | awk -F: '{print $1}'`
|
|
|
|
|
list_ln_close=`grep -n "^>>" "$1" | head -n 1 | awk -F: '{print $1}'`
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
# Put gsl block list in tmp file
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
gsl_tmp_list_brut=`mktemp`
|
|
|
|
|
awk -v lns="$list_ln_start" -v lnc="$list_ln_close" \
|
|
|
|
|
'NR >= lns && NR <= lnc {print}' \
|
|
|
|
|
"$1" \
|
|
|
|
|
> "$gsl_tmp_list_brut"
|
|
|
|
|
|
|
|
|
|
# File to print HTML List
|
|
|
|
|
gsl_tmp_list_HTML=`mktemp`
|
|
|
|
|
|
|
|
|
|
# Define CSS class
|
|
|
|
|
li_class="${site_css}_li ${site_css}_li-"
|
|
|
|
|
uo_class="${site_css}_list ${site_css}_list-"
|
|
|
|
|
|
|
|
|
|
# Custom class for bloc only
|
|
|
|
|
my_class=`awk 'NR == 1 {print $2}' "$gsl_tmp_list_brut"`
|
|
|
|
|
[[ $my_class ]] \
|
|
|
|
|
&& muo_class=" ${site_css}_list-$my_class ${site_css}_list-$my_class-"
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
# Define list in arrays
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
i=0;l=0
|
|
|
|
|
while read -r "ln" "mark" "content"
|
|
|
|
|
do
|
|
|
|
|
((i++))
|
|
|
|
|
mark[$i]="${mark}"
|
|
|
|
|
sign[$i]="${mark:0:1}"
|
|
|
|
|
line[$i]="$ln"
|
|
|
|
|
mn[$i]="${#mark}"
|
|
|
|
|
case "$mark" in
|
|
|
|
|
"="*) list[$i]="ul" ;;
|
|
|
|
|
"+"*) list[$i]="ol" ;;
|
|
|
|
|
esac
|
|
|
|
|
done < <(awk '($1 ~ "=" || $1 ~ "+" || $1 ~ ">>" ) \
|
|
|
|
|
{print NR,$0}' \
|
|
|
|
|
"$gsl_tmp_list_brut")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Generic prints li
|
|
|
|
|
# -----------------
|
|
|
|
|
make__list_li() {
|
|
|
|
|
printf "%$((sp + 2))s%s\n" "" \
|
|
|
|
|
"<li class=\"$li_class${mn[$n]}\">${content[$n]}</li>" \
|
|
|
|
|
| awk -v sp="$((sp+2))" \
|
|
|
|
|
'NR == 1 {print $0};NR > 1 {printf "%" sp "s%s\n", "", $0}' \
|
|
|
|
|
>> "$gsl_tmp_list_HTML"
|
|
|
|
|
}
|
2022-04-07 17:12:50 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Generic print ul | ol (open current)
|
|
|
|
|
# ------------------------------------
|
|
|
|
|
make__list_open_n() {
|
|
|
|
|
l=$(( l + 1 ))
|
|
|
|
|
printf "%${sp}s%s\n" "" \
|
|
|
|
|
"<${list[n]}>" \
|
|
|
|
|
>> "$gsl_tmp_list_HTML"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
# Define content items and make HTML list
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
for n in `seq 1 $i`
|
2022-02-27 19:16:16 +01:00
|
|
|
|
do
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Define content items for each list
|
|
|
|
|
content[$n]=`
|
|
|
|
|
awk -v cts="${line[$n]}" -v ctc="${line[$((n+1))]}" \
|
|
|
|
|
'NR >= cts && NR < ctc {print $0}' \
|
|
|
|
|
"$gsl_tmp_list_brut" \
|
|
|
|
|
| awk '{ sub(/^[ \t]+/, ""); print }'`
|
2022-04-07 14:58:26 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
content[$n]=${content[$n]/${mark[$n]}/}
|
|
|
|
|
content[$n]=`awk '{sub(/^[ \t]+/, ""); print}' <<<"${content[$n]}"`
|
|
|
|
|
|
|
|
|
|
# Define HTML ul | ol from previous item list
|
|
|
|
|
# ----------------------------------------
|
|
|
|
|
# Define a11y tabulation for each item
|
|
|
|
|
sp=$(( ${mn[$n]} * 2 - 2 ))
|
2022-04-07 14:58:26 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# ----------
|
|
|
|
|
# First Item
|
|
|
|
|
# ----------
|
|
|
|
|
if (( $n == 1 ));then
|
|
|
|
|
uo_class+="${list[n]}"
|
|
|
|
|
[[ $my_class ]] \
|
|
|
|
|
&& muo_class+="${list[n]}"
|
|
|
|
|
|
|
|
|
|
l=$(( l + 1 ))
|
|
|
|
|
printf "%${sp}s%s\n" "" \
|
|
|
|
|
"<${list[n]} class=\"$uo_class$muo_class\">" \
|
|
|
|
|
>> "$gsl_tmp_list_HTML"
|
|
|
|
|
printf "%$((sp + 2))s%s\n" "" \
|
|
|
|
|
"<li class=\"${li_class}1\">${content[$n]}</li>" \
|
|
|
|
|
>> "$gsl_tmp_list_HTML"
|
|
|
|
|
|
|
|
|
|
# ---------
|
|
|
|
|
# Last Item
|
|
|
|
|
# ---------
|
|
|
|
|
elif (( $n == $i ));then
|
|
|
|
|
sp=$(( ${mn[$(( n - 1 ))]} * 2 - 2 ))
|
|
|
|
|
|
|
|
|
|
# ---------------------
|
|
|
|
|
# Same sign | Last Item
|
|
|
|
|
# ---------------------
|
|
|
|
|
if [[ ${sign[1]} == ${sign[$(( n - 1 ))]} ]];then
|
|
|
|
|
for c in `seq 1 ${mn[$(( n - 1 ))]}`
|
|
|
|
|
do
|
|
|
|
|
printf "%${sp}s%s\n" "" \
|
|
|
|
|
"</${list[l]}>" \
|
|
|
|
|
>> "$gsl_tmp_list_HTML"
|
|
|
|
|
sp=$(( sp - 2 ))
|
|
|
|
|
l=$(( l - 1 ))
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# ---------------------
|
|
|
|
|
# Diff sign | Last Item
|
|
|
|
|
# ---------------------
|
|
|
|
|
else
|
|
|
|
|
printf "%${sp}s%s\n" "" \
|
|
|
|
|
"</${list[$(( n - 1 ))]}>" \
|
|
|
|
|
>> "$gsl_tmp_list_HTML"
|
|
|
|
|
l=$(( l - 1 ))
|
|
|
|
|
|
|
|
|
|
for c in `seq 1 ${mn[$(( n - 1 ))]}`
|
|
|
|
|
do
|
|
|
|
|
l=$(( l - 1 ))
|
|
|
|
|
sp=$(( sp - 2 ))
|
|
|
|
|
(( $sp < 0 )) && sp=0
|
|
|
|
|
printf "%${sp}s%s\n" "" \
|
|
|
|
|
"</${list[l]}>" \
|
|
|
|
|
>> "$gsl_tmp_list_HTML"
|
|
|
|
|
done
|
|
|
|
|
fi
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# -----------
|
|
|
|
|
# Middle Item
|
|
|
|
|
# -----------
|
|
|
|
|
else
|
|
|
|
|
# Diff NBR between current and previous mark: mark difference
|
|
|
|
|
md=$(( ${mn[$n]} - ${mn[$((n - 1))]} ))
|
|
|
|
|
|
|
|
|
|
#echo "${mark[n]} | ${sign[n]} <==> ${mark[$(( n - 1 ))]} | ${sign[$(( n - 1 ))]}"
|
|
|
|
|
|
|
|
|
|
# ----------------------------
|
|
|
|
|
# Same Diff from previous Item
|
|
|
|
|
# ----------------------------
|
|
|
|
|
if (( $md == 0 ));then
|
|
|
|
|
|
|
|
|
|
# ---------------------
|
|
|
|
|
# Same sign | Same Item
|
|
|
|
|
# ---------------------
|
|
|
|
|
if [[ ${sign[n]} == ${sign[$(( n - 1 ))]} ]];then
|
|
|
|
|
make__list_li
|
|
|
|
|
|
|
|
|
|
# ---------------------
|
|
|
|
|
# Diff sign | Same Item
|
|
|
|
|
# ---------------------
|
|
|
|
|
else
|
|
|
|
|
make__list_open_n
|
|
|
|
|
make__list_li
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# -------------------------
|
|
|
|
|
# NEW Item UP from previous
|
|
|
|
|
# -------------------------
|
|
|
|
|
elif (( $md > 0 ));then
|
|
|
|
|
|
|
|
|
|
# -----------------------
|
|
|
|
|
# Same sign | New Item UP
|
|
|
|
|
# -----------------------
|
|
|
|
|
if [[ ${sign[n]} == ${sign[$(( n - 1 ))]} ]];then
|
|
|
|
|
make__list_open_n
|
|
|
|
|
make__list_li
|
|
|
|
|
|
|
|
|
|
# -----------------------
|
|
|
|
|
# Diff sign | New item UP
|
|
|
|
|
# -----------------------
|
|
|
|
|
else
|
|
|
|
|
make__list_open_n
|
|
|
|
|
make__list_li
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------------------------
|
|
|
|
|
# New Item DOWN from previous
|
|
|
|
|
# ---------------------------
|
|
|
|
|
else
|
|
|
|
|
bsp=$(( ${mn[$(( n - 1 ))]} * 2 - 2 ))
|
|
|
|
|
|
|
|
|
|
# -------------------------
|
|
|
|
|
# Same sign | New Item Down
|
|
|
|
|
# -------------------------
|
|
|
|
|
if [[ ${sign[n]} == ${sign[$(( n - 1 ))]} ]];then
|
|
|
|
|
for c in `seq 1 ${md/-/}`
|
|
|
|
|
do
|
|
|
|
|
printf "%${bsp}s%s\n" "" \
|
|
|
|
|
"</${list[l]}>" \
|
|
|
|
|
>> "$gsl_tmp_list_HTML"
|
|
|
|
|
bsp=$(( bsp - 2 ))
|
|
|
|
|
l=$(( l - 1 ))
|
|
|
|
|
done
|
|
|
|
|
make__list_li
|
|
|
|
|
|
|
|
|
|
# -------------------------
|
|
|
|
|
# Diff sing | New Item Down
|
|
|
|
|
# -------------------------
|
|
|
|
|
else
|
|
|
|
|
l=$(( l + 1 ))
|
|
|
|
|
for c in `seq 1 $(( ${md/-/} + 1 ))`
|
|
|
|
|
do
|
|
|
|
|
printf "%${bsp}s%s\n" "" \
|
|
|
|
|
"</${list[$(( n - 1 ))]}>" \
|
|
|
|
|
>> "$gsl_tmp_list_HTML"
|
|
|
|
|
bsp=$(( bsp - 2 ))
|
|
|
|
|
l=$(( l - 1 ))
|
|
|
|
|
done
|
|
|
|
|
make__list_li
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Delete source lines and insert HTML file
|
|
|
|
|
del_ln=`seq $list_ln_start $list_ln_close | wc -l`
|
|
|
|
|
for i in `seq 1 $del_ln`
|
|
|
|
|
do
|
|
|
|
|
sed -i "${list_ln_start}d" "$1"
|
|
|
|
|
done
|
|
|
|
|
sed -i "$((list_ln_start - 1))r$gsl_tmp_list_HTML" "$1"
|
|
|
|
|
|
|
|
|
|
rm -f "$gsl_tmp_list_brut"
|
|
|
|
|
rm -f "$gsl_tmp_list_HTML"
|
|
|
|
|
|
|
|
|
|
make__lists "$gsl_tmp_post"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#======================================================================
|
|
|
|
|
# Quotes (independant module)
|
|
|
|
|
# $1: file
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__quotes() {
|
|
|
|
|
# Get block quote
|
|
|
|
|
unset ${!quote@} my_class ${!q_@}
|
|
|
|
|
while IFS=: read -r "ln" "mk"
|
|
|
|
|
do
|
|
|
|
|
[[ $quote_ln_start ]] \
|
|
|
|
|
&& quote_ln_close="$ln" \
|
|
|
|
|
|| quote_ln_start="$ln"
|
|
|
|
|
done < <(grep -n "^---" "$1" | head -n 2)
|
|
|
|
|
|
|
|
|
|
[[ $quote_ln_close ]] || return
|
|
|
|
|
|
|
|
|
|
# Put in a file brut block quote
|
|
|
|
|
gsl_tmp_quote_brut=`mktemp`
|
|
|
|
|
awk -v lns="$quote_ln_start" -v lnc="$quote_ln_close" \
|
|
|
|
|
'NR >= lns && NR <= lnc {print}' \
|
|
|
|
|
"$1" \
|
|
|
|
|
> "$gsl_tmp_quote_brut"
|
|
|
|
|
|
|
|
|
|
# Define custom CSS class
|
|
|
|
|
my_class=`awk 'NR == 1 {print $2}' "$gsl_tmp_quote_brut"`
|
|
|
|
|
[[ $my_class ]] \
|
|
|
|
|
&& my_class=" $my_class"
|
|
|
|
|
sed -i "1d" "$gsl_tmp_quote_brut"
|
|
|
|
|
sed -i "`cat "$gsl_tmp_quote_brut" | wc -l`d" "$gsl_tmp_quote_brut"
|
|
|
|
|
|
|
|
|
|
# Get metadatas from quote
|
|
|
|
|
#-------------------------
|
|
|
|
|
make__quotes_set() {
|
|
|
|
|
grep "$1" "$gsl_tmp_quote_brut" | awk -F" : " '{print $2}'
|
|
|
|
|
}
|
2022-04-07 14:58:26 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Delete useless line from source
|
|
|
|
|
#--------------------------------
|
|
|
|
|
make__quotes_rmln() {
|
|
|
|
|
[[ "$2" ]] || return
|
|
|
|
|
q_ln=`grep -n "$1" "$gsl_tmp_quote_brut" | awk -F: '{print $1}'`
|
|
|
|
|
sed -i "${q_ln}d" "$gsl_tmp_quote_brut"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
q_link=`make__quotes_set '^_link : '` && \
|
|
|
|
|
make__quotes_rmln '^_link : ' "$q_link"
|
|
|
|
|
q_lang=`make__quotes_set '^_lang : '` && \
|
|
|
|
|
make__quotes_rmln '^_lang : ' "$q_lang"
|
|
|
|
|
q_auth=`make__quotes_set '^_cite : '` && \
|
|
|
|
|
make__quotes_rmln '^_cite : ' "$q_auth"
|
|
|
|
|
q_book=`make__quotes_set '^_book : '` && \
|
|
|
|
|
make__quotes_rmln '^_book : ' "$q_book"
|
|
|
|
|
q_year=`make__quotes_set '^_year : '` && \
|
|
|
|
|
make__quotes_rmln '^_year : ' "$q_year"
|
|
|
|
|
|
|
|
|
|
# Put in a file HTML quote
|
|
|
|
|
gsl_tmp_quote_HTML=`mktemp`
|
|
|
|
|
|
|
|
|
|
[[ "$q_auth" ]] && q_ref="$q_auth "
|
|
|
|
|
[[ "$q_book" ]] && q_book="- $q_book"
|
|
|
|
|
[[ "$q_year" ]] && q_year="($q_year)"
|
|
|
|
|
|
|
|
|
|
# Define HTML
|
|
|
|
|
[[ "$q_link" ]] && q_HTML_link="href=\"$q_link\" target=\"_blank\""
|
|
|
|
|
[[ "$q_lang" ]] && q_HTML_lang=" lang=\"$q_lang\""
|
|
|
|
|
[[ "$q_link" ]] && q_HTML_cite=" cite=\"$q_link\""
|
|
|
|
|
|
|
|
|
|
q_CSS="class=\"${site_css}_quote$my_class\""
|
|
|
|
|
q_CSS_fig="class=\"${site_css}_quote-fig$my_class\""
|
|
|
|
|
q_CSS_link="class=\"${site_css}_quote-link\""
|
|
|
|
|
|
|
|
|
|
if [[ "$q_book" && "$q_year" ]];then
|
|
|
|
|
q_ref+="$q_book$q_year"
|
|
|
|
|
q_data=" $q_book$q_year"
|
|
|
|
|
q_TITLE=" title=\"$q_ref\""
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
elif [[ "$q_book" ]] && ! [[ "$q_year" ]];then
|
|
|
|
|
q_ref+="$q_book"
|
|
|
|
|
q_data=" $q_book"
|
|
|
|
|
q_TITLE=" title=\"$q_ref\""
|
|
|
|
|
|
|
|
|
|
elif [[ "$q_year" ]] && ! [[ "$q_book" ]];then
|
|
|
|
|
q_ref+="$q_year"
|
|
|
|
|
q_data=" $q_year"
|
|
|
|
|
q_TITLE=" title=\"$q_ref\""
|
|
|
|
|
fi
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Make HTML file
|
|
|
|
|
if [[ "$q_auth" ]];then
|
|
|
|
|
# case figure
|
|
|
|
|
cat <<EOQUOTE > "$gsl_tmp_quote_HTML"
|
|
|
|
|
<figure $q_CSS_fig>
|
|
|
|
|
<blockquote$q_HTML_lang$q_HTML_cite>
|
|
|
|
|
$(while read -r "line"
|
|
|
|
|
do
|
|
|
|
|
printf '%4s%s\n' "" "$line"
|
|
|
|
|
done < <(cat "$gsl_tmp_quote_brut"))
|
|
|
|
|
</blockquote>
|
|
|
|
|
<figcaption>
|
|
|
|
|
<cite>
|
|
|
|
|
<a $q_HTML_link$q_TITLE>$q_auth</a>$q_data
|
|
|
|
|
</cite>
|
|
|
|
|
</figcaption>
|
|
|
|
|
</figure>
|
|
|
|
|
EOQUOTE
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
# Simple quote
|
|
|
|
|
cat <<EOQUOTE > "$gsl_tmp_quote_HTML"
|
|
|
|
|
<blockquote $q_CSS$q_HTML_lang$q_HTML_cite$q_TITLE>
|
|
|
|
|
$(while read -r "line"
|
|
|
|
|
do
|
|
|
|
|
printf '%4s%s\n' "" "$line"
|
|
|
|
|
done < <(cat "$gsl_tmp_quote_brut"))
|
|
|
|
|
</blockquote>
|
|
|
|
|
EOQUOTE
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Remove source lines and insert HTML file
|
|
|
|
|
del_ln=`seq $quote_ln_start $quote_ln_close | wc -l`
|
|
|
|
|
for i in `seq 1 $del_ln`
|
|
|
|
|
do
|
|
|
|
|
sed -i "${quote_ln_start}d" "$1"
|
|
|
|
|
done
|
|
|
|
|
sed -i "$((quote_ln_start - 1))r$gsl_tmp_quote_HTML" "$1"
|
|
|
|
|
|
|
|
|
|
#cat "$gsl_tmp_quote_brut"
|
|
|
|
|
rm -f "$gsl_tmp_quote_brut"
|
|
|
|
|
rm -f "$gsl_tmp_quote_HTML"
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
make__quotes "$gsl_tmp_post"
|
2022-02-27 19:16:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
#======================================================================
|
|
|
|
|
# div container between titles
|
|
|
|
|
# $1: file
|
|
|
|
|
#======================================================================
|
|
|
|
|
make__div_title() {
|
|
|
|
|
max_lines=`cat "$1" | wc -l`
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Mark if betwee
|
|
|
|
|
while IFS=: read -r "ln" "content"
|
2022-02-27 19:16:16 +01:00
|
|
|
|
do
|
2022-06-14 18:51:19 +02:00
|
|
|
|
[[ $title_start ]] \
|
|
|
|
|
&& title_close="$ln" \
|
|
|
|
|
|| title_start="$ln"
|
2022-04-23 17:51:46 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
! [[ $title_close ]] && continue
|
|
|
|
|
|
|
|
|
|
if [[ -z `awk -v lns="$title_start" -v lnc="$title_close" \
|
|
|
|
|
'NR > lns && NR < lnc' "$1"` ]];then
|
|
|
|
|
sed -i -e "${title_start}s|^|NODIV|" "$1"
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
sed -i -e "${title_close}s|$|ENDIV|" "$1"
|
2022-02-27 19:16:16 +01:00
|
|
|
|
fi
|
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
title_start=$title_close;unset title_close
|
|
|
|
|
done < <(grep "^<h" -n "$1")
|
2022-04-13 12:24:39 +02:00
|
|
|
|
|
2022-06-14 18:51:19 +02:00
|
|
|
|
# Add div after title
|
|
|
|
|
n=0
|
|
|
|
|
while IFS=: read -r "ln" "content"
|
|
|
|
|
do
|
|
|
|
|
(( n++ ))
|
|
|
|
|
tn=${content:2:1}
|
2022-06-15 16:15:44 +02:00
|
|
|
|
div_title="<div class=\"${site_css}_content ${site_css}_content-h$tn\">"
|
2022-06-14 18:51:19 +02:00
|
|
|
|
sed -i "$(( ln + n ))i$div_title" "$1"
|
|
|
|
|
done < <(grep "^<h" -n "$1")
|
|
|
|
|
|
|
|
|
|
n=1
|
|
|
|
|
# add /div before title
|
|
|
|
|
while IFS=: read -r "ln" "content"
|
2022-04-13 12:24:39 +02:00
|
|
|
|
do
|
2022-06-14 18:51:19 +02:00
|
|
|
|
sed -i "$(( ln + n -1 ))i</div>" "$1"
|
|
|
|
|
(( n++ ))
|
|
|
|
|
done < <(grep -n 'ENDIV$' "$1")
|
|
|
|
|
echo "</div>" >> "$1"
|
|
|
|
|
sed -i "s^NODIV^^g" "$1"
|
|
|
|
|
sed -i "s^ENDIV^^g" "$1"
|
2022-04-13 12:24:39 +02:00
|
|
|
|
}
|