#!/bin/bash # file: gsl__page_creator # Folder: /var/lib/gsl/scripts # By echolib # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 #---------------------------------------------------------------------- # -------------------------------------------------- # From: gsl__all_makers | Create HTML Page # -------------------------------------------------- #---------------------------------------------------------------------- #---------------------------------------------------------------------- # MAIN #---------------------------------------------------------------------- gsl__page_creator() { #gsl__page_prepare_datas gsl__check_templates gsl__html_meta_head gsl__page_create # Show html result in terminal #cat -n "$gsl_srv_wip_page" } #====================================================================== # Sync Files from Templates to webserver #====================================================================== gsl__srv_sync() { # Sync Files and Folders mkdir -p "$1" for folder in `find $gsl_this_conf_domain/* -type d` do rsync -a --delete "$folder" "$1" && \ gsl__logs_print \ "$gsl_log_i" \ "Server" \ "Sync" \ "$folder" \ "$1" done } #---------------------------------------------------------------------- # Get Datas for Post/Page #---------------------------------------------------------------------- gsl__page_prepare_datas() { # Set wip folder from domain gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip" gsl_srv_www="$gsl_site_server/$gsl_site_ndd/www" # Post or Page case "$gsl_post_type" in post) gsl_srv_wip_page="$gsl_srv_wip/$gsl_header_slug/index.html" 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 gsl_uri=".." ;; page) gsl_srv_wip_page="$gsl_srv_wip/$gsl_header_slug.html" 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 gsl_uri="." ;; esac gsl_uri_site_logo="$gsl_uri/templates/$gsl_site_logo" } #---------------------------------------------------------------------- # Check if Post / Pages exists in server #---------------------------------------------------------------------- gsl__check_srv_files() { if [[ -f "$1" ]];then gsl__logs_print \ "$gsl_log_i" \ "SRV" \ "$2" \ "$gsl_post_type $gsl_post exists" \ "$1" else gsl__logs_print \ "$gsl_log_w" \ "SRV" \ "$2" \ "$gsl_post_type $gsl_post not yet created" \ "$1" gsl_checker_war=true fi } #---------------------------------------------------------------------- # Create Final HTML Post/Page #---------------------------------------------------------------------- gsl__page_create() { cat << EOPAGE > "$gsl_srv_wip_page" `cat "$gsl_html_meta"` `cat "$gsl_dir_domain_tpl/header.html"`

Écrit par $gsl_header_author le $gsl_header_date

`cat "$gsl_a11y_post"`
`cat "$gsl_dir_domain_tpl/footer.html"` EOPAGE gsl__logs_print \ "$gsl_log_w" \ "SRV" \ "wip" \ "$gsl_post_type $gsl_post created" \ "$gsl_srv_wip_page" gsl_checker_war=true # No more needed html meta file rm -f "$gsl_html_meta" } #---------------------------------------------------------------------- # Create META head for Post/Page #---------------------------------------------------------------------- gsl__html_meta_head() { # Create file with metas to be included in Post/Page gsl_html_meta=`mktemp` cat << EOMETAS >> "$gsl_html_meta" $gsl_header_title - $gsl_site_title EOMETAS } #----------------------------------------------------------------------- # Create Generic Header #----------------------------------------------------------------------- gsl__html_header() { cat << EOHEADER >> "$gsl_dir_domain_tpl/header.html"

$gsl_site_title

$gsl_site_info

EOHEADER } #----------------------------------------------------------------------- # Create Generic Footer #----------------------------------------------------------------------- gsl__html_footer() { cat << EOFOOTER >> "$gsl_dir_domain_tpl/header.html" 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 } #====================================================================== # Sidebar Posts list Manager | $1=Process | $2=Position | $3=Post #====================================================================== gsl__page_sidebar() { 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"
  • $gsl_header_title
    Le $gsl_header_date par $gsl_header_author
    $gsl_header_info
  • 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" done < <(ls -1X "$gsl_dir_domain_listings/") }