gsl-statique-litterateur/var/lib/gsl/scripts/gsl__HTML_template

312 lines
9.1 KiB
Bash

#!/bin/bash
# file: gsl__HTML_template
# Folder: /var/lib/gsl/scripts
# By echolib (XMPP: im@echolib.re)
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#======================================================================
# HTML code for <heade>
#
# You can edit this function and create your needed HTML code
# After editing DO: gsl make -F
# for all your pages to be updated
#======================================================================
create__HTML_header() {
cat <<EOHEADER
<header id="${site_css}_banner">
<div id="${site_css}_site-logo">
<a href="/">
<img src="${srv_uri}templates/$site_logo"
alt="Logo: $site_title"
title="Logo: $site_title"/>
</a>
</div>
<div id="${site_css}_site-title">
<h1 id="${site_css}_site-name">
<a href="/"
title="$gsl_welcome $site_itle">
$site_title
</a>
</h1>
<h2 id="${site_css}_site-description">$site_about</h2>
</div>
</header>
EOHEADER
}
#======================================================================
# HTML code in <footer>
# /domains/DOMAIN/templates/footer.html
# ! DO NOT EDIT this function
# It creates file -IF NOT EXISTS-
#
# Add / Edit your own
# Create or Edit file /domains/DOMAIN/templates/footer.html
# After editing DO: gsl make -F
# for all your pages to be updated
#======================================================================
create__HTML_footer() {
cat <<EOFOOTER > "$gsl_dir_domain_tpl/footer.html"
<footer id="${site_css}_footer">
<h1>$gsl_about $site_title</h1>
<div id="${site_css}_footer-infos">
<p>$site_about<p>
</div>
<div id="${site_css}_footer-about">
<ul>
<li><a href="$site_url"><b>$site_title</b></a>: $site_about</li>
<li>Contact: $site_mail</li>
<li>Copyright: $site_cr</li>
<li>$gsl_gen: <a href="https://git.a-lec.org/echolib/gsl" target="_blank"><b>GSL: Statique Littérateur</b></a></li>
<li>RSS: <a type="application/rss+xml" href="$site_url/rss.xml">$site_url/rss.xml</a></li>
</ul>
</div>
</footer>
EOFOOTER
}
#======================================================================
# Translate some static words according to site_lang
#======================================================================
create__HTML_translation() {
if [[ `grep -i "fr" <<<"$site_lang"` ]];then
gsl_welcome="Page d'accueil de"
gsl_written="Écrit par"
gsl_about=" À propos de"
gsl_gen="Propulsé par"
gsl_the="Le"
gsl_by="par"
gsl_read="Lire l'article de"
gsl_rss_info="Tous les titres de"
else
gsl_welcome="Welcome page of"
gsl_written="Written by"
gsl_bout="About"
gsl_gen="Generated with"
gsl_the="The"
gsl_by="by"
gsl_read="Read the post of"
gsl_rss_info="All titles from"
fi
}
#======================================================================
# Page Template
#======================================================================
create__HTML_page() {
create__HTML_translation
! [[ -f "$gsl_dir_domain_tpl/metas.html" ]] \
&& create__HTML_metas
! [[ -f "$gsl_dir_domain_tpl/footer.html" ]] \
&& create__HTML_footer
# Create sub-directories if post only
[[ $article_Type == "post" ]] \
&& mkdir -p "$gsl_srv_wip/$article_Slug"
cat <<EOPAGE > "$gsl_srv_post_wip"
<!DOCTYPE html>
<html lang="${site_lang: :2}">
<head>
$(cat "$gsl_dir_domain_tpl/metas.html")
<meta name='generator' content="GSL: Statique Littérateur">
<meta name='title' content="$article_Title | $site_title">
<meta name='author' content="$article_Author">
<meta name='description' content="$article_Info">
<meta name='keywords' content="$site_keys,$article_Tags">
<meta name='search_date' content="$article_Date">
<link rel="alternate" type="application/rss+xml" href="$site_url/rss.xml" title="RSS: $gsl_rss_info $site_title" />
<link rel="stylesheet" media="screen" href="${srv_uri}templates/styles.css" />
<link rel="shortcut icon" type="image/png" href="${srv_uri}templates/favicon.png" />
<link rel='me' type='text/html' href="$site_auth_url">
<title>$article_Title - $site_title</title>
</head>
<body id="${site_css}_$article_Type$article_CSS">
$(create__HTML_header)
<section id="${site_css}_page-wrapper">
<article id="${site_css}_$article_Slug">
<div id="${site_css}_metas">
<p id="${site_css}_auteur">$gsl_written <strong>$article_Author</strong> - $article_Date</p>
</div>
$(cat "$gsl_tmp_post")
</article>
<aside id="${site_css}_sidebar">
<div class="${ite_css}_wrapper" role="navigation">
<nav id="${site_css}_latest-posts">
<h1 class="${site_css}_latest-posts">$site_listname</h1>
<ul class="${site_css}_latest-posts"
aria-label="$site_listname">
<!--# include file="${srv_uri}templates/sidebar.html" -->
</ul>
</nav>
</div>
</aside>
</section>
$(cat "$gsl_dir_domain_tpl/footer.html")
</body>
</html>
EOPAGE
gsl__logs_print -i -srv -wip \
"Created HTML $article_Type" \
"$gsl_srv_post_wip"
}
#======================================================================
# METAS in <head>
# /domains/DOMAIN/templates/metas.html
# ! DO NOT EDIT this function
# It creates file -IF NOT EXISTS-
#
# Edit your values in the file....
# After editing DO: gsl make -F
# for all your pages to be updated
#======================================================================
create__HTML_metas() {
cat <<EOMETAS > "$gsl_dir_domain_tpl/metas.html"
<meta charset="UTF-8" />
<meta name='viewport' content="width=device-width, initial-scale=1.0">
<meta name='robots' content="all">
<meta name='medium' content='website'>
<meta name='revisit-after' content="3 days">
<meta name='language' content="$site_lang">
<meta name='reply-to' content="$site_mail">
<meta name='copyright' content="$site_cr">
EOMETAS
}
#======================================================================
# Called from sidebar__create in gsl__post_makers
# file: /var/lib/gsl/domains/DOMAIN/X-tra/sidebar/[POSITION].html
# You can edit this HTML code for your needs
# It can get all Values from Database post
# $1: file ($sidebar_HTML_item - see above)
#======================================================================
create__HTML_sidebar_item() {
cat <<EOSIDEBARITEM > "$1"
<li class="${site_css}_list-post-item">
<a href="/$gsl_slug_file"
class="a-lec_list-post-link"
title="$gsl_read $article_Author: $article_Title">
<span class="a-lec_list-post-title">$article_Title</span>
<div class="a-lec_list-post-metas">
$gsl_the $article_Date $gsl_by $article_Author
</div>
<div class="a-lec_list-post-info">
$article_Info
</div>
</a>
</li>
EOSIDEBARITEM
}
#======================================================================
# Called from sidebar__create in gsl__post_makers
# $1: log process
# $2: file: /var/lib/gsl/domains/DOMAIN/templates/sidebar.html
#======================================================================
create__HTML_sidebar() {
gsl_post="sidebar.html"
[[ -f "$2" ]] \
&& rm -f "$2" \
&& gsl__logs_print -w -s $1 \
"Removed to Set new one" \
"$2"
for i in `seq 1 $site_max_list`
do
[[ -f "$gsl_dir_domain_sidebar/$i.html" ]] \
&& cat "$gsl_dir_domain_sidebar/$i.html" \
>> "$2"
done
gsl__logs_print -i -s "$1" \
"Created" \
"$2"
}
#======================================================================
# ATOM/RSS Creator
# File is at root www server ; filename=rss.xml
# reverse sort time from DB | newest first
#======================================================================
create__RSS_feed() {
create__HTML_translation
rss_file="$gsl_srv_www/rss.xml"
cat <<EORSS > "$rss_file"
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>$site_title - $site_ndd - Flux RSS 2.0</title>
<link>$site_url</link>
<description>$gsl_rss_info $site_title</description>
<language>$site_lang</language>
<lastBuildDate>$(date)</lastBuildDate>
<copyright>$site_cr</copyright>
<webMaster>$site_mail</webMaster>
<generator>GSL: Statique Littérateur</generator>
EORSS
while IFS=: read -r "filename" "status"
do
source "$filename"
! (( $article_Status_www > 0 )) && continue
case "$article_Type" in
page) end_url="$article_Slug.html" ;;
post) end_url="$article_Slug/index.html" ;;
esac
cat <<EOITEM >> "$rss_file"
<item>
<title>$article_Title</title>
<link>$site_url/$end_url</link>
<guid>$site_url/$end_url</guid>
<pubDate>$(date -d @$article_epoch)</pubDate>
<description>$article_Info</description>
<author>$article_Author</author>
</item>
EOITEM
done < <(grep "article_epoch" "$gsl_dir_db_domain/"*.db | sort -t= -k2r)
cat <<EORSS >> "$rss_file"
</channel>
</rss>
EORSS
gsl__logs_print -i -srv -www \
"RSS feed updated" \
"$rss_file"
}