2022-02-27 19:16:16 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# file: gsl__page_creator
|
|
|
|
# Folder: /var/lib/gsl/scripts
|
|
|
|
# By echolib
|
|
|
|
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
|
|
|
|
2022-03-02 17:25:23 +01:00
|
|
|
#----------------------------------------------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
# --------------------------------------------------
|
|
|
|
# From: gsl__all_makers | Create HTML Page
|
|
|
|
# --------------------------------------------------
|
2022-03-02 17:25:23 +01:00
|
|
|
#----------------------------------------------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
|
2022-03-02 17:25:23 +01:00
|
|
|
#----------------------------------------------------------------------
|
2022-03-01 12:39:16 +01:00
|
|
|
# MAIN
|
2022-03-02 17:25:23 +01:00
|
|
|
#----------------------------------------------------------------------
|
2022-03-01 12:39:16 +01:00
|
|
|
gsl__page_creator() {
|
2022-03-02 14:27:50 +01:00
|
|
|
#gsl__page_prepare_datas
|
2022-03-01 12:39:16 +01:00
|
|
|
gsl__check_templates
|
|
|
|
gsl__html_meta_head
|
|
|
|
gsl__page_create
|
2022-04-07 17:12:50 +02:00
|
|
|
|
|
|
|
# Show html result in terminal
|
|
|
|
#cat -n "$gsl_srv_wip_page"
|
2022-03-01 12:39:16 +01:00
|
|
|
}
|
|
|
|
|
2022-03-05 18:06:48 +01:00
|
|
|
#======================================================================
|
|
|
|
# Sync Files from Templates to webserver
|
|
|
|
#======================================================================
|
|
|
|
gsl__srv_sync() {
|
|
|
|
# Sync Files and Folders
|
2022-03-27 18:46:48 +02:00
|
|
|
mkdir -p "$1"
|
2022-03-05 18:06:48 +01:00
|
|
|
for folder in `find $gsl_this_conf_domain/* -type d`
|
|
|
|
do
|
2022-03-27 18:46:48 +02:00
|
|
|
rsync -a --delete "$folder" "$1" && \
|
2022-03-05 18:06:48 +01:00
|
|
|
gsl__logs_print \
|
2022-03-27 18:46:48 +02:00
|
|
|
"$gsl_log_i" \
|
2022-03-05 18:06:48 +01:00
|
|
|
"Server" \
|
|
|
|
"Sync" \
|
2022-03-27 18:46:48 +02:00
|
|
|
"$folder" \
|
|
|
|
"$1"
|
2022-03-05 18:06:48 +01:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-03-02 17:25:23 +01:00
|
|
|
#----------------------------------------------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
# Get Datas for Post/Page
|
2022-03-02 17:25:23 +01:00
|
|
|
#----------------------------------------------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl__page_prepare_datas() {
|
2022-03-12 16:16:21 +01:00
|
|
|
# Set wip folder from domain
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip"
|
2022-03-27 18:46:48 +02:00
|
|
|
gsl_srv_www="$gsl_site_server/$gsl_site_ndd/www"
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
|
|
# Post or Page
|
|
|
|
case "$gsl_post_type" in
|
|
|
|
post)
|
|
|
|
gsl_srv_wip_page="$gsl_srv_wip/$gsl_header_slug/index.html"
|
2022-03-27 18:46:48 +02:00
|
|
|
gsl_srv_www_page="$gsl_srv_www/$gsl_header_slug/index.html"
|
|
|
|
gsl__check_srv_files "$gsl_srv_wip_page" wip
|
|
|
|
gsl__check_srv_files "$gsl_srv_www_page" www
|
2022-04-15 08:50:22 +02:00
|
|
|
gsl_uri=".."
|
2022-02-27 19:16:16 +01:00
|
|
|
;;
|
|
|
|
page)
|
|
|
|
gsl_srv_wip_page="$gsl_srv_wip/$gsl_header_slug.html"
|
2022-03-27 18:46:48 +02:00
|
|
|
gsl_srv_www_page="$gsl_srv_www/$gsl_header_slug.html"
|
|
|
|
gsl__check_srv_files "$gsl_srv_wip_page" wip
|
|
|
|
gsl__check_srv_files "$gsl_srv_www_page" www
|
2022-04-15 08:50:22 +02:00
|
|
|
gsl_uri="."
|
2022-02-27 19:16:16 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
gsl_uri_site_logo="$gsl_uri/templates/$gsl_site_logo"
|
|
|
|
}
|
|
|
|
|
2022-03-02 17:25:23 +01:00
|
|
|
#----------------------------------------------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
# Check if Post / Pages exists in server
|
2022-03-02 17:25:23 +01:00
|
|
|
#----------------------------------------------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl__check_srv_files() {
|
|
|
|
if [[ -f "$1" ]];then
|
2022-03-12 16:16:21 +01:00
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"SRV" \
|
2022-03-27 18:46:48 +02:00
|
|
|
"$2" \
|
|
|
|
"$gsl_post_type $gsl_post exists" \
|
2022-03-12 16:16:21 +01:00
|
|
|
"$1"
|
2022-04-15 08:50:22 +02:00
|
|
|
|
2022-03-27 18:46:48 +02:00
|
|
|
else
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_w" \
|
|
|
|
"SRV" \
|
|
|
|
"$2" \
|
|
|
|
"$gsl_post_type $gsl_post not yet created" \
|
|
|
|
"$1"
|
|
|
|
gsl_checker_war=true
|
2022-02-27 19:16:16 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-03-02 17:25:23 +01:00
|
|
|
#----------------------------------------------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
# Create Final HTML Post/Page
|
2022-03-02 17:25:23 +01:00
|
|
|
#----------------------------------------------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl__page_create() {
|
|
|
|
cat << EOPAGE > "$gsl_srv_wip_page"
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="${gsl_site_lang: :2}">
|
|
|
|
<head>
|
|
|
|
`cat "$gsl_html_meta"`
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body id="${gsl_site_css}_$gsl_post_type">
|
|
|
|
|
|
|
|
`cat "$gsl_dir_domain_tpl/header.html"`
|
|
|
|
|
|
|
|
<section id="${gsl_site_css}_page-wrapper">
|
|
|
|
<article id="${gsl_site_css}_$gsl_header_slug">
|
2022-03-02 17:25:23 +01:00
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
<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>
|
2022-03-02 17:25:23 +01:00
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
`cat "$gsl_a11y_post"`
|
2022-04-07 18:47:48 +02:00
|
|
|
</div>
|
2022-03-02 17:25:23 +01:00
|
|
|
</article>
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
|
|
<aside id="${gsl_site_css}_sidebar">
|
2022-03-02 17:25:23 +01:00
|
|
|
<div class="${gsl_site_css}_wrapper" role="navigation">
|
|
|
|
<nav id="${gsl_site_css}_latest-posts">
|
2022-04-12 17:56:54 +02:00
|
|
|
<h1 class="${gsl_site_css}_latest-posts">$gsl_site_listname</h1>
|
2022-03-02 17:25:23 +01:00
|
|
|
<ul aria-label="Liste d'Articles">
|
|
|
|
<!--# include file="$gsl_uri/templates/last-posts-list.html" -->
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
</aside>
|
2022-02-27 19:16:16 +01:00
|
|
|
</section>
|
|
|
|
|
|
|
|
`cat "$gsl_dir_domain_tpl/footer.html"`
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOPAGE
|
|
|
|
|
2022-03-27 18:46:48 +02:00
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_w" \
|
|
|
|
"SRV" \
|
|
|
|
"wip" \
|
|
|
|
"$gsl_post_type $gsl_post created" \
|
|
|
|
"$gsl_srv_wip_page"
|
|
|
|
gsl_checker_war=true
|
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
# No more needed html meta file
|
|
|
|
rm -f "$gsl_html_meta"
|
|
|
|
}
|
|
|
|
|
2022-03-02 17:25:23 +01:00
|
|
|
#----------------------------------------------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
# Create META head for Post/Page
|
2022-03-02 17:25:23 +01:00
|
|
|
#----------------------------------------------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl__html_meta_head() {
|
|
|
|
# Create file with metas to be included in Post/Page
|
|
|
|
gsl_html_meta=`mktemp`
|
|
|
|
cat << EOMETAS >> "$gsl_html_meta"
|
|
|
|
<meta charset="UTF-8" />
|
|
|
|
<meta name='viewport' content="width=device-width, initial-scale=1.0">
|
|
|
|
<meta name='robots' content="all">
|
|
|
|
<meta name='generator' content="GSL: Statique Littérateur">
|
|
|
|
<meta name='medium' content='website'>
|
|
|
|
<meta name='revisit-after' content="3 days">
|
|
|
|
|
|
|
|
<title>$gsl_header_title - $gsl_site_title</title>
|
2022-04-07 14:58:26 +02:00
|
|
|
<link rel="stylesheet" media="screen" href="$gsl_uri/templates/styles.css" />
|
2022-02-27 19:16:16 +01:00
|
|
|
<link rel="shortcut icon" type="image/png" href="$gsl_uri/templates/favicon.png" />
|
|
|
|
<link rel='me' type='text/html' href="$gsl_site_auth_url">
|
|
|
|
|
|
|
|
<meta name='language' content="$gsl_site_lang">
|
|
|
|
<meta name='reply-to' content="$gsl_site_mail">
|
|
|
|
<meta name='copyright' content="$gsl_site_cr">
|
|
|
|
<meta name='title' content="$gsl_header_title - $gsl_site_title">
|
|
|
|
<meta name='author' content="$gsl_header_author">
|
|
|
|
<meta name='description' content="$gsl_header_info">
|
|
|
|
<meta name='keywords' content="$gsl_site_keys,$gsl_header_tags">
|
|
|
|
<meta name='search_date' content="$gsl_header_date">
|
|
|
|
EOMETAS
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
# Create Generic Header
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
gsl__html_header() {
|
|
|
|
cat << EOHEADER >> "$gsl_dir_domain_tpl/header.html"
|
|
|
|
<header id="${gsl_site_css}_banner">
|
|
|
|
<div id="${gsl_site_css}_site-logo">
|
|
|
|
<a href="/">
|
|
|
|
<img src="$gsl_uri_site_logo"
|
|
|
|
alt="Logo de $gsl_site_title"
|
|
|
|
title="Logo de $gsl_site_title"/>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<section id="${gsl_site_css}_site-titles">
|
|
|
|
<h1 id="${gsl_site_css}_site-name">
|
|
|
|
<a href="/"
|
|
|
|
title="Page d'accueil de $gsl_site_title">
|
|
|
|
$gsl_site_title
|
|
|
|
</a>
|
|
|
|
</h1>
|
|
|
|
<h2 id="${gsl_site_css}_site-description">$gsl_site_info</h2>
|
|
|
|
</section>
|
|
|
|
</header>
|
|
|
|
EOHEADER
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
# Create Generic Footer
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
gsl__html_footer() {
|
|
|
|
cat << EOFOOTER >> "$gsl_dir_domain_tpl/header.html"
|
|
|
|
<footer id=${gsl_site_css}_footer">
|
|
|
|
</footer>
|
|
|
|
EOFOOTER
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
# Check for files in templates folder
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
gsl__check_templates() {
|
|
|
|
# Create generic HEADER if not exists
|
|
|
|
! [[ "$gsl_dir_domain_tpl/header.html" ]] \
|
|
|
|
&& gsl__html_header
|
|
|
|
|
|
|
|
# Create generic FOOTER if not exists
|
|
|
|
! [[ "$gsl_dir_domain_tpl/footer.html" ]] \
|
|
|
|
&& gsl__html_footer
|
|
|
|
}
|
2022-04-14 15:49:49 +02:00
|
|
|
|
|
|
|
#======================================================================
|
2022-04-15 08:50:22 +02:00
|
|
|
# Sidebar Posts list Manager | $1=Process | $2=Position | $3=Post
|
2022-04-14 15:49:49 +02:00
|
|
|
#======================================================================
|
|
|
|
gsl__page_sidebar() {
|
2022-04-15 08:50:22 +02:00
|
|
|
gsl_post="$gsl_this_post"
|
|
|
|
gsl__post_begin
|
|
|
|
gsl__get_needed_headers
|
|
|
|
gsl__page_prepare_datas
|
|
|
|
|
|
|
|
if [[ -f "$gsl_srv_wip_page" ]] ||
|
|
|
|
[[ -f "$gsl_srv_www_page" ]];then
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Sidebar" \
|
|
|
|
"$gsl_listing_process" \
|
|
|
|
"to list, position $2 ; $3 from domain $gsl_find_domain" \
|
|
|
|
"$gsl_listing_file.$2"
|
|
|
|
else
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_i" \
|
|
|
|
"Sidebar" \
|
|
|
|
"$gsl_listing_process" \
|
|
|
|
"make $3 from domain $gsl_find_domain first" \
|
|
|
|
"$gsl_dir_domain_listings/"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$gsl_post_type" in
|
|
|
|
post) gsl_bpost_url="$gsl_header_slug/index.html" ;;
|
|
|
|
page) gsl_bpost_url="$gsl_header_slug.html" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
touch "$gsl_listing_file.$2"
|
|
|
|
cat << EOPostSide > "$gsl_listing_file.$2"
|
|
|
|
<li>
|
|
|
|
<span class="${gsl_site_css}_list-post-title"><a href="$gsl_uri/$gsl_bpost_url" class="${gsl_site_css}_list-post-link">$gsl_header_title</a></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__page_sidebar_create
|
|
|
|
}
|
|
|
|
|
|
|
|
#======================================================================
|
|
|
|
# Sidebar Create from list in X-tra to file last-posts-list.html
|
|
|
|
#======================================================================
|
|
|
|
gsl__page_sidebar_create() {
|
|
|
|
[[ -f "$gsl_dir_domain_tpl/last-posts-list.html" ]] \
|
|
|
|
&& rm -f "$gsl_dir_domain_tpl/last-posts-list.html"
|
|
|
|
|
|
|
|
touch "$gsl_dir_domain_tpl/last-posts-list.html" && \
|
|
|
|
gsl__logs_print \
|
|
|
|
"$gsl_log_w" \
|
|
|
|
"Sidebar" \
|
|
|
|
"Create" \
|
|
|
|
"Build new list" \
|
|
|
|
"$gsl_dir_domain_tpl/last-posts-list.html"
|
|
|
|
|
|
|
|
gsl_checker_war=true
|
|
|
|
while read -r "postroller"
|
|
|
|
do
|
|
|
|
cat "$gsl_dir_domain_listings/$postroller" \
|
|
|
|
>> "$gsl_dir_domain_tpl/last-posts-list.html"
|
2022-04-15 11:49:35 +02:00
|
|
|
done < <(ls -1X "$gsl_dir_domain_listings/")
|
2022-04-14 15:49:49 +02:00
|
|
|
}
|